JRootPane (Java 2 Platform SE 5.0) (original) (raw)
javax.swing
Class JRootPane
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JRootPane
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible
public class JRootPane
extends JComponent
implements Accessible
A lightweight container used behind the scenes byJFrame
, 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 "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 JInternalPane
is also shown. All five of these JFC/Swing containers implement theRootPaneContainer
interface, and they all delegate their operations to a JRootPane
(shown with a little "handle" on top).
Note: The
JComponent
methodgetRootPane
can be used to obtain theJRootPane
that contains a given component.
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 theglassPane
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 aBorderLayout
manager. However, theJRootPane
uses a customLayoutManager
. So, when you want to change the layout manager for the components you added to aJRootPane
, 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 theJLayeredPane.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:
- The
glassPane
fills the entire viewable area of theJRootPane
(bounds - insets). - The
layeredPane
fills the entire viewable area of theJRootPane
. (bounds - insets) - The
menuBar
is positioned at the upper edge of thelayeredPane
. - The
contentPane
fills the entire viewable area, minus themenuBar
, if present. Any other views in theJRootPane
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 opaqueJComponent
to exist in the containment hieararchy 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: 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 JavaBeansTM has been added to the java.beans
package. Please see XMLEncoder.
See Also:
JLayeredPane, JMenuBar, JWindow, JFrame, JDialog, JApplet, JInternalFrame, JComponent, BoxLayout, Mixing Heavy and Light Components
Nested Class Summary | |
---|---|
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. |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
static 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. |
protected javax.swing.JRootPane.DefaultAction | defaultPressAction Deprecated. As of Java 2 platform v1.3. |
protected javax.swing.JRootPane.DefaultAction | defaultReleaseAction Deprecated. As of Java 2 platform v1.3. |
static int | ERROR_DIALOG Constant used for the windowDecorationStyle property. |
static int | FILE_CHOOSER_DIALOG Constant used for the windowDecorationStyle property. |
static 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. |
static int | INFORMATION_DIALOG Constant used for the windowDecorationStyle property. |
protected JLayeredPane | layeredPane The layered pane that manages the menu bar and content pane. |
protected JMenuBar | menuBar The menu bar. |
static int | NONE Constant used for the windowDecorationStyle property. |
static int | PLAIN_DIALOG Constant used for the windowDecorationStyle property. |
static int | QUESTION_DIALOG Constant used for the windowDecorationStyle property. |
static int | WARNING_DIALOG Constant used for the windowDecorationStyle property. |
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() Creates a JRootPane, setting up itsglassPane, layeredPane, and contentPane. |
Method Summary | |
---|---|
protected void | [addImpl](../../javax/swing/JRootPane.html#addImpl%28java.awt.Component, java.lang.Object, int%29)(Component comp,Object constraints, int index) Overridden to enforce the position of the glass component as the zero child. |
void | addNotify() Register ourselves with the SystemEventQueueUtils as a new root pane. |
protected Container | createContentPane() Called by the constructor methods to create the default contentPane. |
protected Component | createGlassPane() Called by the constructor methods to create the default glassPane. |
protected JLayeredPane | createLayeredPane() Called by the constructor methods to create the default layeredPane. |
protected LayoutManager | createRootLayout() Called by the constructor methods to create the default layoutManager. |
AccessibleContext | getAccessibleContext() Gets the AccessibleContext associated with thisJRootPane. |
Container | getContentPane() Returns the content pane -- the container that holds the components parented by the root pane. |
JButton | getDefaultButton() Returns the value of the defaultButton property. |
Component | getGlassPane() Returns the current glass pane for this JRootPane. |
JMenuBar | getJMenuBar() Returns the menu bar from the layered pane. |
JLayeredPane | getLayeredPane() Gets the layered pane used by the root pane. |
JMenuBar | getMenuBar() Deprecated. As of Swing version 1.0.3 replaced by getJMenubar(). |
RootPaneUI | getUI() Returns the L&F object that renders this component. |
String | getUIClassID() Returns a string that specifies the name of the L&F class that renders this component. |
int | getWindowDecorationStyle() Returns a constant identifying the type of Window decorations theJRootPane is providing. |
boolean | isOptimizedDrawingEnabled() The glassPane and contentPane have the same bounds, which means JRootPane does not tiles its children and this should return false. |
boolean | isValidateRoot() If a descendant of this JRootPane callsrevalidate, validate from here on down. |
protected String | paramString() Returns a string representation of this JRootPane. |
void | removeNotify() Unregister ourselves from SystemEventQueueUtils. |
void | setContentPane(Container content) Sets the content pane -- the container that holds the components parented by the root pane. |
void | setDefaultButton(JButton defaultButton) Sets the defaultButton property, which determines the current default button for this JRootPane. |
void | setGlassPane(Component glass) Sets a specified Component to be the glass pane for this root pane. |
void | setJMenuBar(JMenuBar menu) Adds or changes the menu bar used in the layered pane. |
void | setLayeredPane(JLayeredPane layered) Sets the layered pane for the root pane. |
void | setMenuBar(JMenuBar menu) Deprecated. As of Swing version 1.0.3 replaced by setJMenuBar(JMenuBar menu). |
void | setUI(RootPaneUI ui) Sets the L&F object that renders this component. |
void | setWindowDecorationStyle(int windowDecorationStyle) Sets the type of Window decorations (such as borders, widgets for closing a Window, title ...) the JRootPane should provide. |
void | updateUI() Resets the UI property to a value from the current look and feel. |
Methods inherited from class javax.swing.JComponent |
---|
addAncestorListener, addVetoableChangeListener, computeVisibleRect, [contains](../../javax/swing/JComponent.html#contains%28int, int%29), createToolTip, disable, enable, [firePropertyChange](../../javax/swing/JComponent.html#firePropertyChange%28java.lang.String, boolean, boolean%29), [firePropertyChange](../../javax/swing/JComponent.html#firePropertyChange%28java.lang.String, char, char%29), [firePropertyChange](../../javax/swing/JComponent.html#firePropertyChange%28java.lang.String, int, int%29), [fireVetoableChange](../../javax/swing/JComponent.html#fireVetoableChange%28java.lang.String, java.lang.Object, java.lang.Object%29), getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isPaintingTile, isRequestFocusEnabled, paint, paintBorder, paintChildren, paintComponent, [paintImmediately](../../javax/swing/JComponent.html#paintImmediately%28int, int, int, int%29), paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, [processKeyBinding](../../javax/swing/JComponent.html#processKeyBinding%28javax.swing.KeyStroke, java.awt.event.KeyEvent, int, boolean%29), processKeyEvent, processMouseEvent, processMouseMotionEvent, [putClientProperty](../../javax/swing/JComponent.html#putClientProperty%28java.lang.Object, java.lang.Object%29), [registerKeyboardAction](../../javax/swing/JComponent.html#registerKeyboardAction%28java.awt.event.ActionListener, javax.swing.KeyStroke, int%29), [registerKeyboardAction](../../javax/swing/JComponent.html#registerKeyboardAction%28java.awt.event.ActionListener, java.lang.String, javax.swing.KeyStroke, int%29), removeAncestorListener, removeVetoableChangeListener, [repaint](../../javax/swing/JComponent.html#repaint%28long, int, int, int, int%29), repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, [reshape](../../javax/swing/JComponent.html#reshape%28int, int, int, int%29), revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, [setFocusTraversalKeys](../../javax/swing/JComponent.html#setFocusTraversalKeys%28int, java.util.Set%29), setFont, setForeground, setInheritsPopupMenu, [setInputMap](../../javax/swing/JComponent.html#setInputMap%28int, javax.swing.InputMap%29), setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update |
Methods inherited from class java.awt.Container |
---|
add, [add](../../java/awt/Container.html#add%28java.awt.Component, int%29), [add](../../java/awt/Container.html#add%28java.awt.Component, java.lang.Object%29), [add](../../java/awt/Container.html#add%28java.awt.Component, java.lang.Object, int%29), [add](../../java/awt/Container.html#add%28java.lang.String, java.awt.Component%29), addContainerListener, addPropertyChangeListener, [addPropertyChangeListener](../../java/awt/Container.html#addPropertyChangeListener%28java.lang.String, java.beans.PropertyChangeListener%29), applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, [findComponentAt](../../java/awt/Container.html#findComponentAt%28int, int%29), findComponentAt, getComponent, [getComponentAt](../../java/awt/Container.html#getComponentAt%28int, int%29), getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, [list](../../java/awt/Container.html#list%28java.io.PrintStream, int%29), [list](../../java/awt/Container.html#list%28java.io.PrintWriter, int%29), [locate](../../java/awt/Container.html#locate%28int, int%29), minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, [setComponentZOrder](../../java/awt/Container.html#setComponentZOrder%28java.awt.Component, int%29), setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree |
Methods inherited from class java.awt.Component |
---|
[action](../../java/awt/Component.html#action%28java.awt.Event, java.lang.Object%29), add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, [checkImage](../../java/awt/Component.html#checkImage%28java.awt.Image, java.awt.image.ImageObserver%29), [checkImage](../../java/awt/Component.html#checkImage%28java.awt.Image, int, int, java.awt.image.ImageObserver%29), [coalesceEvents](../../java/awt/Component.html#coalesceEvents%28java.awt.AWTEvent, java.awt.AWTEvent%29), contains, createImage, [createImage](../../java/awt/Component.html#createImage%28int, int%29), [createVolatileImage](../../java/awt/Component.html#createVolatileImage%28int, int%29), [createVolatileImage](../../java/awt/Component.html#createVolatileImage%28int, int, java.awt.ImageCapabilities%29), disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, [firePropertyChange](../../java/awt/Component.html#firePropertyChange%28java.lang.String, byte, byte%29), [firePropertyChange](../../java/awt/Component.html#firePropertyChange%28java.lang.String, double, double%29), [firePropertyChange](../../java/awt/Component.html#firePropertyChange%28java.lang.String, float, float%29), [firePropertyChange](../../java/awt/Component.html#firePropertyChange%28java.lang.String, long, long%29), [firePropertyChange](../../java/awt/Component.html#firePropertyChange%28java.lang.String, java.lang.Object, java.lang.Object%29), [firePropertyChange](../../java/awt/Component.html#firePropertyChange%28java.lang.String, short, short%29), getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, [gotFocus](../../java/awt/Component.html#gotFocus%28java.awt.Event, java.lang.Object%29), handleEvent, hasFocus, hide, [imageUpdate](../../java/awt/Component.html#imageUpdate%28java.awt.Image, int, int, int, int, int%29), [inside](../../java/awt/Component.html#inside%28int, int%29), isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, [keyDown](../../java/awt/Component.html#keyDown%28java.awt.Event, int%29), [keyUp](../../java/awt/Component.html#keyUp%28java.awt.Event, int%29), list, list, list, location, [lostFocus](../../java/awt/Component.html#lostFocus%28java.awt.Event, java.lang.Object%29), [mouseDown](../../java/awt/Component.html#mouseDown%28java.awt.Event, int, int%29), [mouseDrag](../../java/awt/Component.html#mouseDrag%28java.awt.Event, int, int%29), [mouseEnter](../../java/awt/Component.html#mouseEnter%28java.awt.Event, int, int%29), [mouseExit](../../java/awt/Component.html#mouseExit%28java.awt.Event, int, int%29), [mouseMove](../../java/awt/Component.html#mouseMove%28java.awt.Event, int, int%29), [mouseUp](../../java/awt/Component.html#mouseUp%28java.awt.Event, int, int%29), [move](../../java/awt/Component.html#move%28int, int%29), nextFocus, paintAll, postEvent, [prepareImage](../../java/awt/Component.html#prepareImage%28java.awt.Image, java.awt.image.ImageObserver%29), [prepareImage](../../java/awt/Component.html#prepareImage%28java.awt.Image, int, int, java.awt.image.ImageObserver%29), processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, [removePropertyChangeListener](../../java/awt/Component.html#removePropertyChangeListener%28java.lang.String, java.beans.PropertyChangeListener%29), repaint, [repaint](../../java/awt/Component.html#repaint%28int, int, int, int%29), repaint, resize, [resize](../../java/awt/Component.html#resize%28int, int%29), [setBounds](../../java/awt/Component.html#setBounds%28int, int, int, int%29), setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, [setLocation](../../java/awt/Component.html#setLocation%28int, int%29), setLocation, setName, setSize, [setSize](../../java/awt/Component.html#setSize%28int, int%29), show, show, size, toString, transferFocus, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, [wait](../../java/lang/Object.html#wait%28long, int%29) |
Field Detail |
---|
NONE
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
See Also:
FRAME
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
See Also:
PLAIN_DIALOG
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
See Also:
INFORMATION_DIALOG
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
See Also:
ERROR_DIALOG
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
See Also:
COLOR_CHOOSER_DIALOG
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
See Also:
FILE_CHOOSER_DIALOG
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
See Also:
QUESTION_DIALOG
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
See Also:
WARNING_DIALOG
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
See Also:
menuBar
protected JMenuBar menuBar
The menu bar.
contentPane
protected Container contentPane
The content pane.
layeredPane
protected JLayeredPane layeredPane
The layered pane that manages the menu bar and content pane.
glassPane
protected Component glassPane
The glass pane that overlays the menu bar and content pane, so it can intercept mouse movements and such.
defaultButton
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.
defaultPressAction
@Deprecated protected javax.swing.JRootPane.DefaultAction defaultPressAction
Deprecated. As of Java 2 platform v1.3.
As of Java 2 platform v1.3 this unusable field is no longer used. To override the default button you should replace the Action
in the JRootPane
's ActionMap
. Please refer to the key bindings specification for further details.
See Also:
defaultReleaseAction
@Deprecated protected javax.swing.JRootPane.DefaultAction defaultReleaseAction
Deprecated. As of Java 2 platform v1.3.
As of Java 2 platform v1.3 this unusable field is no longer used. To override the default button you should replace the Action
in the JRootPane
's ActionMap
. Please refer to the key bindings specification for further details.
See Also:
Constructor Detail |
---|
JRootPane
public JRootPane()
Creates a JRootPane
, setting up itsglassPane
, layeredPane
, and contentPane
.
Method Detail |
---|
getWindowDecorationStyle
public int getWindowDecorationStyle()
Returns a constant identifying the type of Window decorations theJRootPane
is providing.
Returns:
One of NONE
, FRAME
,PLAIN_DIALOG
, INFORMATION_DIALOG
,ERROR_DIALOG
, COLOR_CHOOSER_DIALOG
,FILE_CHOOSER_DIALOG
, QUESTION_DIALOG
orWARNING_DIALOG
.
Since:
1.4
See Also:
setWindowDecorationStyle
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
- Constant identifying Window decorations to provide.
Throws:
[IllegalArgumentException](../../java/lang/IllegalArgumentException.html "class in java.lang")
- if style
is not one of: NONE
, FRAME
,PLAIN_DIALOG
, INFORMATION_DIALOG
,ERROR_DIALOG
, COLOR_CHOOSER_DIALOG
,FILE_CHOOSER_DIALOG
, QUESTION_DIALOG
, orWARNING_DIALOG
.
Since:
1.4
See Also:
JDialog.setDefaultLookAndFeelDecorated(boolean), JFrame.setDefaultLookAndFeelDecorated(boolean), LookAndFeel.getSupportsWindowDecorations()
getUI
public RootPaneUI getUI()
Returns the L&F object that renders this component.
Returns:
LabelUI
object
Since:
1.3
setUI
public void setUI(RootPaneUI ui)
Sets the L&F object that renders this component.
Parameters:
ui
- the LabelUI
L&F object
Since:
1.3
See Also:
UIDefaults.getUI(javax.swing.JComponent)
updateUI
public void updateUI()
Resets the UI property to a value from the current look and feel.
Overrides:
[updateUI](../../javax/swing/JComponent.html#updateUI%28%29)
in class [JComponent](../../javax/swing/JComponent.html "class in javax.swing")
See Also:
getUIClassID
public String getUIClassID()
Returns a string that specifies the name of the L&F class that renders this component.
Overrides:
[getUIClassID](../../javax/swing/JComponent.html#getUIClassID%28%29)
in class [JComponent](../../javax/swing/JComponent.html "class in javax.swing")
Returns:
the string "RootPaneUI"
See Also:
JComponent.getUIClassID(), UIDefaults.getUI(javax.swing.JComponent)
createLayeredPane
protected JLayeredPane createLayeredPane()
Called by the constructor methods to create the default layeredPane
. Bt default it creates a new JLayeredPane
.
Returns:
the default layeredPane
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
.
Returns:
the default contentPane
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.
Returns:
the default glassPane
createRootLayout
protected LayoutManager createRootLayout()
Called by the constructor methods to create the default layoutManager
.
Returns:
the default layoutManager
.
setJMenuBar
public void setJMenuBar(JMenuBar menu)
Adds or changes the menu bar used in the layered pane.
Parameters:
menu
- the JMenuBar
to add
setMenuBar
@Deprecated 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
- the JMenuBar
to add.
getJMenuBar
public JMenuBar getJMenuBar()
Returns the menu bar from the layered pane.
Returns:
the JMenuBar
used in the pane
getMenuBar
@Deprecated public JMenuBar getMenuBar()
Deprecated. As of Swing version 1.0.3 replaced by getJMenubar()
.
Returns the menu bar value.
Returns:
the JMenuBar
used in the pane
setContentPane
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 hiearchy. 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
- the Container
to use for component-contents
Throws:
[IllegalComponentStateException](../../java/awt/IllegalComponentStateException.html "class in java.awt")
- (a runtime exception) if the content pane parameter is null
getContentPane
public Container getContentPane()
Returns the content pane -- the container that holds the components parented by the root pane.
Returns:
the Container
that holds the component-contents
setLayeredPane
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
- the JLayeredPane
to use
Throws:
[IllegalComponentStateException](../../java/awt/IllegalComponentStateException.html "class in java.awt")
- (a runtime exception) if the layered pane parameter is null
getLayeredPane
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:
the JLayeredPane
currently in use
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 JInternalFrame
s' 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
Throws:
[NullPointerException](../../java/lang/NullPointerException.html "class in java.lang")
- if the glass
parameter isnull
getGlassPane
public Component getGlassPane()
Returns the current glass pane for this JRootPane
.
Returns:
the current glass pane
See Also:
setGlassPane(java.awt.Component)
isValidateRoot
public boolean isValidateRoot()
If a descendant of this JRootPane
callsrevalidate
, 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.
Overrides:
[isValidateRoot](../../javax/swing/JComponent.html#isValidateRoot%28%29)
in class [JComponent](../../javax/swing/JComponent.html "class in javax.swing")
Returns:
true
See Also:
isOptimizedDrawingEnabled
public boolean 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 theglassPane
isn't visible. Therefore, the return value here depends upon the visiblity of theglassPane
.
Overrides:
[isOptimizedDrawingEnabled](../../javax/swing/JComponent.html#isOptimizedDrawingEnabled%28%29)
in class [JComponent](../../javax/swing/JComponent.html "class in javax.swing")
Returns:
true if this component's children don't overlap
addNotify
public void addNotify()
Register ourselves with the SystemEventQueueUtils
as a new root pane.
Overrides:
[addNotify](../../javax/swing/JComponent.html#addNotify%28%29)
in class [JComponent](../../javax/swing/JComponent.html "class in javax.swing")
See Also:
[JComponent.registerKeyboardAction(java.awt.event.ActionListener, java.lang.String, javax.swing.KeyStroke, int)](../../javax/swing/JComponent.html#registerKeyboardAction%28java.awt.event.ActionListener, java.lang.String, javax.swing.KeyStroke, int%29)
removeNotify
public void removeNotify()
Unregister ourselves from SystemEventQueueUtils
.
Overrides:
[removeNotify](../../javax/swing/JComponent.html#removeNotify%28%29)
in class [JComponent](../../javax/swing/JComponent.html "class in javax.swing")
See Also:
setDefaultButton
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
- the JButton
which is to be the default button
See Also:
getDefaultButton
public JButton getDefaultButton()
Returns the value of the defaultButton
property.
Returns:
the JButton
which is currently the default button
See Also:
setDefaultButton(javax.swing.JButton)
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](../../java/awt/Container.html#addImpl%28java.awt.Component, java.lang.Object, int%29)
in class [Container](../../java/awt/Container.html "class in java.awt")
Parameters:
comp
- the component to be enhanced
constraints
- the constraints to be respected
index
- the index
See Also:
Container.add(Component), [Container.add(Component, int)](../../java/awt/Container.html#add%28java.awt.Component, int%29), [Container.add(Component, java.lang.Object)](../../java/awt/Container.html#add%28java.awt.Component, java.lang.Object%29), LayoutManager, LayoutManager2
paramString
protected String 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
.
Overrides:
[paramString](../../javax/swing/JComponent.html#paramString%28%29)
in class [JComponent](../../javax/swing/JComponent.html "class in javax.swing")
Returns:
a string representation of this JRootPane
.
getAccessibleContext
public AccessibleContext getAccessibleContext()
Gets the AccessibleContext
associated with thisJRootPane
. For root panes, theAccessibleContext
takes the form of an AccessibleJRootPane
. A new AccessibleJRootPane
instance is created if necessary.
Specified by:
[getAccessibleContext](../../javax/accessibility/Accessible.html#getAccessibleContext%28%29)
in interface [Accessible](../../javax/accessibility/Accessible.html "interface in javax.accessibility")
Overrides:
[getAccessibleContext](../../javax/swing/JComponent.html#getAccessibleContext%28%29)
in class [JComponent](../../javax/swing/JComponent.html "class in javax.swing")
Returns:
an AccessibleJRootPane
that serves as the AccessibleContext
of this JRootPane
Submit a bug or feature
For further API reference and developer documentation, see Java 2 SDK SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 2004, 2010 Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.