Top Description Inners Fields Constructors Methods
javax.swing

public Class JRootPane

extends JComponent
implements Accessible
Class Inheritance
All Implemented Interfaces
javax.accessibility.Accessible
Annotations
@SuppressWarnings:serial
Imports
java.awt.*, java.beans.*, java.security.AccessController, javax.accessibility.*, javax.swing.plaf.RootPaneUI, java.io.Serializable, sun.security.action.GetBooleanAction

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.

The following text describes this graphic.

The "heavyweight" components (those that delegate to a peer, or native component on the host system) are shown with a darker, heavier box. The four heavyweight JFC/Swing containers (JFrame, JDialog, JWindow, and JApplet) are shown in relation to the AWT classes they extend. These four components are the only heavyweight containers in the Swing library. The lightweight container JInternalFrame is also shown. All five of these JFC/Swing containers implement the RootPaneContainer interface, and they all delegate their operations to a JRootPane (shown with a little "handle" on top).

Note

The JComponent method getRootPane can be used to obtain the JRootPane that contains a given component.

Example:

the following text describes this graphic.

The diagram at right shows the structure of a JRootPane. A JRootpane is made up of a glassPane, an optional menuBar, and a contentPane. (The JLayeredPane manages the menuBar and the contentPane.) The glassPane sits over the top of everything, where it is in a position to intercept mouse movements. Since the glassPane (like the contentPane) can be an arbitrary component, it is also possible to set up the glassPane for drawing. Lines and images on the glassPane can then range over the frames underneath without being limited by their boundaries.

Although the menuBar component is optional, the layeredPane, contentPane, and glassPane always exist. Attempting to set them to null generates an exception.

To add components to the JRootPane (other than the optional menu bar), you add the object to the contentPane of the JRootPane, like this:

      rootPane.getContentPane().add(child);
The same principle 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 the contentPane is 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());
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 the parent of all children in the JRootPane -- both as the direct parent of the menu and the grandparent of all components added to the contentPane. 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:

  1. The glassPane 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. So ordinarily you will want to be sure that you change the layout manager for the contentPane rather than for the JRootPane itself!

The painting architecture of Swing requires an opaque JComponent to exist in the containment hierarchy above all other components. This is typically provided by way of the content pane. If you replace the content pane, it is recommended that you make the content pane opaque by way of setOpaque(true). Additionally, if the content pane overrides paintComponent, it will need to completely fill in the background in an opaque color in paintComponent.

Warning

Swing is not thread safe. For more information see Swing's Threading Policy.

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. As of 1.4, support for long term storage of all JavaBeans has been added to the java.beans package. Please see java.beans.XMLEncoder.

Author
David Kloba
Since
1.2
See Also
JLayeredPane, JMenuBar, JWindow, JFrame, JDialog, JApplet, JInternalFrame, JComponent, BoxLayout, Mixing Heavy and Light Components

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected class
JRootPane.AccessibleJRootPane

This class implements accessibility support for the JRootPane class.

protected class
JRootPane.RootLayout

A custom layout manager that is responsible for the layout of layeredPane, glassPane, and menuBar.

Field Summary

Modifier and TypeField and Description
public static final int
COLOR_CHOOSER_DIALOG

Constant used for the windowDecorationStyle property.

protected Container
contentPane

The content pane.

protected JButton
defaultButton

The button that gets activated when the pane has the focus and a UI-specific action like pressing the Enter key occurs.

public static final int
ERROR_DIALOG

Constant used for the windowDecorationStyle property.

public static final int
FILE_CHOOSER_DIALOG

Constant used for the windowDecorationStyle property.

public static final int
FRAME

Constant used for the windowDecorationStyle property.

protected Component
glassPane

The glass pane that overlays the menu bar and content pane, so it can intercept mouse movements and such.

private static final boolean
IGNORE_DISABLE_TRUE_DOUBLE_BUFFERING

Whether or not we should ignore requests to disable true double buffering.

public static final int
INFORMATION_DIALOG

Constant used for the windowDecorationStyle property.

protected JLayeredPane
layeredPane

The layered pane that manages the menu bar and content pane.

private static final boolean
LOG_DISABLE_TRUE_DOUBLE_BUFFERING

Whether or not we should dump the stack when true double buffering is disabled.

public static final int
NONE

Constant used for the windowDecorationStyle property.

public static final int
PLAIN_DIALOG

Constant used for the windowDecorationStyle property.

public static final int
QUESTION_DIALOG

Constant used for the windowDecorationStyle property.

private static final String
pack-priv boolean
useTrueDoubleBuffering

Whether or not true double buffering should be used.

public static final int
WARNING_DIALOG

Constant used for the windowDecorationStyle property.

private int
Inherited from javax.swing.JComponent:
DEBUG_GRAPHICS_LOADEDfocusControllerlistenerListpaintingChildTOOL_TIP_TEXT_KEYuiUNDEFINED_CONDITIONWHEN_ANCESTOR_OF_FOCUSED_COMPONENTWHEN_FOCUSEDWHEN_IN_FOCUSED_WINDOW

Constructor Summary

AccessConstructor and Description
public
JRootPane()

Creates a JRootPane, setting up its glassPane, layeredPane, and contentPane.

Method Summary

Modifier and TypeMethod and Description
protected void
addImpl(Component
the component to be enhanced
comp
,
Object
the constraints to be respected
constraints
,
int
the index
index
)

Overrides java.awt.Container.addImpl.

Overridden to enforce the position of the glass component as the zero child.
public void
addNotify()

Overrides javax.swing.JComponent.addNotify.

Notifies this component that it now has a parent component.
protected Container

Returns:

the default contentPane
createContentPane
()

Called by the constructor methods to create the default contentPane.

protected Component

Returns:

the default glassPane
createGlassPane
()

Called by the constructor methods to create the default glassPane.

protected JLayeredPane

Returns:

the default layeredPane
createLayeredPane
()

Called by the constructor methods to create the default layeredPane.

protected LayoutManager

Returns:

the default layoutManager.
createRootLayout
()

Called by the constructor methods to create the default layoutManager.

pack-priv final void
public AccessibleContext

Returns:

an AccessibleJRootPane that serves as the AccessibleContext of this JRootPane
getAccessibleContext
()

Overrides java.awt.Component.getAccessibleContext.

Implements javax.accessibility.Accessible.getAccessibleContext.

Gets the AccessibleContext associated with this JRootPane.
public Container

Returns:

the Container that holds the component-contents
getContentPane
()

Returns the content pane -- the container that holds the components parented by the root pane.

public JButton

Returns:

the JButton which is currently the default button
getDefaultButton
()

Returns the value of the defaultButton property.

public Component

Returns:

the current glass pane
getGlassPane
()

Returns the current glass pane for this JRootPane.

public JMenuBar

Returns:

the JMenuBar used in the pane
getJMenuBar
()

Returns the menu bar from the layered pane.

public JLayeredPane

Returns:

the JLayeredPane currently in use
getLayeredPane
()

Gets the layered pane used by the root pane.

public JMenuBar

Returns:

the JMenuBar used in the pane
getMenuBar
()

Deprecated As of Swing version 1.0.3 replaced by getJMenuBar().
Returns the menu bar value.
public RootPaneUI

Returns:

LabelUI object
getUI
()

Overrides javax.swing.JComponent.getUI.

Returns the L&F object that renders this component.
public String

Returns:

the string "RootPaneUI"
getUIClassID
()

Overrides javax.swing.JComponent.getUIClassID.

Returns a string that specifies the name of the L&F class that renders this component.
pack-priv final boolean
public int

Returns:

One of NONE, FRAME, PLAIN_DIALOG, INFORMATION_DIALOG, ERROR_DIALOG, COLOR_CHOOSER_DIALOG, FILE_CHOOSER_DIALOG, QUESTION_DIALOG or WARNING_DIALOG.
getWindowDecorationStyle
()

Returns a constant identifying the type of Window decorations the JRootPane is providing.

public boolean

Returns:

true if this component's children don't overlap
isOptimizedDrawingEnabled
()

Overrides javax.swing.JComponent.isOptimizedDrawingEnabled.

The glassPane and contentPane have the same bounds, which means JRootPane does not tiles its children and this should return false.
public boolean

Returns:

true
isValidateRoot
()

Overrides javax.swing.JComponent.isValidateRoot.

If a descendant of this JRootPane calls revalidate, validate from here on down.
protected String

Returns:

a string representation of this JRootPane.
paramString
()

Overrides javax.swing.JComponent.paramString.

Returns a string representation of this JRootPane.
public void
removeNotify()

Overrides javax.swing.JComponent.removeNotify.

Notifies this component that it no longer has a parent component.
public void
setContentPane(Container
the Container to use for component-contents
content
)

Sets the content pane -- the container that holds the components parented by the root pane.

public void
setDefaultButton(JButton
the JButton which is to be the default button
defaultButton
)

Sets the defaultButton property, which determines the current default button for this JRootPane.

public void
setDoubleBuffered(boolean
if true, set this component to be double buffered
aFlag
)

Overrides javax.swing.JComponent.setDoubleBuffered.

Sets whether this component should use a buffer to paint.
public void
setGlassPane(Component
the Component to use as the glass pane for this JRootPane
glass
)

Sets a specified Component to be the glass pane for this root pane.

public void
setJMenuBar(JMenuBar
the JMenuBar to add
menu
)

Adds or changes the menu bar used in the layered pane.

public void
setLayeredPane(JLayeredPane
the JLayeredPane to use
layered
)

Sets the layered pane for the root pane.

public void
setMenuBar(JMenuBar
the JMenuBar to add.
menu
)

Deprecated As of Swing version 1.0.3 replaced by setJMenuBar(JMenuBar menu).
Specifies the menu bar value.
public void
setUI(RootPaneUI
the LabelUI L&F object
ui
)

Sets the L&F object that renders this component.

pack-priv final void
setUseTrueDoubleBuffering(boolean useTrueDoubleBuffering)

public void
setWindowDecorationStyle(int
Constant identifying Window decorations to provide.
windowDecorationStyle
)

Sets the type of Window decorations (such as borders, widgets for closing a Window, title ...) the JRootPane should provide.

public void
updateUI()

Overrides javax.swing.JComponent.updateUI.

Resets the UI property to a value from the current look and feel.
Inherited from javax.swing.JComponent:
_paintImmediatelyaddAncestorListeneraddVetoableChangeListeneralwaysOnTopcheckIfChildObscuredBySiblingclientPropertyChangedcomponentInputMapChangedcomputeVisibleRectcomputeVisibleRectcompWriteObjectNotifycontainscreateToolTipdisabledndDonedropLocationForPointenablefirePropertyChangefirePropertyChangefirePropertyChangefireVetoableChangegetActionForKeyStrokegetActionMapgetActionMapgetAlignmentXgetAlignmentYgetAncestorListenersgetAutoscrollsgetBaselinegetBaselineResizeBehaviorgetBordergetBoundsgetClientPropertygetComponentGraphicsgetComponentPopupMenugetConditionForKeyStrokegetCreatedDoubleBuffergetDebugGraphicsOptionsgetDefaultLocalegetFontMetricsgetGraphicsgetGraphicsInvokedgetHeightgetInheritsPopupMenugetInputMapgetInputMapgetInputMapgetInputVerifiergetInsetsgetInsetsgetListenersgetLocationgetManagingFocusBackwardTraversalKeysgetManagingFocusForwardTraversalKeysgetMaximumSizegetMinimumSizegetNextFocusableComponentgetPopupLocationgetPreferredSizegetRegisteredKeyStrokesgetRootPanegetSizegetToolTipLocationgetToolTipTextgetToolTipTextgetTopLevelAncestorgetTransferHandlergetVerifyInputWhenFocusTargetgetVetoableChangeListenersgetVisibleRectgetWidthgetWriteObjCountergetXgetYgrabFocushideisDoubleBufferedisLightweightComponentisManagingFocusisOpaqueisPaintingisPaintingForPrintisPaintingOriginisPaintingTileisRequestFocusEnabledpaintpaintBorderpaintChildrenpaintComponentpaintForceDoubleBufferedpaintImmediatelypaintImmediatelypaintToOffscreenprintprintAllprintBorderprintChildrenprintComponentprocessComponentKeyEventprocessKeyBindingprocessKeyBindingsprocessKeyBindingsForAllComponentsprocessKeyEventprocessMouseEventprocessMouseMotionEventputClientPropertyrectangleIsObscuredregisterKeyboardActionregisterKeyboardActionremoveAncestorListenerremoveVetoableChangeListenerrepaintrepaintrequestDefaultFocusrequestFocusrequestFocusrequestFocusInWindowrequestFocusInWindowresetKeyboardActionsreshaperevalidatesafelyGetGraphicssafelyGetGraphicsscrollRectToVisiblesetActionMapsetAlignmentXsetAlignmentYsetAutoscrollssetBackgroundsetBordersetComponentPopupMenusetCreatedDoubleBuffersetDebugGraphicsOptionssetDefaultLocalesetDropLocationsetEnabledsetFocusTraversalKeyssetFontsetForegroundsetInheritsPopupMenusetInputMapsetInputVerifiersetMaximumSizesetMinimumSizesetNextFocusableComponentsetOpaquesetPaintingChildsetPreferredSizesetRequestFocusEnabledsetToolTipTextsetTransferHandlersetUIsetUIPropertysetVerifyInputWhenFocusTargetsetVisiblesetWriteObjCountershouldDebugGraphicssuperProcessMouseMotionEventunregisterKeyboardActionupdate

Field Detail

COLOR_CHOOSER_DIALOGback to summary
public static final int COLOR_CHOOSER_DIALOG

Constant used for the windowDecorationStyle property. Indicates that the JRootPane should provide decorations appropriate for a Dialog used to display a JColorChooser.

Since
1.4
contentPaneback to summary
protected Container contentPane

The content pane.

defaultButtonback to summary
protected JButton defaultButton

The button that gets activated when the pane has the focus and a UI-specific action like pressing the Enter key occurs.

ERROR_DIALOGback to summary
public static final int ERROR_DIALOG

Constant used for the windowDecorationStyle property. Indicates that the JRootPane should provide decorations appropriate for a Dialog used to display an error message.

Since
1.4
FILE_CHOOSER_DIALOGback to summary
public static final int FILE_CHOOSER_DIALOG

Constant used for the windowDecorationStyle property. Indicates that the JRootPane should provide decorations appropriate for a Dialog used to display a JFileChooser.

Since
1.4
FRAMEback to summary
public static final int FRAME

Constant used for the windowDecorationStyle property. Indicates that the JRootPane should provide decorations appropriate for a Frame.

Since
1.4
glassPaneback to summary
protected Component glassPane

The glass pane that overlays the menu bar and content pane, so it can intercept mouse movements and such.

IGNORE_DISABLE_TRUE_DOUBLE_BUFFERINGback to summary
private static final boolean IGNORE_DISABLE_TRUE_DOUBLE_BUFFERING

Whether or not we should ignore requests to disable true double buffering. Default is false.

Annotations
@SuppressWarnings:removal
INFORMATION_DIALOGback to summary
public static final int INFORMATION_DIALOG

Constant used for the windowDecorationStyle property. Indicates that the JRootPane should provide decorations appropriate for a Dialog used to display an informational message.

Since
1.4
layeredPaneback to summary
protected JLayeredPane layeredPane

The layered pane that manages the menu bar and content pane.

LOG_DISABLE_TRUE_DOUBLE_BUFFERINGback to summary
private static final boolean LOG_DISABLE_TRUE_DOUBLE_BUFFERING

Whether or not we should dump the stack when true double buffering is disabled. Default is false.

Annotations
@SuppressWarnings:removal
NONEback to summary
public static final int NONE

Constant used for the windowDecorationStyle property. Indicates that the JRootPane should not provide any sort of Window decorations.

Since
1.4
PLAIN_DIALOGback to summary
public static final int PLAIN_DIALOG

Constant used for the windowDecorationStyle property. Indicates that the JRootPane should provide decorations appropriate for a Dialog.

Since
1.4
QUESTION_DIALOGback to summary
public static final int QUESTION_DIALOG

Constant used for the windowDecorationStyle property. Indicates that the JRootPane should provide decorations appropriate for a Dialog used to present a question to the user.

Since
1.4
uiClassIDback to summary
private static final String uiClassID

Hides javax.swing.JComponent.uiClassID.

useTrueDoubleBufferingback to summary
pack-priv boolean useTrueDoubleBuffering

Whether or not true double buffering should be used. This is typically true, but may be set to false in special situations. For example, heavy weight popups (backed by a window) set this to false.

WARNING_DIALOGback to summary
public static final int WARNING_DIALOG

Constant used for the windowDecorationStyle property. Indicates that the JRootPane should provide decorations appropriate for a Dialog used to display a warning message.

Since
1.4
windowDecorationStyleback to summary
private int windowDecorationStyle

Constructor Detail

JRootPaneback to summary
public JRootPane()

Creates a JRootPane, setting up its glassPane, layeredPane, and contentPane.

Method Detail

addImplback to summary
protected void addImpl(Component comp, Object constraints, int index)

Overrides java.awt.Container.addImpl.

Overridden to enforce the position of the glass component as the zero child.

Parameters
comp:Component

the component to be enhanced

constraints:Object

the constraints to be respected

index:int

the index

addNotifyback to summary
public void addNotify()

Overrides javax.swing.JComponent.addNotify.

Doc from javax.swing.JComponent.addNotify.

Notifies this component that it now has a parent component. When this method is invoked, the chain of parent components is set up with KeyboardAction event listeners. This method is called by the toolkit internally and should not be called directly by programs.

createContentPaneback to summary
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.

Returns:Container

the default contentPane

createGlassPaneback to summary
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.

Returns:Component

the default glassPane

createLayeredPaneback to summary
protected JLayeredPane createLayeredPane()

Called by the constructor methods to create the default layeredPane. Bt default it creates a new JLayeredPane.

Returns:JLayeredPane

the default layeredPane

createRootLayoutback to summary
protected LayoutManager createRootLayout()

Called by the constructor methods to create the default layoutManager.

Returns:LayoutManager

the default layoutManager.

disableTrueDoubleBufferingback to summary
pack-priv final void disableTrueDoubleBuffering()
getAccessibleContextback to summary
public AccessibleContext getAccessibleContext()

Overrides java.awt.Component.getAccessibleContext.

Implements javax.accessibility.Accessible.getAccessibleContext.

Gets the AccessibleContext associated with this JRootPane. For root panes, the AccessibleContext takes the form of an AccessibleJRootPane. A new AccessibleJRootPane instance is created if necessary.

Returns:AccessibleContext

an AccessibleJRootPane that serves as the AccessibleContext of this JRootPane

getContentPaneback to summary
public Container getContentPane()

Returns the content pane -- the container that holds the components parented by the root pane.

Returns:Container

the Container that holds the component-contents

getDefaultButtonback to summary
public JButton getDefaultButton()

Returns the value of the defaultButton property.

Returns:JButton

the JButton which is currently the default button

See Also
setDefaultButton
getGlassPaneback to summary
public Component getGlassPane()

Returns the current glass pane for this JRootPane.

Returns:Component

the current glass pane

See Also
setGlassPane
getJMenuBarback to summary
public JMenuBar getJMenuBar()

Returns the menu bar from the layered pane.

Returns:JMenuBar

the JMenuBar used in the pane

getLayeredPaneback to summary
public JLayeredPane getLayeredPane()

Gets the layered pane used by the root pane. The layered pane typically holds a content pane and an optional JMenuBar.

Returns:JLayeredPane

the JLayeredPane currently in use

getMenuBarback to summary
public JMenuBar getMenuBar()

Deprecated

As of Swing version 1.0.3 replaced by getJMenuBar().

Returns the menu bar value.

Returns:JMenuBar

the JMenuBar used in the pane

Annotations
@Deprecated
getUIback to summary
public RootPaneUI getUI()

Overrides javax.swing.JComponent.getUI.

Returns the L&F object that renders this component.

Returns:RootPaneUI

LabelUI object

Since
1.3
getUIClassIDback to summary
public String getUIClassID()

Overrides javax.swing.JComponent.getUIClassID.

Returns a string that specifies the name of the L&F class that renders this component.

Returns:String

the string "RootPaneUI"

See Also
JComponent#getUIClassID, UIDefaults#getUI
getUseTrueDoubleBufferingback to summary
pack-priv final boolean getUseTrueDoubleBuffering()
getWindowDecorationStyleback to summary
public int getWindowDecorationStyle()

Returns a constant identifying the type of Window decorations the JRootPane is providing.

Returns:int

One of NONE, FRAME, PLAIN_DIALOG, INFORMATION_DIALOG, ERROR_DIALOG, COLOR_CHOOSER_DIALOG, FILE_CHOOSER_DIALOG, QUESTION_DIALOG or WARNING_DIALOG.

Since
1.4
See Also
setWindowDecorationStyle
isOptimizedDrawingEnabledback to summary
public boolean isOptimizedDrawingEnabled()

Overrides javax.swing.JComponent.isOptimizedDrawingEnabled.

The glassPane and contentPane have the same bounds, which means JRootPane does not tiles its children and this should return false. On the other hand, the glassPane is normally not visible, and so this can return true if the glassPane isn't visible. Therefore, the return value here depends upon the visibility of the glassPane.

Returns:boolean

true if this component's children don't overlap

isValidateRootback to summary
public boolean isValidateRoot()

Overrides javax.swing.JComponent.isValidateRoot.

If a descendant of this JRootPane calls revalidate, validate from here on down.

Deferred requests to layout a component and its descendents again. For example, calls to revalidate, are pushed upwards to either a JRootPane or a JScrollPane because both classes override isValidateRoot to return true.

Returns:boolean

true

Annotations
@Override
See Also
JComponent#isValidateRoot, java.awt.Container#isValidateRoot
paramStringback to summary
protected String paramString()

Overrides javax.swing.JComponent.paramString.

Returns a string representation of this JRootPane. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null.

Returns:String

a string representation of this JRootPane.

removeNotifyback to summary
public void removeNotify()

Overrides javax.swing.JComponent.removeNotify.

Doc from javax.swing.JComponent.removeNotify.

Notifies this component that it no longer has a parent component. When this method is invoked, any KeyboardActions set up in the chain of parent components are removed. This method is called by the toolkit internally and should not be called directly by programs.

setContentPaneback to summary
public void setContentPane(Container content)

Sets the content pane -- the container that holds the components parented by the root pane.

Swing's painting architecture requires an opaque JComponent in the containment hierarchy. This is typically provided by the content pane. If you replace the content pane it is recommended you replace it with an opaque JComponent.

Parameters
content:Container

the Container to use for component-contents

Exceptions
IllegalComponentStateException:
(a runtime exception) if the content pane parameter is null
setDefaultButtonback to summary
public void setDefaultButton(JButton defaultButton)

Sets the defaultButton property, which determines 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 Enter key) occurs in the root pane regardless of whether or not the button has keyboard focus (unless there is another component within the root pane which consumes the activation event, such as a JTextPane). For default activation to work, the button must be an enabled descendent of the root pane when activation occurs. To remove a default button from this root pane, set this property to null.

Parameters
defaultButton:JButton

the JButton which is to be the default button

Annotations
@BeanProperty
description:The button activated by default in this root pane
See Also
JButton#isDefaultButton
setDoubleBufferedback to summary
public void setDoubleBuffered(boolean aFlag)

Overrides javax.swing.JComponent.setDoubleBuffered.

Doc from javax.swing.JComponent.setDoubleBuffered.

Sets whether this component should use a buffer to paint. If set to true, all the drawing from this component will be done in an offscreen painting buffer. The offscreen painting buffer will the be copied onto the screen. If a Component is buffered and one of its ancestor is also buffered, the ancestor buffer will be used.

Parameters
aFlag:boolean

if true, set this component to be double buffered

Since
1.6
setGlassPaneback to summary
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.

The new glass pane's visibility is changed to match that of the current glass pane. An implication of this is that care must be taken when you want to replace the glass pane and make it visible. Either of the following will work:

  root.setGlassPane(newGlassPane);
  newGlassPane.setVisible(true);
or:
  root.getGlassPane().setVisible(true);
  root.setGlassPane(newGlassPane);
Parameters
glass:Component

the Component to use as the glass pane for this JRootPane

Exceptions
NullPointerException:
if the glass parameter is null
setJMenuBarback to summary
public void setJMenuBar(JMenuBar menu)

Adds or changes the menu bar used in the layered pane.

Parameters
menu:JMenuBar

the JMenuBar to add

setLayeredPaneback to summary
public void setLayeredPane(JLayeredPane layered)

Sets the layered pane for the root pane. The layered pane typically holds a content pane and an optional JMenuBar.

Parameters
layered:JLayeredPane

the JLayeredPane to use

Exceptions
IllegalComponentStateException:
(a runtime exception) if the layered pane parameter is null
setMenuBarback to summary
public void setMenuBar(JMenuBar menu)

Deprecated

As of Swing version 1.0.3 replaced by setJMenuBar(JMenuBar menu).

Specifies the menu bar value.

Parameters
menu:JMenuBar

the JMenuBar to add.

Annotations
@Deprecated
setUIback to summary
public void setUI(RootPaneUI ui)

Sets the L&F object that renders this component.

Parameters
ui:RootPaneUI

the LabelUI L&F object

Annotations
@BeanProperty
expert:true
hidden:true
visualUpdate:true
description:The UI object that implements the Component\'s LookAndFeel.
Since
1.3
See Also
UIDefaults#getUI
setUseTrueDoubleBufferingback to summary
pack-priv final void setUseTrueDoubleBuffering(boolean useTrueDoubleBuffering)
setWindowDecorationStyleback to summary
public void setWindowDecorationStyle(int windowDecorationStyle)

Sets the type of Window decorations (such as borders, widgets for closing a Window, title ...) the JRootPane should provide. The default is to provide no Window decorations (NONE).

This is only a hint, and some look and feels may not support this. This is a bound property.

Parameters
windowDecorationStyle:int

Constant identifying Window decorations to provide.

Annotations
@BeanProperty
expert:true
visualUpdate:true
enumerationValues:JRootPane.NONE, JRootPane.FRAME, JRootPane.PLAIN_DIALOG, JRootPane.INFORMATION_DIALOG, JRootPane.ERROR_DIALOG, JRootPane.COLOR_CHOOSER_DIALOG, JRootPane.FILE_CHOOSER_DIALOG, JRootPane.QUESTION_DIALOG, JRootPane.WARNING_DIALOG
description:Identifies the type of Window decorations to provide
Exceptions
IllegalArgumentException:
if style is not one of: NONE, FRAME, PLAIN_DIALOG, INFORMATION_DIALOG, ERROR_DIALOG, COLOR_CHOOSER_DIALOG, FILE_CHOOSER_DIALOG, QUESTION_DIALOG, or WARNING_DIALOG.
Since
1.4
See Also
JDialog#setDefaultLookAndFeelDecorated, JFrame#setDefaultLookAndFeelDecorated, LookAndFeel#getSupportsWindowDecorations
updateUIback to summary
public void updateUI()

Overrides javax.swing.JComponent.updateUI.

Resets the UI property to a value from the current look and feel.

See Also
JComponent#updateUI
javax.swing back to summary

protected Class JRootPane.AccessibleJRootPane

extends AccessibleJComponent
Class Inheritance
Annotations
@SuppressWarnings:serial

This class implements accessibility support for the JRootPane class. It provides an implementation of the Java Accessibility API appropriate to root pane user-interface elements.

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. As of 1.4, support for long term storage of all JavaBeans has been added to the java.beans package. Please see java.beans.XMLEncoder.

Field Summary

Inherited from javax.swing.JComponent.AccessibleJComponent:
accessibleFocusHandler

Constructor Summary

AccessConstructor and Description
protected
AccessibleJRootPane()

Constructs an AccessibleJRootPane.

Method Summary

Modifier and TypeMethod and Description
public Accessible

Returns:

the Accessible child of the object
getAccessibleChild
(int
zero-based index of child
i
)

Overrides javax.swing.JComponent.AccessibleJComponent.getAccessibleChild.

Returns the specified Accessible child of the object.
public int

Returns:

the number of accessible children of the object.
getAccessibleChildrenCount
()

Overrides javax.swing.JComponent.AccessibleJComponent.getAccessibleChildrenCount.

Returns the number of accessible children of the object.
public AccessibleRole

Returns:

an instance of AccessibleRole describing the role of the object
getAccessibleRole
()

Overrides javax.swing.JComponent.AccessibleJComponent.getAccessibleRole.

Get the role of this object.
Inherited from javax.swing.JComponent.AccessibleJComponent:
addPropertyChangeListenergetAccessibleDescriptiongetAccessibleExtendedComponentgetAccessibleKeyBindinggetAccessibleNamegetAccessibleStateSetgetBorderTitlegetTitledBorderTextgetToolTipTextremovePropertyChangeListener

Constructor Detail

AccessibleJRootPaneback to summary
protected AccessibleJRootPane()

Constructs an AccessibleJRootPane.

Method Detail

getAccessibleChildback to summary
public Accessible getAccessibleChild(int i)

Overrides javax.swing.JComponent.AccessibleJComponent.getAccessibleChild.

Returns the specified Accessible child of the object. The Accessible children of an Accessible object are zero-based, so the first child of an Accessible child is at index 0, the second child is at index 1, and so on.

Parameters
i:int

zero-based index of child

Returns:Accessible

the Accessible child of the object

See Also
getAccessibleChildrenCount
getAccessibleChildrenCountback to summary
public int getAccessibleChildrenCount()

Overrides javax.swing.JComponent.AccessibleJComponent.getAccessibleChildrenCount.

Returns the number of accessible children of the object.

Returns:int

the number of accessible children of the object.

getAccessibleRoleback to summary
public AccessibleRole getAccessibleRole()

Overrides javax.swing.JComponent.AccessibleJComponent.getAccessibleRole.

Get the role of this object.

Returns:AccessibleRole

an instance of AccessibleRole describing the role of the object

javax.swing back to summary

protected Class JRootPane.RootLayout

extends Object
implements LayoutManager2, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, java.awt.LayoutManager2, java.awt.LayoutManager
Annotations
@SuppressWarnings:serial

A custom layout manager that is responsible for the layout of layeredPane, glassPane, and menuBar.

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. As of 1.4, support for long term storage of all JavaBeans has been added to the java.beans package. Please see java.beans.XMLEncoder.

Constructor Summary

AccessConstructor and Description
protected
RootLayout()

Constructs a RootLayout.

Method Summary

Modifier and TypeMethod and Description
public void
addLayoutComponent(String
the string to be associated with the component
name
,
Component
the component to be added
comp
)

Implements java.awt.LayoutManager.addLayoutComponent.

If the layout manager uses a per-component string, adds the component comp to the layout, associating it with the string specified by name.
public void
addLayoutComponent(Component
the component to be added
comp
,
Object
where/how the component is added to the layout.
constraints
)

Implements java.awt.LayoutManager2.addLayoutComponent.

Adds the specified component to the layout, using the specified constraint object.
public float
getLayoutAlignmentX(Container
the target container
target
)

Implements java.awt.LayoutManager2.getLayoutAlignmentX.

Returns the alignment along the x axis.
public float
getLayoutAlignmentY(Container
the target container
target
)

Implements java.awt.LayoutManager2.getLayoutAlignmentY.

Returns the alignment along the y axis.
public void
invalidateLayout(Container
the target container
target
)

Implements java.awt.LayoutManager2.invalidateLayout.

Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.
public void
layoutContainer(Container
the Container for which this layout manager is being used
parent
)

Implements java.awt.LayoutManager.layoutContainer.

Instructs the layout manager to perform the layout for the specified container.
public Dimension

Returns:

a Dimension object containing the layout's maximum size
maximumLayoutSize
(Container
the Container for which this layout manager is being used
target
)

Implements java.awt.LayoutManager2.maximumLayoutSize.

Returns the maximum amount of space the layout can use.
public Dimension

Returns:

a Dimension object containing the layout's minimum size
minimumLayoutSize
(Container
the Container for which this layout manager is being used
parent
)

Implements java.awt.LayoutManager.minimumLayoutSize.

Returns the minimum amount of space the layout needs.
public Dimension

Returns:

a Dimension object containing the layout's preferred size
preferredLayoutSize
(Container
the Container for which this layout manager is being used
parent
)

Implements java.awt.LayoutManager.preferredLayoutSize.

Returns the amount of space the layout would like to have.
public void
removeLayoutComponent(Component
the component to be removed
comp
)

Implements java.awt.LayoutManager.removeLayoutComponent.

Removes the specified component from the layout.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

RootLayoutback to summary
protected RootLayout()

Constructs a RootLayout.

Method Detail

addLayoutComponentback to summary
public void addLayoutComponent(String name, Component comp)

Implements java.awt.LayoutManager.addLayoutComponent.

Doc from java.awt.LayoutManager.addLayoutComponent.

If the layout manager uses a per-component string, adds the component comp to the layout, associating it with the string specified by name.

Parameters
name:String

the string to be associated with the component

comp:Component

the component to be added

addLayoutComponentback to summary
public void addLayoutComponent(Component comp, Object constraints)

Implements java.awt.LayoutManager2.addLayoutComponent.

Doc from java.awt.LayoutManager2.addLayoutComponent.

Adds the specified component to the layout, using the specified constraint object.

Parameters
comp:Component

the component to be added

constraints:Object

where/how the component is added to the layout.

getLayoutAlignmentXback to summary
public float getLayoutAlignmentX(Container target)

Implements java.awt.LayoutManager2.getLayoutAlignmentX.

Doc from java.awt.LayoutManager2.getLayoutAlignmentX.

Returns the alignment along the x axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.

Parameters
target:Container

the target container

Returns:float

the x-axis alignment preference

getLayoutAlignmentYback to summary
public float getLayoutAlignmentY(Container target)

Implements java.awt.LayoutManager2.getLayoutAlignmentY.

Doc from java.awt.LayoutManager2.getLayoutAlignmentY.

Returns the alignment along the y axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.

Parameters
target:Container

the target container

Returns:float

the y-axis alignment preference

invalidateLayoutback to summary
public void invalidateLayout(Container target)

Implements java.awt.LayoutManager2.invalidateLayout.

Doc from java.awt.LayoutManager2.invalidateLayout.

Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.

Parameters
target:Container

the target container

layoutContainerback to summary
public void layoutContainer(Container parent)

Implements java.awt.LayoutManager.layoutContainer.

Instructs the layout manager to perform the layout for the specified container.

Parameters
parent:Container

the Container for which this layout manager is being used

maximumLayoutSizeback to summary
public Dimension maximumLayoutSize(Container target)

Implements java.awt.LayoutManager2.maximumLayoutSize.

Returns the maximum amount of space the layout can use.

Parameters
target:Container

the Container for which this layout manager is being used

Returns:Dimension

a Dimension object containing the layout's maximum size

minimumLayoutSizeback to summary
public Dimension minimumLayoutSize(Container parent)

Implements java.awt.LayoutManager.minimumLayoutSize.

Returns the minimum amount of space the layout needs.

Parameters
parent:Container

the Container for which this layout manager is being used

Returns:Dimension

a Dimension object containing the layout's minimum size

preferredLayoutSizeback to summary
public Dimension preferredLayoutSize(Container parent)

Implements java.awt.LayoutManager.preferredLayoutSize.

Returns the amount of space the layout would like to have.

Parameters
parent:Container

the Container for which this layout manager is being used

Returns:Dimension

a Dimension object containing the layout's preferred size

removeLayoutComponentback to summary
public void removeLayoutComponent(Component comp)

Implements java.awt.LayoutManager.removeLayoutComponent.

Doc from java.awt.LayoutManager.removeLayoutComponent.

Removes the specified component from the layout.

Parameters
comp:Component

the component to be removed