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 like this:

       rootPane.add(child);
 
Using JRootPane the proper semantic is:
       rootPane.getContentPane().add(child);
 
The same priniciple holds true for setting layout managers, removing components, listing children, etc. All these methods should normally be sent to the contentPane instead of to the JRootPane. The contentPane is always non-null. Attempting to set it to null generates an exception. The default contentPane has a BorderLayout manager set on it.

If a JMenuBar component is set on the JRootPane, it is positioned along the upper edge of the frame. The contentPane is adjusted in location and size to fill the remaining area.

The JMenuBar and the contentPane are 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 is always non-null. Attempting to set it to null generates an exception.

The glassPane is always added as the first child of the JRootPane. This allows the 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 is always non-null. Attempting to set it to null generates an exception. Developers should use setVisible on the glassPane to control when the glassPane displays over the other children. By default the glassPane is not 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.

Warning: serialized objects of this class will not be compatible with future swing releases. The current serialization support is appropriate for short term storage or RMI between Swing1.0 applications. It will not be possible to load serialized Swing1.0 objects with future releases of Swing. The JDK1.2 release of Swing will be the compatibility baseline for the serialized form of Swing objects.

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

Variable Index

 o contentPane
 o defaultButton
 o defaultPressAction
 o defaultReleaseAction
 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 getAccessibleContext()
Get the AccessibleContext associated with this JComponent
 o getContentPane()
 o getDefaultButton()
Returns the current default button for this JRootPane.
 o getGlassPane()
Returns the current glass pane for this JRootPane.
 o getLayeredPane()
 o getMenuBar()
 o setContentPane(Container)
 o setDefaultButton(JButton)
Sets the current default button for this JRootPane.
 o setGlassPane(Component)
Sets a specified Component to be the glass pane for this root pane.
 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
 o defaultButton
 protected JButton defaultButton
 o defaultPressAction
 protected JRootPane. DefaultAction defaultPressAction
 o defaultReleaseAction
 protected JRootPane. DefaultAction defaultReleaseAction

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)
Sets a specified Component to be the glass pane for this root pane. The glass pane should normally be a lightweight, transparent component, because it will be made visible when ever the root pane needs to grab input events. For example, only one JInternalFrame is ever active when using a DefaultDesktop, and any inactive JInternalFrames' glass panes are made visible so that clicking anywhere within an inactive JInternalFrame can activate it.

Parameters:
glass - the Component to use as the glass pane for this JRootPane.
 o getGlassPane
 public Component getGlassPane()
Returns the current glass pane for this JRootPane.

Returns:
the current glass pane.
 o setDefaultButton
 public void setDefaultButton(JButton defaultButton)
Sets the current default button for this JRootPane. The default button is the button which will be activated when a UI-defined activation event (typically the key) occurs in the RootPane regardless of whether or not the button has keyboard focus (unless there is another component within the RootPane which consumes the activation event, such as a JTextPane). For default activation to work, the button must be an enabled descendent of the RootPane when activation occurs. To remove a default button from this RootPane, set this property to null.

Parameters:
default - the default button.
See Also:
isDefaultButton
 o getDefaultButton
 public JButton getDefaultButton()
Returns the current default button for this JRootPane.

Returns:
the current default button.
 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 getAccessibleContext
 public AccessibleContext getAccessibleContext()
Get the AccessibleContext associated with this JComponent

Returns:
the AccessibleContext of this JComponent
Overrides:
getAccessibleContext in class JComponent

All Packages  Class Hierarchy  This Package  Previous  Next  Index