java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--javax.swing.JComponent | +--javax.swing.JRootPane
A lightweight container used behind the scenes by JFrame, JDialog, JWindow, JApplet, and JInternalFrame. For task-oriented information on functionality provided by root panes see How to Use Root Panes, a section in The Java Tutorial.
The following image shows the relationships between the classes that use root panes.

Note: The JComponent method getRootPane can be used to
obtain the JRootPane that contains a given component.
|
Although the menuBar component is optional, the layeredPane, contentPane, and glassPane always exist. Attempting to set them to null generates an exception.
The contentPane must be the parent of any children of
the JRootPane. Rather than adding directly to a JRootPane, like this:
rootPane.add(child);
You instead add to the contentPane of the JRootPane, like this:
rootPane.getContentPane().add(child);
The same priniciple holds true for setting layout managers, removing
components, listing children, etc. All these methods are invoked on
the contentPane instead of on the JRootPane.
Note: The default layout manager for theIf a JMenuBar component is set on the JRootPane, it is positioned along the upper edge of the frame. ThecontentPaneis a BorderLayout manager. However, the JRootPane uses a custom LayoutManager. So, when you want to change the layout manager for the components you added to a JRootPane, be sure to use code like this:rootPane.getContentPane().setLayout(new BoxLayout());
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 the parent of all children in the JRootPane.
It is an instance of JLayeredPane, which provides the ability to add components
at several layers. This capability is very useful when working with menu popups,
dialog boxes, and dragging -- situations in which you need to place a component
on top of all other components in the pane.
The glassPane sits on top of all other components in the JRootPane.
That provides a convenient place to draw above all other components, and makes
it possible to intercept mouse events, which is useful both for dragging and
for drawing. Developers can use setVisible on the glassPane
to control when the glassPane displays over the other children.
By default the glassPane is not visible.
The custom LayoutManager used by JRootPane ensures that:
glassPane, if present, fills the entire viewable
area of the JRootPane (bounds - insets).
layeredPane fills the entire viewable area of the
JRootPane. (bounds - insets)
menuBar is positioned at the upper edge of the
layeredPane().
contentPane fills the entire viewable area,
minus the MenuBar, if present.
If you replace the LayoutManager of the JRootPane, you are responsible for
managing all of these views. So ordinarily you will want to be sure that you
change the layout manager for the contentPane rather than
for the JRootPane itself!
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 applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
JLayeredPane,
JMenuBar,
JWindow,
JFrame,
JDialog,
JApplet,
JInternalFrame,
JComponent,
BoxLayout,
Mixing Heavy and Light Components, Serialized Form
| Inner Class Summary | |
protected class |
JRootPane.AccessibleJRootPane
JRootPane.AccessibleJRootPane
|
protected class |
JRootPane.RootLayout
JRootPane.RootLayout
|
| Inner classes inherited from class javax.swing.JComponent |
JComponent.AccessibleJComponent |
| Inner classes inherited from class java.awt.Container |
Container.AccessibleAWTContainer |
| Inner classes inherited from class java.awt.Component |
Component.AccessibleAWTComponent |
| Field Summary | |
protected Container |
contentPane
copy-> contentPane
|
protected JButton |
defaultButton
copy-> defaultButton
|
protected javax.swing.JRootPane.DefaultAction |
defaultPressAction
copy-> defaultPressAction
|
protected javax.swing.JRootPane.DefaultAction |
defaultReleaseAction
copy-> defaultReleaseAction
|
protected Component |
glassPane
copy-> glassPane
|
protected JLayeredPane |
layeredPane
copy-> layeredPane
|
protected JMenuBar |
menuBar
copy-> menuBar
|
| Fields inherited from class javax.swing.JComponent |
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
| Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
JRootPane
copy-> new JRootPane()copy-> <JRootPane var> = new JRootPane();
|
|
| Method Summary | |
protected void |
addImpl(Component comp,
Object constraints,
int index)
copy-> .addImpl(, , )copy-> <JRootPane>.addImpl(<Component comp>, <Object constraints>, <int index>);
|
void |
addNotify()
copy-> .addNotify()copy-> <JRootPane>.addNotify();
|
protected Container |
createContentPane()
copy-> .createContentPane()copy-> <Container var>=<JRootPane>.createContentPane();
|
protected Component |
createGlassPane()
copy-> .createGlassPane()copy-> <Component var>=<JRootPane>.createGlassPane();
|
protected JLayeredPane |
createLayeredPane()
copy-> .createLayeredPane()copy-> <JLayeredPane var>=<JRootPane>.createLayeredPane();
|
protected LayoutManager |
createRootLayout()
copy-> .createRootLayout()copy-> <LayoutManager var>=<JRootPane>.createRootLayout();
|
AccessibleContext |
getAccessibleContext()
copy-> .getAccessibleContext()copy-> <AccessibleContext var>=<JRootPane>.getAccessibleContext();
|
Container |
getContentPane()
copy-> .getContentPane()copy-> <Container var>=<JRootPane>.getContentPane();
|
JButton |
getDefaultButton()
copy-> .getDefaultButton()copy-> <JButton var>=<JRootPane>.getDefaultButton();
|
Component |
getGlassPane()
copy-> .getGlassPane()copy-> <Component var>=<JRootPane>.getGlassPane();
|
JMenuBar |
getJMenuBar()
copy-> .getJMenuBar()copy-> <JMenuBar var>=<JRootPane>.getJMenuBar();
|
JLayeredPane |
getLayeredPane()
copy-> .getLayeredPane()copy-> <JLayeredPane var>=<JRootPane>.getLayeredPane();
|
JMenuBar |
getMenuBar()
copy-> .getMenuBar()copy-> <JMenuBar var>=<JRootPane>.getMenuBar();
|
RootPaneUI |
getUI()
copy-> .getUI()copy-> <RootPaneUI var>=<JRootPane>.getUI();
|
String |
getUIClassID()
copy-> .getUIClassID()copy-> <String var>=<JRootPane>.getUIClassID();
|
boolean |
isFocusCycleRoot()
copy-> .isFocusCycleRoot()copy-> <boolean var>=<JRootPane>.isFocusCycleRoot();
|
boolean |
isOptimizedDrawingEnabled()
copy-> .isOptimizedDrawingEnabled()copy-> <boolean var>=<JRootPane>.isOptimizedDrawingEnabled();
|
boolean |
isValidateRoot()
copy-> .isValidateRoot()copy-> <boolean var>=<JRootPane>.isValidateRoot();
|
protected String |
paramString()
copy-> .paramString()copy-> <String var>=<JRootPane>.paramString();
|
void |
removeNotify()
copy-> .removeNotify()copy-> <JRootPane>.removeNotify();
|
void |
setContentPane(Container content)
copy-> .setContentPane( )copy-> <JRootPane>.setContentPane(<Container content>);
|
void |
setDefaultButton(JButton defaultButton)
copy-> .setDefaultButton( )copy-> <JRootPane>.setDefaultButton(<JButton defaultButton>);
|
void |
setGlassPane(Component glass)
copy-> .setGlassPane( )copy-> <JRootPane>.setGlassPane(<Component glass>);
|
void |
setJMenuBar(JMenuBar menu)
copy-> .setJMenuBar( )copy-> <JRootPane>.setJMenuBar(<JMenuBar menu>);
|
void |
setLayeredPane(JLayeredPane layered)
copy-> .setLayeredPane( )copy-> <JRootPane>.setLayeredPane(<JLayeredPane layered>);
|
void |
setMenuBar(JMenuBar menu)
copy-> .setMenuBar( )copy-> <JRootPane>.setMenuBar(<JMenuBar menu>);
|
void |
setUI(RootPaneUI ui)
copy-> .setUI( )copy-> <JRootPane>.setUI(<RootPaneUI ui>);
|
void |
updateUI()
copy-> .updateUI()copy-> <JRootPane>.updateUI();
|
| Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validate, validateTree |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |