Liking cljdoc? Tell your friends :D

javax.swing.JRootPane

A lightweight container used behind the scenes by JFrame, JDialog, JWindow, JApplet, and JInternalFrame. For task-oriented information on functionality provided by root panes see How to Use Root Panes, a section in The Java Tutorial.

The following image shows the relationships between the classes that use root panes.

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 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 XMLEncoder.

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 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 XMLEncoder.
raw docstring

*-color-chooser-dialogclj

Static Constant.

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

type: int

Static Constant.

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

type: int
raw docstring

*-error-dialogclj

Static Constant.

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

type: int

Static Constant.

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

type: int
raw docstring

*-file-chooser-dialogclj

Static Constant.

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

type: int

Static Constant.

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

type: int
raw docstring

*-frameclj

Static Constant.

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

type: int

Static Constant.

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

type: int
raw docstring

*-information-dialogclj

Static Constant.

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

type: int

Static Constant.

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

type: int
raw docstring

*-noneclj

Static Constant.

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

type: int

Static Constant.

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

type: int
raw docstring

*-plain-dialogclj

Static Constant.

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

type: int

Static Constant.

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

type: int
raw docstring

*-question-dialogclj

Static Constant.

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.

type: int

Static Constant.

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.

type: int
raw docstring

*-warning-dialogclj

Static Constant.

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

type: int

Static Constant.

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

type: int
raw docstring

->j-root-paneclj

(->j-root-pane)

Constructor.

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

Constructor.

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

add-notifyclj

(add-notify this)

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.

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.
raw docstring

get-accessible-contextclj

(get-accessible-context this)

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: an AccessibleJRootPane that serves as the AccessibleContext of this JRootPane - javax.accessibility.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.

returns: an AccessibleJRootPane that serves as the
         AccessibleContext of this JRootPane - `javax.accessibility.AccessibleContext`
raw docstring

get-content-paneclj

(get-content-pane this)

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

returns: the Container that holds the component-contents - java.awt.Container

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

returns: the Container that holds the component-contents - `java.awt.Container`
raw docstring

get-default-buttonclj

(get-default-button this)

Returns the value of the defaultButton property.

returns: the JButton which is currently the default button - javax.swing.JButton

Returns the value of the defaultButton property.

returns: the JButton which is currently the default button - `javax.swing.JButton`
raw docstring

get-glass-paneclj

(get-glass-pane this)

Returns the current glass pane for this JRootPane.

returns: the current glass pane - java.awt.Component

Returns the current glass pane for this JRootPane.

returns: the current glass pane - `java.awt.Component`
raw docstring

get-j-menu-barclj

(get-j-menu-bar this)

Returns the menu bar from the layered pane.

returns: the JMenuBar used in the pane - javax.swing.JMenuBar

Returns the menu bar from the layered pane.

returns: the JMenuBar used in the pane - `javax.swing.JMenuBar`
raw docstring

get-layered-paneclj

(get-layered-pane this)

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 - javax.swing.JLayeredPane

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 - `javax.swing.JLayeredPane`
raw docstring

get-menu-barclj

(get-menu-bar this)

Deprecated. As of Swing version 1.0.3 replaced by getJMenuBar().

returns: the JMenuBar used in the pane - javax.swing.JMenuBar

Deprecated. As of Swing version 1.0.3
  replaced by getJMenuBar().

returns: the JMenuBar used in the pane - `javax.swing.JMenuBar`
raw docstring

get-uiclj

(get-ui this)

Returns the L&F object that renders this component.

returns: LabelUI object - javax.swing.plaf.RootPaneUI

Returns the L&F object that renders this component.

returns: LabelUI object - `javax.swing.plaf.RootPaneUI`
raw docstring

get-ui-class-idclj

(get-ui-class-id this)

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

returns: the string "RootPaneUI" - java.lang.String

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

returns: the string "RootPaneUI" - `java.lang.String`
raw docstring

get-window-decoration-styleclj

(get-window-decoration-style this)

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

returns: One of NONE, FRAME, PLAIN_DIALOG, INFORMATION_DIALOG, ERROR_DIALOG, COLOR_CHOOSER_DIALOG, FILE_CHOOSER_DIALOG, QUESTION_DIALOG or WARNING_DIALOG. - int

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

returns: One of NONE, FRAME,
        PLAIN_DIALOG, INFORMATION_DIALOG,
        ERROR_DIALOG, COLOR_CHOOSER_DIALOG,
        FILE_CHOOSER_DIALOG, QUESTION_DIALOG or
        WARNING_DIALOG. - `int`
raw docstring

optimized-drawing-enabled?clj

(optimized-drawing-enabled? this)

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: true if this component's children don't overlap - boolean

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: true if this component's children don't overlap - `boolean`
raw docstring

remove-notifyclj

(remove-notify this)

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

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

set-content-paneclj

(set-content-pane this 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.

content - the Container to use for component-contents - java.awt.Container

throws: java.awt.IllegalComponentStateException - (a runtime exception) if the content pane parameter is null

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.

content - the Container to use for component-contents - `java.awt.Container`

throws: java.awt.IllegalComponentStateException - (a runtime exception) if the content pane parameter is null
raw docstring

set-default-buttonclj

(set-default-button this default-button)

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.

default-button - the JButton which is to be the default button - javax.swing.JButton

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.

default-button - the JButton which is to be the default button - `javax.swing.JButton`
raw docstring

set-double-bufferedclj

(set-double-buffered this a-flag)

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.

a-flag - if true, set this component to be double buffered - boolean

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.

a-flag - if true, set this component to be double buffered - `boolean`
raw docstring

set-glass-paneclj

(set-glass-pane this 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);

glass - the Component to use as the glass pane for this JRootPane - java.awt.Component

throws: java.lang.NullPointerException - if the glass parameter is null

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);

glass - the Component to use as the glass pane for this JRootPane - `java.awt.Component`

throws: java.lang.NullPointerException - if the glass parameter is null
raw docstring

set-j-menu-barclj

(set-j-menu-bar this menu)

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

menu - the JMenuBar to add - javax.swing.JMenuBar

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

menu - the JMenuBar to add - `javax.swing.JMenuBar`
raw docstring

set-layered-paneclj

(set-layered-pane this layered)

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

layered - the JLayeredPane to use - javax.swing.JLayeredPane

throws: java.awt.IllegalComponentStateException - (a runtime exception) if the layered pane parameter is null

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

layered - the JLayeredPane to use - `javax.swing.JLayeredPane`

throws: java.awt.IllegalComponentStateException - (a runtime exception) if the layered pane parameter is null
raw docstring

set-menu-barclj

(set-menu-bar this menu)

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

menu - the JMenuBar to add. - javax.swing.JMenuBar

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

menu - the JMenuBar to add. - `javax.swing.JMenuBar`
raw docstring

set-uiclj

(set-ui this ui)

Sets the L&F object that renders this component.

ui - the LabelUI L&F object - javax.swing.plaf.RootPaneUI

Sets the L&F object that renders this component.

ui - the LabelUI L&F object - `javax.swing.plaf.RootPaneUI`
raw docstring

set-window-decoration-styleclj

(set-window-decoration-style this window-decoration-style)

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.

window-decoration-style - Constant identifying Window decorations to provide. - int

throws: java.lang.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.

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.

window-decoration-style - Constant identifying Window decorations to provide. - `int`

throws: java.lang.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.
raw docstring

update-uiclj

(update-ui this)

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

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

validate-root?clj

(validate-root? this)

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: true - boolean

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: true - `boolean`
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close