|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object![]()
![]()
![]()
java.awt.Component
![]()
![]()
![]()
java.awt.Container
![]()
![]()
![]()
java.awt.Window
, MenuContainer
, Serializable
, Accessible

, Dialog
, Frame
, JWindow

public class Window


A Window object is a top-level window with no borders and no
menubar.
The default layout for a window is BorderLayout.
A window must have either a frame, dialog, or another window defined as its owner when it's constructed.
In a multi-screen environment, you can create a Window
on a different screen device by constructing the Window
with Window(Window, GraphicsConfiguration)
. The
GraphicsConfiguration object is one of the
GraphicsConfiguration objects of the target screen device.
In a virtual device multi-screen environment in which the desktop area could span multiple physical screen devices, the bounds of all configurations are relative to the virtual device coordinate system. The origin of the virtual-coordinate system is at the upper left-hand corner of the primary physical screen. Depending on the location of the primary screen in the virtual device, negative coordinates are possible, as shown in the following figure.
In such an environment, when calling setLocation,
you must pass a virtual coordinate to this method. Similarly,
calling getLocationOnScreen on a Window returns
virtual device coordinates. Call the getBounds method
of a GraphicsConfiguration to find its origin in the virtual
coordinate system.
The following code sets the location of a Window
at (10, 10) relative to the origin of the physical screen
of the corresponding GraphicsConfiguration. If the
bounds of the GraphicsConfiguration is not taken
into account, the Window location would be set
at (10, 10) relative to the virtual-coordinate system and would appear
on the primary physical screen, which might be different from the
physical screen of the specified GraphicsConfiguration.
Window w = new Window(Window owner, GraphicsConfiguration gc);
Rectangle bounds = gc.getBounds();
w.setLocation(10 + bounds.x, 10 + bounds.y);
Note: the location and size of top-level windows (including
Windows, Frames, and Dialogs)
are under the control of the desktop's window management system.
Calls to setLocation, setSize, and
setBounds are requests (not directives) which are
forwarded to the window management system. Every effort will be
made to honor such requests. However, in some cases the window
management system may ignore such requests, or modify the requested
geometry in order to place and size the Window in a way
that more closely matches the desktop settings.
Due to the asynchronous nature of native event handling, the results
returned by getBounds, getLocation,
getLocationOnScreen, and getSize might not
reflect the actual geometry of the Window on screen until the last
request has been processed. During the processing of subsequent
requests these values might change accordingly while the window
management system fulfills the requests.
Windows are capable of generating the following WindowEvents: WindowOpened, WindowClosed, WindowGainedFocus, WindowLostFocus.
WindowEvent
,
addWindowListener(java.awt.event.WindowListener)
,
BorderLayout
,
Serialized Form| Nested Class Summary | |
|---|---|
protected class |
Window.AccessibleAWTWindow
This class implements accessibility support for the Window class. |
Nested classes/interfaces inherited from class java.awt.Container ![]() |
|---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component ![]() |
|---|
Component.AccessibleAWTComponent |
| Field Summary |
|---|
Fields inherited from class java.awt.Component ![]() |
|---|
BOTTOM_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver ![]() |
|---|
ABORT |
| Constructor Summary | |
|---|---|
Window
Constructs a new invisible window with the specified Frame as its owner. |
|
Window
Constructs a new invisible window with the specified Window as its owner. |
|
Window
Constructs a new invisible window with the specified window as its owner and a GraphicsConfiguration of a screen device. |
|
| Method Summary | ||
|---|---|---|
void |
addNotify
Makes this Window displayable by creating the connection to its native screen resource. |
|
void |
addPropertyChangeListener
Adds a PropertyChangeListener to the listener list. |
|
void |
addPropertyChangeListener
Adds a PropertyChangeListener to the listener list for a specific property. |
|
void |
addWindowFocusListener
Adds the specified window focus listener to receive window events from this window. |
|
void |
addWindowListener
Adds the specified window listener to receive window events from this window. |
|
void |
addWindowStateListener
Adds the specified window state listener to receive window events from this window. |
|
void |
applyResourceBundle
Deprecated. As of J2SE 1.4, replaced by Component.applyComponentOrientation . |
|
void |
applyResourceBundle
Deprecated. As of J2SE 1.4, replaced by Component.applyComponentOrientation . |
|
void |
createBufferStrategy
Creates a new strategy for multi-buffering on this component. |
|
void |
createBufferStrategy
Creates a new strategy for multi-buffering on this component with the required buffer capabilities. |
|
void |
dispose
Releases all of the native screen resources used by this Window, its subcomponents, and all of its owned
children. |
|
protected void |
finalize
Disposes of the input methods and context, and removes this Window from the GUI hierarchy. |
|
AccessibleContext |
getAccessibleContext
Gets the AccessibleContext associated with this Window. |
|
BufferStrategy |
getBufferStrategy
|
|
boolean |
getFocusableWindowState
Returns whether this Window can become the focused Window if it meets the other requirements outlined in isFocusableWindow. |
|
Container |
getFocusCycleRootAncestor
Always returns null because Windows have no ancestors; they
represent the top of the Component hierarchy. |
|
Component |
getFocusOwner
Returns the child Component of this Window that has focus if this Window is focused; returns null otherwise. |
|
Set |
getFocusTraversalKeys
Gets a focus traversal key for this Window. |
|
GraphicsConfiguration |
getGraphicsConfiguration
This method returns the GraphicsConfiguration used by this Window. |
|
InputContext |
getInputContext
Gets the input context for this window. |
|
|
getListeners
Returns an array of all the objects currently registered as FooListeners
upon this Window. |
|
Locale |
getLocale
Gets the Locale object that is associated
with this window, if the locale has been set. |
|
Component |
getMostRecentFocusOwner
Returns the child Component of this Window that will receive the focus when this Window is focused. |
|
Window |
getOwnedWindows
Return an array containing all the windows this window currently owns. |
|
Window |
getOwner
Returns the owner of this window. |
|
Toolkit |
getToolkit
Returns the toolkit of this frame. |
|
String |
getWarningString
Gets the warning string that is displayed with this window. |
|
WindowFocusListener |
getWindowFocusListeners
Returns an array of all the window focus listeners registered on this window. |
|
WindowListener |
getWindowListeners
Returns an array of all the window listeners registered on this window. |
|
WindowStateListener |
getWindowStateListeners
Returns an array of all the window state listeners registered on this window. |
|
void |
hide
Deprecated. As of JDK 5, replaced by Component.setVisible(boolean) . |
|
boolean |
isActive
Returns whether this Window is active. |
|
boolean |
isAlwaysOnTop
Returns whether this window is an always-on-top window. |
|
boolean |
isFocusableWindow
Returns whether this Window can become the focused Window, that is, whether this Window or any of its subcomponents can become the focus owner. |
|
boolean |
isFocusCycleRoot
Always returns true because all Windows must be roots of a
focus traversal cycle. |
|
boolean |
isFocused
Returns whether this Window is focused. |
|
boolean |
isLocationByPlatform
Returns true if this Window will appear at the default location
for the native windowing system the next time this Window is made visible. |
|
boolean |
isShowing
Checks if this Window is showing on screen. |
|
void |
pack
Causes this Window to be sized to fit the preferred size and layouts of its subcomponents. |
|
boolean |
postEvent
Deprecated. As of JDK version 1.1 replaced by dispatchEvent(AWTEvent). |
|
protected void |
processEvent
Processes events on this window. |
|
protected void |
processWindowEvent
Processes window events occurring on this window by dispatching them to any registered WindowListener objects. |
|
protected void |
processWindowFocusEvent
Processes window focus event occuring on this window by dispatching them to any registered WindowFocusListener objects. |
|
protected void |
processWindowStateEvent
Processes window state event occuring on this window by dispatching them to any registered WindowStateListener
objects. |
|
void |
removeWindowFocusListener
Removes the specified window focus listener so that it no longer receives window events from this window. |
|
void |
removeWindowListener
Removes the specified window listener so that it no longer receives window events from this window. |
|
void |
removeWindowStateListener
Removes the specified window state listener so that it no longer receives window events from this window. |
|
void |
setAlwaysOnTop
Changes the always-on-top window state. |
|
void |
setBounds
Moves and resizes this component. |
|
void |
setCursor
Set the cursor image to a specified cursor. |
|
void |
setFocusableWindowState
Sets whether this Window can become the focused Window if it meets the other requirements outlined in isFocusableWindow. |
|
void |
setFocusCycleRoot
Does nothing because Windows must always be roots of a focus traversal cycle. |
|
void |
setLocationByPlatform
Sets whether this Window should appear at the default location for the native windowing system or at the current location (returned by getLocation) the next time the Window is made visible. |
|
void |
setLocationRelativeTo
Sets the location of the window relative to the specified component. |
|
void |
show
Deprecated. As of JDK 5, replaced by Component.setVisible(boolean) . |
|
void |
toBack
If this Window is visible, sends this Window to the back and may cause it to lose focus or activation if it is the focused or active Window. |
|
void |
toFront
If this Window is visible, brings this Window to the front and may make it the focused Window. |
|
Methods inherited from class java.awt.Container ![]() |
|---|
add |