*
* @param parent the Container for which this layout manager is being
* used
*/
public void layoutContainer(Container parent) {
JRootPane root = (JRootPane) parent;
Rectangle b = root.getBounds();
Insets i = root.getInsets();
int nextY = 0;
int w = b.width - i.right - i.left;
int h = b.height - i.top - i.bottom;
if (root.getLayeredPane() != null) {
root.getLayeredPane().setBounds(i.left, i.top, w, h);
}
if (root.getGlassPane() != null) {
root.getGlassPane().setBounds(i.left, i.top, w, h);
}
// Note: This is laying out the children in the layeredPane,
// technically, these are not our children.
if (root.getWindowDecorationStyle() != JRootPane.NONE && (root.getUI() instanceof SeaGlassRootPaneUI)) {
JComponent titlePane = ((SeaGlassRootPaneUI) root.getUI()).getTitlePane();
if (titlePane != null) {
Dimension tpd = titlePane.getPreferredSize();
if (tpd != null) {
int tpHeight = tpd.height;
titlePane.setBounds(0, 0, w, tpHeight);
nextY += tpHeight;
}
}
}
if (root.getJMenuBar() != null) {
boolean menuInTitle = (root.getClientProperty("JRootPane.MenuInTitle") == Boolean.TRUE);
Dimension mbd = root.getJMenuBar().getPreferredSize();
int x = menuInTitle? 20 : 0;
root.getJMenuBar().setBounds(x, menuInTitle ? 0 : nextY, w, mbd.height);
root.getJMenuBar().setOpaque(false);
root.getJMenuBar().setBackground(transparentColor);
if (!menuInTitle) {
nextY += mbd.height;
}
}
if (root.getContentPane() != null) {
/* Dimension cpd = */ root.getContentPane().getPreferredSize();
root.getContentPane().setBounds(0, nextY, w, h < nextY ? 0 : h - nextY);
}
}