javax.swing
public class: JRootPane [javadoc |
source]
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JRootPane
All Implemented Interfaces:
Accessible, HasGetTransferHandler, Serializable, MenuContainer, ImageObserver
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 "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.
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:
- The
glassPane fills the entire viewable
area of the JRootPane (bounds - insets).
- The
layeredPane fills the entire viewable area of the
JRootPane. (bounds - insets)
- The
menuBar is positioned at the upper edge of the
layeredPane.
- 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 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: 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 JavaBeansTM
has been added to the java.beans package.
Please see java.beans.XMLEncoder .
| Nested Class Summary: |
|---|
| static class | JRootPane.DefaultAction | |
| protected class | JRootPane.RootLayout | 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 JavaBeansTM
has been added to the java.beans package.
Please see {@link java.beans.XMLEncoder}. |
| protected class | JRootPane.AccessibleJRootPane | 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 JavaBeansTM
has been added to the java.beans package.
Please see {@link java.beans.XMLEncoder}. |
| Field Summary |
|---|
| public static final int | NONE | Constant used for the windowDecorationStyle property. Indicates that
the JRootPane should not provide any sort of
Window decorations. |
| public static final int | FRAME | Constant used for the windowDecorationStyle property. Indicates that
the JRootPane should provide decorations appropriate for
a Frame. |
| public static final int | PLAIN_DIALOG | Constant used for the windowDecorationStyle property. Indicates that
the JRootPane should provide decorations appropriate for
a 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. |
| 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. |
| 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. |
| 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. |
| 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. |
| 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. |
| protected JMenuBar | menuBar | The menu bar. |
| protected Container | contentPane | The content pane. |
| protected JLayeredPane | layeredPane | The layered pane that manages the menu bar and content pane. |
| protected Component | glassPane | The glass pane that overlays the menu bar and content pane,
so it can intercept mouse movements and such. |
| 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 JRootPane.DefaultAction | defaultPressAction | 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. |
| protected JRootPane.DefaultAction | defaultReleaseAction | 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. |
| 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. |
| Fields inherited from javax.swing.JComponent: |
|---|
| DEBUG_GRAPHICS_LOADED, ui, listenerList, paintingChild, WHEN_FOCUSED, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_IN_FOCUSED_WINDOW, UNDEFINED_CONDITION, TOOL_TIP_TEXT_KEY, focusController, accessibleContext |
| Fields inherited from java.awt.Container: |
|---|
| ncomponents, component, layoutMgr, containerListener, listeningChildren, listeningBoundsChildren, descendantsCount, INCLUDE_SELF, SEARCH_HEAVYWEIGHTS, modalComp, modalAppContext |
| Fields inherited from java.awt.Component: |
|---|
| TOP_ALIGNMENT, CENTER_ALIGNMENT, BOTTOM_ALIGNMENT, RIGHT_ALIGNMENT, LEFT_ALIGNMENT, treeLock, x, y, width, height, foreground, background, font, peerFont, cursor, locale, ignoreRepaint, visible, enabled, valid, dropTarget, popups, name, nameExplicitlySet, focusable, isFocusTraversableOverridden, focusTraversalKeys, focusTraversalKeysEnabled, minSize, prefSize, newEventsOnly, eventMask, changeSupport, isPacked, componentSerializedDataVersion, accessibleContext, componentListener, focusListener, keyListener, mouseListener, mouseMotionListener, mouseWheelListener, inputMethodListener, hierarchyListener, hierarchyBoundsListener, parent, peer, orientation, graphicsConfig, bufferStrategy |
| Method from javax.swing.JRootPane Summary: |
|---|
|
addImpl, addNotify, createContentPane, createGlassPane, createLayeredPane, createRootLayout, disableTrueDoubleBuffering, getAccessibleContext, getContentPane, getDefaultButton, getGlassPane, getJMenuBar, getLayeredPane, getMenuBar, getUI, getUIClassID, getUseTrueDoubleBuffering, getWindowDecorationStyle, isOptimizedDrawingEnabled, isValidateRoot, paramString, removeNotify, setContentPane, setDefaultButton, setDoubleBuffered, setGlassPane, setJMenuBar, setLayeredPane, setMenuBar, setUI, setUseTrueDoubleBuffering, setWindowDecorationStyle, updateUI |
| Methods from javax.swing.JComponent: |
|---|
|
_paintImmediately, addAncestorListener, addNotify, addVetoableChangeListener, alwaysOnTop, checkIfChildObscuredBySibling, clientPropertyChanged, compWriteObjectNotify, componentInputMapChanged, computeVisibleRect, computeVisibleRect, contains, createToolTip, disable, dndDone, dropLocationForPoint, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getCreatedDoubleBuffer, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getGraphicsInvoked, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getManagingFocusBackwardTraversalKeys, getManagingFocusForwardTraversalKeys, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getWriteObjCounter, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPainting, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintForceDoubleBuffered, paintImmediately, paintImmediately, paintToOffscreen, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyBindings, processKeyBindingsForAllComponents, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, rectangleIsObscured, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, safelyGetGraphics, safelyGetGraphics, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setCreatedDoubleBuffer, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setDropLocation, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPaintingChild, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setUIProperty, setVerifyInputWhenFocusTarget, setVisible, setWriteObjCounter, shouldDebugGraphics, superProcessMouseMotionEvent, unregisterKeyboardAction, update, updateUI |
| Methods from java.awt.Container: |
|---|
|
add, add, add, add, add, addContainerListener, addImpl, addNotify, addPropertyChangeListener, addPropertyChangeListener, adjustDecendantsOnParent, adjustDescendants, adjustListeningChildren, applyComponentOrientation, areFocusTraversalKeysSet, canContainFocusOwner, checkGD, clearCurrentFocusCycleRootOnHide, clearMostRecentFocusOwnerOnHide, containsFocus, countComponents, countHierarchyMembers, createChildHierarchyEvents, createHierarchyEvents, decreaseComponentCount, deliverEvent, dispatchEventImpl, dispatchEventToSelf, doLayout, eventEnabled, findComponentAt, findComponentAt, findComponentAt, findComponentAtImpl, getAccessibleAt, getAccessibleChild, getAccessibleChildrenCount, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponentZOrder, getComponents, getComponents_NoClientCode, getContainerListeners, getDropTargetEventTarget, getFocusTraversalKeys, getFocusTraversalPolicy, getHeavyweightContainer, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMouseEventTarget, getMousePosition, getPreferredSize, getTraversalRoot, increaseComponentCount, initializeFocusTraversalKeys, insets, invalidate, invalidateTree, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, isSameOrAncestorOf, layout, lightweightPaint, lightweightPrint, list, list, locate, minimumSize, mixOnHiding, mixOnReshaping, mixOnShowing, mixOnZOrderChanging, numListening, paint, paintComponents, paintHeavyweightComponents, paramString, postProcessKeyEvent, postsOldMouseEvents, preProcessKeyEvent, preferredSize, print, printComponents, printHeavyweightComponents, processContainerEvent, processEvent, proxyEnableEvents, recursiveApplyCurrentShape, recursiveApplyCurrentShape, recursiveApplyCurrentShape, recursiveSubtractAndApplyShape, recursiveSubtractAndApplyShape, recursiveSubtractAndApplyShape, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusDownCycle, update, validate, validateTree |
| Methods from java.awt.Component: |
|---|
|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, dispatchEventImpl, doLayout, enable, enable, enableEvents, enableInputMethods, eventTypeEnabled, findNextFocusComponent, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, generateName, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getGraphicsConfigurationImpl, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFocusable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFocusable, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setPeer, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, translateEvent, update, validate |
| Methods from java.lang.Object: |
|---|
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method from javax.swing.JRootPane Detail: |
protected void addImpl(Component comp,
Object constraints,
int index) {
super.addImpl(comp, constraints, index);
/// We are making sure the glassPane is on top.
if(glassPane != null
&& glassPane.getParent() == this
&& getComponent(0) != glassPane) {
add(glassPane, 0);
}
}
Overridden to enforce the position of the glass component as
the zero child. |
public void addNotify() {
super.addNotify();
enableEvents(AWTEvent.KEY_EVENT_MASK);
}
|
protected Container createContentPane() {
JComponent c = new JPanel();
c.setName(this.getName()+".contentPane");
c.setLayout(new BorderLayout() {
/* This BorderLayout subclass maps a null constraint to CENTER.
* Although the reference BorderLayout also does this, some VMs
* throw an IllegalArgumentException.
*/
public void addLayoutComponent(Component comp, Object constraints) {
if (constraints == null) {
constraints = BorderLayout.CENTER;
}
super.addLayoutComponent(comp, constraints);
}
});
return c;
}
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. |
protected Component createGlassPane() {
JComponent c = new JPanel();
c.setName(this.getName()+".glassPane");
c.setVisible(false);
((JPanel)c).setOpaque(false);
return c;
}
Called by the constructor methods to create the default
glassPane.
By default this method creates a new JComponent
with visibility set to false. |
protected JLayeredPane createLayeredPane() {
JLayeredPane p = new JLayeredPane();
p.setName(this.getName()+".layeredPane");
return p;
}
Called by the constructor methods to create the default
layeredPane.
Bt default it creates a new JLayeredPane. |
protected LayoutManager createRootLayout() {
return new RootLayout();
}
Called by the constructor methods to create the default
layoutManager. |
final void disableTrueDoubleBuffering() {
if (useTrueDoubleBuffering) {
if (!IGNORE_DISABLE_TRUE_DOUBLE_BUFFERING) {
if (LOG_DISABLE_TRUE_DOUBLE_BUFFERING) {
System.out.println("Disabling true double buffering for " +
this);
Thread.dumpStack();
}
useTrueDoubleBuffering = false;
RepaintManager.currentManager(this).
doubleBufferingChanged(this);
}
}
}
|
public AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
accessibleContext = new AccessibleJRootPane();
}
return accessibleContext;
}
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. |
public Container getContentPane() {
return contentPane;
}
Returns the content pane -- the container that holds the components
parented by the root pane. |
public JButton getDefaultButton() {
return defaultButton;
}
Returns the value of the defaultButton property. |
public Component getGlassPane() {
return glassPane;
}
Returns the current glass pane for this JRootPane. |
public JMenuBar getJMenuBar() {
return menuBar;
}
Returns the menu bar from the layered pane. |
public JLayeredPane getLayeredPane() {
return layeredPane;
}
Gets the layered pane used by the root pane. The layered pane
typically holds a content pane and an optional JMenuBar. |
public JMenuBar getMenuBar() {
return menuBar;
} Deprecated! As - of Swing version 1.0.3
replaced by getJMenuBar().
Returns the menu bar value. |
public RootPaneUI getUI() {
return (RootPaneUI)ui;
}
Returns the L&F object that renders this component. |
public String getUIClassID() {
return uiClassID;
}
Returns a string that specifies the name of the L&F class
that renders this component. |
final boolean getUseTrueDoubleBuffering() {
return useTrueDoubleBuffering;
}
|
public int getWindowDecorationStyle() {
return windowDecorationStyle;
}
Returns a constant identifying the type of Window decorations the
JRootPane is providing. |
public boolean isOptimizedDrawingEnabled() {
return !glassPane.isVisible();
}
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 visiblity of the
glassPane. |
public boolean isValidateRoot() {
return true;
}
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. |
protected String paramString() {
return super.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. |
public void removeNotify() {
super.removeNotify();
}
|
public void setContentPane(Container content) {
if(content == null)
throw new IllegalComponentStateException("contentPane cannot be set to null.");
if(contentPane != null && contentPane.getParent() == layeredPane)
layeredPane.remove(contentPane);
contentPane = content;
layeredPane.add(contentPane, JLayeredPane.FRAME_CONTENT_LAYER);
}
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. |
public void setDefaultButton(JButton defaultButton) {
JButton oldDefault = this.defaultButton;
if (oldDefault != defaultButton) {
this.defaultButton = defaultButton;
if (oldDefault != null) {
oldDefault.repaint();
}
if (defaultButton != null) {
defaultButton.repaint();
}
}
firePropertyChange("defaultButton", oldDefault, 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. |
public void setDoubleBuffered(boolean aFlag) {
if (isDoubleBuffered() != aFlag) {
super.setDoubleBuffered(aFlag);
RepaintManager.currentManager(this).doubleBufferingChanged(this);
}
}
|
public void setGlassPane(Component glass) {
if (glass == null) {
throw new NullPointerException("glassPane cannot be set to null.");
}
boolean visible = false;
if (glassPane != null && glassPane.getParent() == this) {
this.remove(glassPane);
visible = glassPane.isVisible();
}
glass.setVisible(visible);
glassPane = glass;
this.add(glassPane, 0);
if (visible) {
repaint();
}
}
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);
|
public void setJMenuBar(JMenuBar menu) {
if(menuBar != null && menuBar.getParent() == layeredPane)
layeredPane.remove(menuBar);
menuBar = menu;
if(menuBar != null)
layeredPane.add(menuBar, JLayeredPane.FRAME_CONTENT_LAYER);
}
Adds or changes the menu bar used in the layered pane. |
public void setLayeredPane(JLayeredPane layered) {
if(layered == null)
throw new IllegalComponentStateException("layeredPane cannot be set to null.");
if(layeredPane != null && layeredPane.getParent() == this)
this.remove(layeredPane);
layeredPane = layered;
this.add(layeredPane, -1);
}
Sets the layered pane for the root pane. The layered pane
typically holds a content pane and an optional JMenuBar. |
public void setMenuBar(JMenuBar menu) {
if(menuBar != null && menuBar.getParent() == layeredPane)
layeredPane.remove(menuBar);
menuBar = menu;
if(menuBar != null)
layeredPane.add(menuBar, JLayeredPane.FRAME_CONTENT_LAYER);
} Deprecated! As - of Swing version 1.0.3
replaced by setJMenuBar(JMenuBar menu).
Specifies the menu bar value. |
public void setUI(RootPaneUI ui) {
super.setUI(ui);
}
Sets the L&F object that renders this component. |
final void setUseTrueDoubleBuffering(boolean useTrueDoubleBuffering) {
this.useTrueDoubleBuffering = useTrueDoubleBuffering;
}
|
public void setWindowDecorationStyle(int windowDecorationStyle) {
if (windowDecorationStyle < 0 ||
windowDecorationStyle > WARNING_DIALOG) {
throw new IllegalArgumentException("Invalid decoration style");
}
int oldWindowDecorationStyle = getWindowDecorationStyle();
this.windowDecorationStyle = windowDecorationStyle;
firePropertyChange("windowDecorationStyle",
oldWindowDecorationStyle,
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. |
public void updateUI() {
setUI((RootPaneUI)UIManager.getUI(this));
}
Resets the UI property to a value from the current look and feel. |