All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.sun.java.swing.JRootPane

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----com.sun.java.swing.JComponent
                           |
                           +----com.sun.java.swing.JRootPane

public class JRootPane
extends JComponent
implements Accessible
The JRootPane component is made up of several components. In order they are:
      JRootPane
          glassPane
          layeredPane 
              [menuBar]
              contentPane
 
The 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:

  1. The glassPane(), if present, fills the entire viewable area of the JRootPane. (bounds - insets)
  2. The layeredPane() fills the entire viewable area of the JRootPane. (bounds - insets)
  3. The menuBar() is positioned at the upper edge of the layeredPane().
  4. The contentPane() fills the entire viewable area, minus the MenuBar, if present.
Any other views in the JRootPane view hierarchy are ignored. If you replace the LayoutManager of the JRootPane, you are responsible for managing all of these views.

See Also:
JLayeredPane, JMenuBar, JWindow, JFrame, JDialog

Variable Index

 o contentPane
 o glassPane
 o layeredPane
 o menuBar

Constructor Index

 o JRootPane()

Method Index

 o addImpl(Component, Object, int)
Overridden to enforce the position of the glass component as the zero child.
 o createContentPane()
Called by the constructor methods to create the default contentPane.
 o createGlassPane()
Called by the constructor methods to create the default glassPane.
 o createLayeredPane()
Called by the constructor methods to create the default layeredPane.
 o createRootLayout()
Called by the constructor methods to create the default layoutManager.
 o getAccessibleRole()
Get the role of this object.
 o getContentPane()
 o getGlassPane()
 o getLayeredPane()
 o getMenuBar()
 o setContentPane(Container)
 o setGlassPane(Component)
 o setLayeredPane(JLayeredPane)
 o setMenuBar(JMenuBar)

Variables

 o menuBar
 protected JMenuBar menuBar
 o contentPane
 protected Container contentPane
 o layeredPane
 protected JLayeredPane layeredPane
 o glassPane
 protected Component glassPane

Constructors

 o JRootPane
 public JRootPane()

Methods

 o createLayeredPane
 protected JLayeredPane createLayeredPane()
Called by the constructor methods to create the default layeredPane. Bt default it creates a new JLayeredPane.

 o createContentPane
 protected Container createContentPane()
Called by the constructor methods to create the default contentPane. By default this method creates a new JComponent add sets a BorderLayout as its LayoutManager.

 o createGlassPane
 protected Component createGlassPane()
Called by the constructor methods to create the default glassPane. By default this method creates a new JComponent with visibility set to false.

 o createRootLayout
 protected LayoutManager createRootLayout()
Called by the constructor methods to create the default layoutManager.

 o setMenuBar
 public void setMenuBar(JMenuBar menu)
 o getMenuBar
 public JMenuBar getMenuBar()
 o setContentPane
 public void setContentPane(Container content)
 o getContentPane
 public Container getContentPane()
 o setLayeredPane
 public void setLayeredPane(JLayeredPane layered)
 o getLayeredPane
 public JLayeredPane getLayeredPane()
 o setGlassPane
 public void setGlassPane(Component glass)
 o getGlassPane
 public Component getGlassPane()
 o addImpl
 protected void addImpl(Component comp,
                        Object constraints,
                        int index)
Overridden to enforce the position of the glass component as the zero child.

Overrides:
addImpl in class Container
 o getAccessibleRole
 public AccessibleRole getAccessibleRole()
Get the role of this object.

Returns:
an instance of AccessibleRole describing the role of the object
Overrides:
getAccessibleRole in class JComponent
See Also:
AccessibleRole

All Packages  Class Hierarchy  This Package  Previous  Next  Index