return new Dimensions(preferredWidth, preferredHeight);
}
@Override
public void layout() {
Frame frame = (Frame)getComponent();
int width = getWidth();
int height = getHeight();
boolean maximized = frame.isMaximized();
if (!maximized
|| getShowWindowControls()) {
int clientX = 1;
int clientY = 1;
int clientWidth = Math.max(width - 2, 0);
int clientHeight = Math.max(height - 2, 0);
// Size/position title bar
titleBarTablePane.setLocation(clientX, clientY);
titleBarTablePane.setSize(clientWidth, titleBarTablePane.getPreferredHeight());
titleBarTablePane.setVisible(true);
// Add bottom title bar border, top content border, and content bevel
clientY += titleBarTablePane.getHeight() + (showContentBevel ? 1 : 0) + 2;
// Size/position resize handle
resizeHandle.setSize(resizeHandle.getPreferredSize());
resizeHandle.setLocation(clientWidth - resizeHandle.getWidth(),
clientHeight - resizeHandle.getHeight());
resizeHandle.setVisible(resizable
&& !maximized
&& (frame.isPreferredWidthSet()
|| frame.isPreferredHeightSet()));
// Size/position menu bar
MenuBar menuBar = frame.getMenuBar();
if (menuBar != null
&& menuBar.isVisible()) {
menuBar.setLocation(clientX, clientY);
menuBar.setSize(clientWidth, menuBar.getPreferredHeight());
clientY += menuBar.getHeight();
}
// Size/position content
Component content = frame.getContent();
if (content != null) {
int contentX = clientX + padding.left;
int contentY = clientY + padding.top;
int contentWidth = Math.max(clientWidth - (padding.left + padding.right), 0);
int contentHeight = Math.max(clientHeight - (clientY + padding.top + padding.bottom) + (showContentBevel ? 1 : 0), 0);
content.setLocation(contentX, contentY);
content.setSize(contentWidth, contentHeight);
}
} else {
titleBarTablePane.setVisible(false);
resizeHandle.setVisible(false);
// Size/position menu bar
int clientY = 0;
MenuBar menuBar = frame.getMenuBar();
if (menuBar != null
&& menuBar.isVisible()) {
menuBar.setLocation(0, clientY);
menuBar.setSize(width, menuBar.getPreferredHeight());
clientY += menuBar.getHeight();
}
Component content = frame.getContent();
if (content != null) {
content.setLocation(padding.left, clientY + padding.top);
content.setSize(Math.max(width - (padding.left + padding.right), 0),
Math.max(height - (clientY + padding.top + padding.bottom), 0));
}