APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javax.swing

public Class JWindow

extends Window
implements Accessible, RootPaneContainer, HasGetTransferHandler
Class Inheritance
All Implemented Interfaces
javax.swing.TransferHandler.HasGetTransferHandler, javax.swing.RootPaneContainer, javax.accessibility.Accessible
Known Direct Subclasses
javax.swing.Popup.HeavyWeightWindow
Annotations
@JavaBean
defaultProperty:accessibleContext
description:A toplevel window which has no system border or controls.
@SwingContainer
delegate:getContentPane
@SuppressWarnings:serial
Imports
java.awt.*, java.awt.event.*, java.beans.JavaBean, .BeanProperty, javax.accessibility.*

A JWindow is a container that can be displayed anywhere on the user's desktop. It does not have the title bar, window-management buttons, or other trimmings associated with a JFrame, but it is still a "first-class citizen" of the user's desktop, and can exist anywhere on it.

The JWindow component contains a JRootPane as its only child. The contentPane should be the parent of any children of the JWindow. As a convenience, the add, remove, and setLayout methods of this class are overridden, so that they delegate calls to the corresponding methods of the ContentPane. For example, you can add a child component to a window as follows:

      window.add(child);
And the child will be added to the contentPane. The contentPane will always be non-null. Attempting to set it to null will cause the JWindow to throw an exception. The default contentPane will have a BorderLayout manager set on it. Refer to javax.swing.RootPaneContainer for details on adding, removing and setting the LayoutManager of a JWindow.

Please see the JRootPane documentation for a complete description of the contentPane, glassPane, and layeredPane components.

In a multi-screen environment, you can create a JWindow on a different screen device. See java.awt.Window for more information.

Warning

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

Warning

Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeans has been added to the java.beans package. Please see java.beans.XMLEncoder.

Author
David Kloba
Since
1.2
See Also
JRootPane

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected class
JWindow.AccessibleJWindow

This class implements accessibility support for the JWindow class.

Field Summary

Modifier and TypeField and Description
protected AccessibleContext
accessibleContext

Hides java.awt.Component.accessibleContext.

The accessible context property.
protected JRootPane
rootPane

The JRootPane instance that manages the contentPane and optional menuBar for this frame, as well as the glassPane.

protected boolean
rootPaneCheckingEnabled

If true then calls to add and setLayout will be forwarded to the contentPane.

private TransferHandler
transferHandler

The TransferHandler for this window.

Constructor Summary

AccessConstructor and Description
public
JWindow()

Creates a window with no specified owner.

public
JWindow(GraphicsConfiguration
the GraphicsConfiguration that is used to construct the new window with; if gc is null, the system default GraphicsConfiguration is assumed
gc
)

Creates a window with the specified GraphicsConfiguration of a screen device.

public
JWindow(Frame
the frame from which the window is displayed
owner
)

Creates a window with the specified owner frame.

public
JWindow(Window
the window from which the window is displayed
owner
)

Creates a window with the specified owner window.

public
JWindow(Window
the window from which the window is displayed
owner
,
GraphicsConfiguration
the GraphicsConfiguration that is used to construct the new window with; if gc is null, the system default GraphicsConfiguration is assumed, unless owner is also null, in which case the GraphicsConfiguration from the shared owner frame will be used.
gc
)

Creates a window with the specified owner window and GraphicsConfiguration of a screen device.

Method Summary

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

Overrides java.awt.Container.addImpl.

Adds the specified child Component.

protected JRootPane

Returns:

a new JRootPane
createRootPane
()

Called by the constructor methods to create the default rootPane.

public AccessibleContext

Returns:

an AccessibleJWindow that serves as the AccessibleContext of this JWindow
getAccessibleContext
()

Overrides java.awt.Window.getAccessibleContext.

Implements javax.accessibility.Accessible.getAccessibleContext.

Gets the AccessibleContext associated with this JWindow.

public Container

Returns:

the contentPane property
getContentPane
()

Implements javax.swing.RootPaneContainer.getContentPane.

Returns the Container which is the contentPane for this window.

public Component

Returns:

the glassPane property
getGlassPane
()

Implements javax.swing.RootPaneContainer.getGlassPane.

Returns the glassPane Component for this window.

public Graphics
getGraphics()

Overrides java.awt.Component.getGraphics.

Creates a graphics context for this component.

public JLayeredPane

Returns:

the layeredPane property
getLayeredPane
()

Implements javax.swing.RootPaneContainer.getLayeredPane.

Returns the layeredPane object for this window.

public JRootPane

Returns:

the rootPane property for this window
getRootPane
()

Implements javax.swing.RootPaneContainer.getRootPane.

Returns the rootPane object for this window.

public TransferHandler

Returns:

the value of the transferHandler property
getTransferHandler
()

Implements javax.swing.TransferHandler.HasGetTransferHandler.getTransferHandler.

Gets the transferHandler property.

protected boolean

Returns:

true if add and setLayout are forwarded; false otherwise
isRootPaneCheckingEnabled
()

Returns whether calls to add and setLayout are forwarded to the contentPane.

protected String

Returns:

a string representation of this JWindow
paramString
()

Overrides java.awt.Container.paramString.

Returns a string representation of this JWindow.

public void
remove(Component
the component to be removed
comp
)

Overrides java.awt.Container.remove.

Removes the specified component from the container.

public void
repaint(long
maximum time in milliseconds before update
time
,
int
the x coordinate
x
,
int
the y coordinate
y
,
int
the width
width
,
int
the height
height
)

Overrides java.awt.Component.repaint.

Repaints the specified rectangle of this component within time milliseconds.

public void
setContentPane(Container
the new contentPane
contentPane
)

Implements javax.swing.RootPaneContainer.setContentPane.

Sets the contentPane property for this window.

public void
setGlassPane(Component
the glassPane object for this window
glassPane
)

Implements javax.swing.RootPaneContainer.setGlassPane.

Sets the glassPane property.

public void
setLayeredPane(JLayeredPane
the new layeredPane object
layeredPane
)

Implements javax.swing.RootPaneContainer.setLayeredPane.

Sets the layeredPane property.

public void
setLayout(LayoutManager
the LayoutManager
manager
)

Overrides java.awt.Container.setLayout.

Sets the LayoutManager.

protected void
setRootPane(JRootPane
the new rootPane property
root
)

Sets the new rootPane object for this window.

protected void
setRootPaneCheckingEnabled(boolean
true if add and setLayout are forwarded, false if they should operate directly on the JWindow.
enabled
)

Sets whether calls to add and setLayout are forwarded to the contentPane.

public void
setTransferHandler(TransferHandler
the new TransferHandler
newHandler
)

Sets the transferHandler property, which is a mechanism to support transfer of data into this component.

public void
update(Graphics
the Graphics context in which to paint
g
)

Overrides java.awt.Container.update.

Calls paint(g).

protected void
windowInit()

Called by the constructors to init the JWindow properly.

Inherited from java.awt.Window:
addNotifyaddPropertyChangeListeneraddPropertyChangeListeneraddWindowFocusListeneraddWindowListeneraddWindowStateListenerapplyResourceBundleapplyResourceBundlecreateBufferStrategycreateBufferStrategydisposegetBackgroundgetBufferStrategygetFocusableWindowStategetFocusCycleRootAncestorgetFocusOwnergetFocusTraversalKeysgetIconImagesgetInputContextgetListenersgetLocalegetModalExclusionTypegetMostRecentFocusOwnergetOpacitygetOwnedWindowsgetOwnergetOwnerlessWindowsgetShapegetToolkitgetTypegetWarningStringgetWindowFocusListenersgetWindowListenersgetWindowsgetWindowStateListenershideisActiveisAlwaysOnTopisAlwaysOnTopSupportedisAutoRequestFocusisFocusableWindowisFocusCycleRootisFocusedisLocationByPlatformisOpaqueisShowingisValidateRootpackpaintpostEventprocessEventprocessWindowEventprocessWindowFocusEventprocessWindowStateEventremoveNotifyremoveWindowFocusListenerremoveWindowListenerremoveWindowStateListenerreshapesetAlwaysOnTopsetAutoRequestFocussetBackgroundsetBoundssetBoundssetCursorsetFocusableWindowStatesetFocusCycleRootsetIconImagesetIconImagessetLocationsetLocationsetLocationByPlatformsetLocationRelativeTosetMinimumSizesetModalExclusionTypesetOpacitysetShapesetSizesetSizesetTypesetVisibleshowtoBacktoFront

Field Detail

accessibleContextback to summary
protected AccessibleContext accessibleContext

Hides java.awt.Component.accessibleContext.

The accessible context property.

rootPaneback to summary
protected JRootPane rootPane

The JRootPane instance that manages the contentPane and optional menuBar for this frame, as well as the glassPane.

See Also
getRootPane, setRootPane
rootPaneCheckingEnabledback to summary
protected boolean rootPaneCheckingEnabled

If true then calls to add and setLayout will be forwarded to the contentPane. This is initially false, but is set to true when the JWindow is constructed.

See Also
isRootPaneCheckingEnabled, setRootPaneCheckingEnabled, javax.swing.RootPaneContainer
transferHandlerback to summary
private TransferHandler transferHandler

The TransferHandler for this window.

Constructor Detail

JWindowback to summary
public JWindow()

Creates a window with no specified owner. This window will not be focusable.

This constructor sets the component's locale property to the value returned by JComponent.getDefaultLocale.

Exceptions
HeadlessException:
if GraphicsEnvironment.isHeadless() returns true.
See Also
java.awt.GraphicsEnvironment#isHeadless, isFocusableWindow, JComponent#getDefaultLocale
JWindowback to summary
public JWindow(GraphicsConfiguration gc)

Creates a window with the specified GraphicsConfiguration of a screen device. This window will not be focusable.

This constructor sets the component's locale property to the value returned by JComponent.getDefaultLocale.

Parameters
gc:GraphicsConfiguration

the GraphicsConfiguration that is used to construct the new window with; if gc is null, the system default GraphicsConfiguration is assumed

Exceptions
HeadlessException:
If GraphicsEnvironment.isHeadless() returns true.
IllegalArgumentException:
if gc is not from a screen device.
Since
1.3
See Also
java.awt.GraphicsEnvironment#isHeadless, isFocusableWindow, JComponent#getDefaultLocale
JWindowback to summary
public JWindow(Frame owner)

Creates a window with the specified owner frame. If owner is null, the shared owner will be used and this window will not be focusable. Also, this window will not be focusable unless its owner is showing on the screen.

This constructor sets the component's locale property to the value returned by JComponent.getDefaultLocale.

Parameters
owner:Frame

the frame from which the window is displayed

Exceptions
HeadlessException:
if GraphicsEnvironment.isHeadless() returns true.
See Also
java.awt.GraphicsEnvironment#isHeadless, isFocusableWindow, JComponent#getDefaultLocale
JWindowback to summary
public JWindow(Window owner)

Creates a window with the specified owner window. This window will not be focusable unless its owner is showing on the screen. If owner is null, the shared owner will be used and this window will not be focusable.

This constructor sets the component's locale property to the value returned by JComponent.getDefaultLocale.

Parameters
owner:Window

the window from which the window is displayed

Exceptions
HeadlessException:
if GraphicsEnvironment.isHeadless() returns true.
See Also
java.awt.GraphicsEnvironment#isHeadless, isFocusableWindow, JComponent#getDefaultLocale
JWindowback to summary
public JWindow(Window owner, GraphicsConfiguration gc)

Creates a window with the specified owner window and GraphicsConfiguration of a screen device. If owner is null, the shared owner will be used and this window will not be focusable.

This constructor sets the component's locale property to the value returned by JComponent.getDefaultLocale.

Parameters
owner:Window

the window from which the window is displayed

gc:GraphicsConfiguration

the GraphicsConfiguration that is used to construct the new window with; if gc is null, the system default GraphicsConfiguration is assumed, unless owner is also null, in which case the GraphicsConfiguration from the shared owner frame will be used.

Exceptions
HeadlessException:
if GraphicsEnvironment.isHeadless() returns true.
IllegalArgumentException:
if gc is not from a screen device.
Since
1.3
See Also
java.awt.GraphicsEnvironment#isHeadless, isFocusableWindow, JComponent#getDefaultLocale

Method Detail

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

Overrides java.awt.Container.addImpl.

Adds the specified child Component. This method is overridden to conditionally forward calls to the contentPane. By default, children are added to the contentPane instead of the frame, refer to javax.swing.RootPaneContainer for details.

Parameters
comp:Component

the component to be enhanced

constraints:Object

the constraints to be respected

index:int

the index

Exceptions
IllegalArgumentException:
  • if index is invalid
  • if adding the container's parent to itself
  • if adding a window to a container
See Also
setRootPaneCheckingEnabled, javax.swing.RootPaneContainer
createRootPaneback to summary
protected JRootPane createRootPane()

Called by the constructor methods to create the default rootPane.

Returns:JRootPane

a new JRootPane

getAccessibleContextback to summary
public AccessibleContext getAccessibleContext()

Overrides java.awt.Window.getAccessibleContext.

Implements javax.accessibility.Accessible.getAccessibleContext.

Gets the AccessibleContext associated with this JWindow. For JWindows, the AccessibleContext takes the form of an AccessibleJWindow. A new AccessibleJWindow instance is created if necessary.

Returns:AccessibleContext

an AccessibleJWindow that serves as the AccessibleContext of this JWindow

getContentPaneback to summary
public Container getContentPane()

Implements javax.swing.RootPaneContainer.getContentPane.

Returns the Container which is the contentPane for this window.

Returns:Container

the contentPane property

See Also
setContentPane, RootPaneContainer#getContentPane
getGlassPaneback to summary
public Component getGlassPane()

Implements javax.swing.RootPaneContainer.getGlassPane.

Returns the glassPane Component for this window.

Returns:Component

the glassPane property

See Also
setGlassPane, RootPaneContainer#getGlassPane
getGraphicsback to summary
public Graphics getGraphics()

Overrides java.awt.Component.getGraphics.

Doc from java.awt.Component.getGraphics.

Creates a graphics context for this component. This method will return null if this component is currently not displayable.

Annotations
@BeanProperty
bound:false
Since
1.6
getLayeredPaneback to summary
public JLayeredPane getLayeredPane()

Implements javax.swing.RootPaneContainer.getLayeredPane.

Returns the layeredPane object for this window.

Returns:JLayeredPane

the layeredPane property

See Also
setLayeredPane, RootPaneContainer#getLayeredPane
getRootPaneback to summary
public JRootPane getRootPane()

Implements javax.swing.RootPaneContainer.getRootPane.

Returns the rootPane object for this window.

Returns:JRootPane

the rootPane property for this window

Annotations
@BeanProperty
bound:false
hidden:true
description:the RootPane object for this window.
See Also
setRootPane, RootPaneContainer#getRootPane
getTransferHandlerback to summary
public TransferHandler getTransferHandler()

Implements javax.swing.TransferHandler.HasGetTransferHandler.getTransferHandler.

Gets the transferHandler property.

Returns:TransferHandler

the value of the transferHandler property

Since
1.6
See Also
TransferHandler, setTransferHandler
isRootPaneCheckingEnabledback to summary
protected boolean isRootPaneCheckingEnabled()

Returns whether calls to add and setLayout are forwarded to the contentPane.

Returns:boolean

true if add and setLayout are forwarded; false otherwise

See Also
addImpl, setLayout, setRootPaneCheckingEnabled, javax.swing.RootPaneContainer
paramStringback to summary
protected String paramString()

Overrides java.awt.Container.paramString.

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

Returns:String

a string representation of this JWindow

removeback to summary
public void remove(Component comp)

Overrides java.awt.Container.remove.

Removes the specified component from the container. If comp is not the rootPane, this will forward the call to the contentPane. This will do nothing if comp is not a child of the JWindow or contentPane.

Parameters
comp:Component

the component to be removed

Exceptions
NullPointerException:
if comp is null
See Also
add, javax.swing.RootPaneContainer
repaintback to summary
public void repaint(long time, int x, int y, int width, int height)

Overrides java.awt.Component.repaint.

Repaints the specified rectangle of this component within time milliseconds. Refer to RepaintManager for details on how the repaint is handled.

Parameters
time:long

maximum time in milliseconds before update

x:int

the x coordinate

y:int

the y coordinate

width:int

the width

height:int

the height

Since
1.6
See Also
RepaintManager
setContentPaneback to summary
public void setContentPane(Container contentPane)

Implements javax.swing.RootPaneContainer.setContentPane.

Sets the contentPane property for this window. This method is called by the constructor.

Parameters
contentPane:Container

the new contentPane

Annotations
@BeanProperty
bound:false
hidden:true
description:The client area of the window where child components are normally inserted.
Exceptions
IllegalComponentStateException:
(a runtime exception) if the content pane parameter is null
See Also
getContentPane, RootPaneContainer#setContentPane
setGlassPaneback to summary
public void setGlassPane(Component glassPane)

Implements javax.swing.RootPaneContainer.setGlassPane.

Sets the glassPane property. This method is called by the constructor.

Parameters
glassPane:Component

the glassPane object for this window

Annotations
@BeanProperty
bound:false
hidden:true
description:A transparent pane used for menu rendering.
See Also
getGlassPane, RootPaneContainer#setGlassPane
setLayeredPaneback to summary
public void setLayeredPane(JLayeredPane layeredPane)

Implements javax.swing.RootPaneContainer.setLayeredPane.

Sets the layeredPane property. This method is called by the constructor.

Parameters
layeredPane:JLayeredPane

the new layeredPane object

Annotations
@BeanProperty
bound:false
hidden:true
description:The pane which holds the various window layers.
Exceptions
IllegalComponentStateException:
(a runtime exception) if the content pane parameter is null
See Also
getLayeredPane, RootPaneContainer#setLayeredPane
setLayoutback to summary
public void setLayout(LayoutManager manager)

Overrides java.awt.Container.setLayout.

Sets the LayoutManager. Overridden to conditionally forward the call to the contentPane. Refer to javax.swing.RootPaneContainer for more information.

Parameters
manager:LayoutManager

the LayoutManager

See Also
setRootPaneCheckingEnabled, javax.swing.RootPaneContainer
setRootPaneback to summary
protected void setRootPane(JRootPane root)

Sets the new rootPane object for this window. This method is called by the constructor.

Parameters
root:JRootPane

the new rootPane property

See Also
getRootPane
setRootPaneCheckingEnabledback to summary
protected void setRootPaneCheckingEnabled(boolean enabled)

Sets whether calls to add and setLayout are forwarded to the contentPane.

Parameters
enabled:boolean

true if add and setLayout are forwarded, false if they should operate directly on the JWindow.

Annotations
@BeanProperty
hidden:true
description:Whether the add and setLayout methods are forwarded
See Also
addImpl, setLayout, isRootPaneCheckingEnabled, javax.swing.RootPaneContainer
setTransferHandlerback to summary
public void setTransferHandler(TransferHandler newHandler)

Sets the transferHandler property, which is a mechanism to support transfer of data into this component. Use null if the component does not support data transfer operations.

If the system property suppressSwingDropSupport is false (the default) and the current drop target on this component is either null or not a user-set drop target, this method will change the drop target as follows: If newHandler is null it will clear the drop target. If not null it will install a new DropTarget.

Note

When used with JWindow, TransferHandler only provides data import capability, as the data export related methods are currently typed to JComponent.

Please see How to Use Drag and Drop and Data Transfer, a section in The Java Tutorial, for more information.

Parameters
newHandler:TransferHandler

the new TransferHandler

Annotations
@BeanProperty
hidden:true
description:Mechanism for transfer of data into the component
Since
1.6
See Also
TransferHandler, getTransferHandler, java.awt.Component#setDropTarget
updateback to summary
public void update(Graphics g)

Overrides java.awt.Container.update.

Calls paint(g). This method was overridden to prevent an unnecessary call to clear the background.

Parameters
g:Graphics

the Graphics context in which to paint

windowInitback to summary
protected void windowInit()

Called by the constructors to init the JWindow properly.

javax.swing back to summary

protected Class JWindow.AccessibleJWindow

extends AccessibleAWTWindow
Class Inheritance
Annotations
@SuppressWarnings:serial

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

Constructor Summary

AccessConstructor and Description
protected
AccessibleJWindow()

Constructs an AccessibleJWindow.

Method Summary

Inherited from java.awt.Window.AccessibleAWTWindow:
getAccessibleRolegetAccessibleStateSet

Constructor Detail

AccessibleJWindowback to summary
protected AccessibleJWindow()

Constructs an AccessibleJWindow.