int preferredHeight = 0;
Window window = (Window)getComponent();
Component content = window.getContent();
Dimensions preferredTitleBarSize = titleBarFlowPane.getPreferredSize();
preferredWidth = preferredTitleBarSize.width;
preferredHeight = preferredTitleBarSize.height;
if (content != null
&& content.isDisplayable()) {
Dimensions preferredContentSize = content.getPreferredSize();
preferredWidth = Math.max(preferredWidth, preferredContentSize.width);
preferredHeight += preferredContentSize.height;
}
preferredWidth += (padding.left + padding.right) + 2;
preferredHeight += (padding.top + padding.bottom) + 4;
return new Dimensions(preferredWidth, preferredHeight);
}