All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object | +----java.awt.Component | +----java.awt.Container | +----java.awt.swing.JComponent | +----java.awt.swing.JRootPane
JRootPane glassPane layeredPane [menuBar] contentPaneThe menuBar component is optional and may or may exist at any time. The layeredPane, contentPane, and glassPane will always be available.
The contentPane() should be the parent of any children of the JRootPane. You would normally do something:
rootPane.add(child);Using JRootPane the proper semantic is:
rootPane.getContentPane().add(child);The same is true of setting LayoutManagers, removing components, listing children, etc. All these methods should normally be sent to the contentPane() instead of the JRootPane itself. The contentPane() will always be non-null. Attempting to set it to null will cause the JRootPane to throw an exception. The default contentPane() will have a BorderLayout manager set on it.
If a JMenuBar component is set on the JRootPane, it will be positioned along the upper edge of the frame. The contentPane() will be adjusted in location and size to fill the remaining area.
The JMenuBar and the contentPane() will be added to the layeredPane() component at the JLayeredPane.FRAME_CONTENT_LAYER layer.
The layeredPane() is an instance of the JLayeredPane class. It's purpose is to be the parent of all children of the JRootPane. It provides the ability to add components at several layers. This is very useful when working with menu popups, dialog boxes, or during dragging. Situations where you need to place a component over the top of all other normal components. The layeredPane() will always be non-null. Attempting to set it to null will cause the JRootPane to throw an exception.
The glassPane() will always be added as the first child of the JRootPane. This allows this glass component to get in the way of all mouse events, as well as providing a convient place to draw above all other components. The glassPane() will always be non-null. Attempting to set it to null will cause the JRootPane to throw an exception. Developers should use the setVisible() call on the glassPane to control when the glassPane displays over the other children. By default the glassPane will not be visible.
The JRootPane uses a custom LayoutManager. This LayoutManager insures the following:
protected JMenuBar menuBar
protected Container contentPane
protected JLayeredPane layeredPane
protected Component glassPane
public JRootPane()
protected JLayeredPane createLayeredPane()
protected Container createContentPane()
protected Component createGlassPane()
protected LayoutManager createRootLayout()
public void setMenuBar(JMenuBar menu)
public JMenuBar getMenuBar()
public void setContentPane(Container content)
public Container getContentPane()
public void setLayeredPane(JLayeredPane layered)
public JLayeredPane getLayeredPane()
public void setGlassPane(Component glass)
public Component getGlassPane()
protected void addImpl(Component comp, Object constraints, int index)
public AccessibleRole getAccessibleRole()
All Packages Class Hierarchy This Package Previous Next Index