Additional top-level class in compilation unit: FocusManager.
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.
Visual effects such as halos, shadows, motion effects and animations may be applied to the window by the desktop window management system. These are outside the knowledge and control of the AWT and so for the purposes of this specification are not considered part of the top-level window.
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.
An application may set the size and location of an invisible
Window arbitrarily, but the window management system may
subsequently change its size and/or location when the
Window is made visible. One or more ComponentEvents
will be generated to indicate the new geometry.
Windows are capable of generating the following WindowEvents: WindowOpened, WindowClosed, WindowGainedFocus, WindowLostFocus.
WindowEvent, addWindowListener, java.awt.BorderLayout
| Modifier and Type | Class and Description |
|---|---|
| protected class | Window.
This class implements accessibility support for the
|
| public static enum | Window.
Enumeration of available window types. |
| pack-priv static class |
| Modifier and Type | Field and Description |
|---|---|
| private static final IdentityArrayList | allWindows
Contains all the windows that have a peer object associated, i. |
| private boolean | alwaysOnTop
A boolean value representing Window always-on-top state |
| pack-priv transient Object | |
| private volatile boolean | autoRequestFocus
Indicates whether this window should receive focus on
subsequently being shown (with a call to |
| private static final String | |
| pack-priv transient boolean | |
| private static final AtomicBoolean | |
| pack-priv transient Window. | |
| private transient boolean | |
| private boolean | focusableWindowState
Indicates whether this Window can become the focused Window. |
| private FocusManager | focusMgr
Unused. |
| pack-priv transient List | icons
|
| pack-priv transient InputContext | |
| private transient Object | |
| pack-priv transient boolean | |
| pack-priv transient boolean | |
| private volatile boolean | |
| private static final boolean | |
| private static final PlatformLogger | log
Hides java. |
| pack-priv transient Dialog | modalBlocker
Contains the modal dialog that blocks this window, or null if the window is unblocked. |
| pack-priv Dialog. | |
| private static int | |
| private volatile float | opacity
The opacity level of the window |
| pack-priv static final int | |
| pack-priv transient Vector | ownedWindowList
A vector containing all the windows this window currently owns. |
| private static final long | serialVersionUID
Use serialVersionUID from JDK 1.1 for interoperability.
|
| private Shape | shape
The shape assigned to this window. |
| pack-priv transient boolean | |
| pack-priv int | state
An Integer value representing the Window State. |
| pack-priv boolean | |
| pack-priv static boolean | |
| private transient Component | temporaryLostComponent
Holds the reference to the component which last had focus in this window before it lost focus. |
| private Window. | |
| private transient WeakReference | |
| pack-priv transient WindowFocusListener | |
| private static final Vector | |
| pack-priv transient WindowListener | |
| private int | windowSerializedDataVersion
The window serialized data version. |
| pack-priv transient WindowStateListener |
| Access | Constructor and Description |
|---|---|
| pack-priv | Window(GraphicsConfiguration
the gc)GraphicsConfiguration of the target screen
device. If gc is null, the system default
GraphicsConfiguration is assumedConstructs a new, initially invisible window in default size with the
specified |
| pack-priv | |
| public | |
| public | |
| public | Window(Window
the window to act as owner or owner, GraphicsConfiguration null
if this window has no ownerthe gc)GraphicsConfiguration of the target
screen device; if gc is null,
the system default GraphicsConfiguration is assumedConstructs a new, initially invisible window with the specified owner
|
| Modifier and Type | Method and Description |
|---|---|
| public void | addNotify()
Overrides java. Makes this Window displayable by creating the connection to its native screen resource. |
| pack-priv void | |
| public void | addPropertyChangeListener(PropertyChangeListener
the PropertyChangeListener to be added listener)Overrides java. Adds a PropertyChangeListener to the listener list. |
| public void | addPropertyChangeListener(String
one of the property names listed above propertyName, PropertyChangeListener the PropertyChangeListener to be added listener)Overrides java. Adds a PropertyChangeListener to the listener list for a specific property. |
| private void | |
| public synchronized void | addWindowFocusListener(WindowFocusListener
the window focus listener l)Adds the specified window focus listener to receive window events from this window. |
| public synchronized void | addWindowListener(WindowListener
the window listener l)Adds the specified window listener to receive window events from this window. |
| public synchronized void | addWindowStateListener(WindowStateListener
the window state listener l)Adds the specified window state listener to receive window events from this window. |
| pack-priv void | |
| pack-priv void | adjustListeningChildrenOnParent(long mask, int num)
Overrides java.
|
| pack-priv final void | applyCompoundShape(Region
Shape to be applied to the component shape)Overrides java. Applies the shape to the component |
| pack-priv final void | |
| public void | applyResourceBundle(ResourceBundle
the resource bundle rb)
Deprecated
As of J2SE 1.4, replaced by
Component..
|
| public void | applyResourceBundle(String
the resource name rbName)
Deprecated
As of J2SE 1.4, replaced by
Component..
|
| pack-priv boolean | canContainFocusOwner(Component focusOwnerCandidate)
Overrides java. Checks whether this window can contain focus owner. |
| pack-priv final void | |
| pack-priv final void | |
| pack-priv void | |
| pack-priv String | constructComponentName()
Overrides java. Construct a name for this component. |
| public void | createBufferStrategy(int
number of buffers to create numBuffers)Overrides java. Creates a new strategy for multi-buffering on this component. |
| public void | createBufferStrategy(int
number of buffers to create, including the front buffer numBuffers, BufferCapabilities the required capabilities for creating the buffer strategy;
cannot be caps)nullOverrides java. Creates a new strategy for multi-buffering on this component with the required buffer capabilities. |
| pack-priv void | |
| private void | |
| pack-priv void | dispatchEventImpl(AWTEvent
the event e)Overrides java. Dispatches an event to this window or one of its sub components. |
| pack-priv boolean | dispatchMouseWheelToAncestor(MouseWheelEvent e)
Overrides java. Overridden from Component. |
| public void | dispose()
Releases all of the native screen resources used by this
|
| pack-priv void | |
| pack-priv void | |
| pack-priv boolean | |
| public AccessibleContext | Returns: an AccessibleAWTWindow that serves as the AccessibleContext of this WindowOverrides java. Implements javax. Gets the AccessibleContext associated with this Window. |
| pack-priv static IdentityArrayList | |
| pack-priv static IdentityArrayList | |
| public Color | Returns: this component's background colorOverrides java. Gets the background color of this window. |
| public BufferStrategy | Returns: the buffer strategy used by this componentOverrides java. Returns the |
| pack-priv final Container | |
| pack-priv Window | |
| public boolean | Returns: whether this Window can be the focused WindowReturns whether this Window can become the focused Window if it meets
the other requirements outlined in |
| public final Container | Returns: nullOverrides java. Always returns |
| public Component | Returns: the child Component with focus, or null if this Window is not focusedReturns the child Component of this Window that has focus if this Window is focused; returns null otherwise. |
| public Set | Returns: the AWTKeyStroke for the specified keyone of KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,
KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS,
KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, or
KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS id)Overrides java. Gets a focus traversal key for this Window. |
| public List | Returns: the copy of icon images' list for this window, or empty list if this window doesn't have icon images.Returns the sequence of images to be displayed as the icon for this window. |
| public InputContext | getInputContext()
Overrides java. Gets the input context for this window. |
| public <T extends EventListener> T[] | Returns: an array of all objects registered asFooListeners on this window,
or an empty array if no such
listeners have been addedthe type of listeners requested; this parameter
should specify an interface that descends from
listenerType)java.util.EventListenerOverrides java. Returns an array of all the objects currently registered
as |
| public Locale | Returns: the locale that is set for this window.Overrides java. Gets the |
| pack-priv final Point | |
| pack-priv Dialog | |
| public Dialog. | Returns: the modal exclusion type of this windowReturns the modal exclusion type of this window. |
| public Component | Returns: the child Component that will receive focus when this Window is focusedReturns the child Component of this Window that will receive the focus when this Window is focused. |
| public float | |
| public Window[] | Returns: the array of all the owned windowsReturn an array containing all the windows this window currently owns. |
| pack-priv final Window[] | |
| public Window | |
| pack-priv final Window | |
| public static Window[] | Returns: the array of all the ownerlessWindows
created by this applicationReturns an array of all |
| public Shape | Returns: the shape of the window ornull if no
shape is specified for the windowReturns the shape of the window. |
| pack-priv Component | |
| public Toolkit | Returns: the toolkit of this window.Overrides java. Returns the toolkit of this frame. |
| public Window. | |
| public final String | Returns: null
Deprecated
for removal since 24. since JDK 24
Gets the warning string that is displayed with this window. |
| public synchronized WindowFocusListener[] | Returns: all of this window'sWindowFocusListeners
or an empty array if no window focus
listeners are currently registeredReturns an array of all the window focus listeners registered on this window. |
| public synchronized WindowListener[] | Returns: all of this window'sWindowListeners
or an empty array if no window
listeners are currently registeredReturns an array of all the window listeners registered on this window. |
| public static Window[] | Returns: the array of all theWindows created by the applicationReturns an array of all |
| public synchronized WindowStateListener[] | Returns: all of this window'sWindowStateListeners
or an empty array if no window state
listeners are currently registeredReturns an array of all the window state listeners registered on this window. |
| public void | hide()
Overrides java.
Deprecated
As of JDK version 1.5, replaced by
setVisible(boolean).
Hide this Window, its subcomponents, and all of its owned children. |
| private void | |
| private void | |
| private GraphicsConfiguration | |
| private static native void | initIDs()
Hides java. Initialize JNI field and method IDs for fields that may be accessed from C. |
| public boolean | |
| public final boolean | Returns: true, if the window is in always-on-top state,
false otherwiseReturns whether this window is an always-on-top window. |
| public boolean | Returns: true, if the always-on-top mode is supported for
this window and this window's toolkit supports always-on-top windows,
false otherwiseReturns whether the always-on-top mode is supported for this window. |
| public boolean | Returns: autoRequestFocus valueReturns whether this window should receive focus on subsequently being shown
(with a call to |
| pack-priv boolean | |
| public final boolean | Returns: true if this Window can be the focused Window;
false otherwiseReturns whether this Window can become the focused Window, that is, whether this Window or any of its subcomponents can become the focus owner. |
| public final boolean | Returns: trueOverrides java. Always returns |
| public boolean | |
| public boolean | Returns: whether this Window will appear at the default locationReturns |
| pack-priv boolean | |
| pack-priv boolean | |
| public boolean | Returns: true if the window is opaque, false otherwiseOverrides java. Indicates if the window is currently opaque. |
| pack-priv boolean | Returns: true if the component and all of its ancestors
until a toplevel window are visible, false otherwiseOverrides java. Determines whether this component will be displayed on the screen. |
| public boolean | |
| public boolean | Returns: trueOverrides java. Indicates if this container is a validate root. |
| private static double | |
| pack-priv final void | |
| private void | |
| public void | |
| public void | |
| public boolean | postEvent(Event e)
Overrides java. Implements java.
Deprecated
As of JDK version 1.1
replaced by
dispatchEvent(AWTEvent).
Posts an event to the listeners. |
| pack-priv void | |
| pack-priv synchronized void | |
| pack-priv void | preProcessKeyEvent(KeyEvent
the keyboard event e)Overrides java. Implements a debugging hook -- checks to see if the user has typed control-shift-F1. |
| protected void | processEvent(AWTEvent
the event e)Overrides java. Processes events on this window. |
| protected void | processWindowEvent(WindowEvent
the window event e)Processes window events occurring on this window by dispatching them to any registered WindowListener objects. |
| protected void | processWindowFocusEvent(WindowEvent
the window focus event e)Processes window focus event occurring on this window by dispatching them to any registered WindowFocusListener objects. |
| protected void | processWindowStateEvent(WindowEvent
the window state event e)Processes window state event occurring on this window by
dispatching them to any registered |
| private void | readObject(ObjectInputStream
the s)ObjectInputStream to readHides java. Reads the |
| private static void | |
| private void | |
| public void | removeNotify()
Overrides java. Makes this Container undisplayable by removing its connection to its native screen resource. |
| pack-priv void | |
| public synchronized void | removeWindowFocusListener(WindowFocusListener
the window focus listener l)Removes the specified window focus listener so that it no longer receives window events from this window. |
| public synchronized void | removeWindowListener(WindowListener
the window listener l)Removes the specified window listener so that it no longer receives window events from this window. |
| public synchronized void | removeWindowStateListener(WindowStateListener
the window state listener l)Removes the specified window state listener so that it no longer receives window events from this window. |
| public void | reshape(int x, int y, int width, int height)
Overrides java.
Deprecated
As of JDK version 1.1,
replaced by
setBounds(int, int, int, int).
Reshapes the bounding rectangle for this component. |
| public final void | setAlwaysOnTop(boolean
true if the window should always be above other
windows alwaysOnTop)Sets whether this window should always be above other windows. |
| public void | setAutoRequestFocus(boolean
whether this window should be focused on
subsequently being shown or being moved to the front autoRequestFocus)Sets whether this window should receive focus on
subsequently being shown (with a call to |
| public void | setBackground(Color
the color to become this window's background color. bgColor)Overrides java. Sets the background color of this window. |
| public void | setBounds(int x, int y, int width, int height)
Overrides java. Moves and resizes this component. |
| public void | setBounds(Rectangle r)
Overrides java. Moves and resizes this component to conform to the new
bounding rectangle |
| pack-priv void | |
| public void | setCursor(Cursor
One of the constants defined
by the cursor)Cursor class. If this parameter is null
then the cursor for this window will be set to the type
Cursor.DEFAULT_CURSOR.Overrides java. Set the cursor image to a specified cursor. |
| public void | setFocusableWindowState(boolean
whether this Window can be the focused
Window focusableWindowState)Sets whether this Window can become the focused Window if it meets
the other requirements outlined in |
| public final void | setFocusCycleRoot(boolean
this value is ignored focusCycleRoot)Overrides java. Does nothing because Windows must always be roots of a focus traversal cycle. |
| pack-priv void | |
| public void | setIconImage(Image
the icon image to be displayed. image)Sets the image to be displayed as the icon for this window. |
| public synchronized void | setIconImages(List<? extends Image>
the list of icon images to be displayed. icons)Sets the sequence of images to be displayed as the icon for this window. |
| private static void | |
| public void | setLocation(int x, int y)
Overrides java. Moves this component to a new location. |
| public void | setLocation(Point p)
Overrides java. Moves this component to a new location. |
| public void | setLocationByPlatform(boolean
true if this Window should appear
at the default location, false if at the current locationSets whether this Window should appear at the default location for the
native windowing system or at the current location (returned by
|
| public void | setLocationRelativeTo(Component
the component in relation to which the window's location
is determined c)Sets the location of the window relative to the specified component according to the following scenarios. |
| public void | setMinimumSize(Dimension
the new minimum size of this window minimumSize)Overrides java. Sets the minimum size of this window to a constant value. |
| pack-priv void | |
| public void | setModalExclusionType(Dialog.
the modal exclusion type for this window; a exclusionTypenull
value is equivalent to NO_EXCLUDESpecifies the modal exclusion type for this window. |
| public void | |
| private void | |
| public void | |
| public void | setSize(Dimension d)
Overrides java. Resizes this component so that it has width |
| public void | setSize(int width, int height)
Overrides java. Resizes this component so that it has width |
| pack-priv Component | |
| public void | |
| public void | setVisible(boolean
if b)true, makes the Window visible,
otherwise hides the Window.
If the Window and/or its owner
are not yet displayable, both are made displayable. The
Window will be validated prior to being made visible.
If the Window is already visible, this will bring the
Window to the front.
If Overrides java. Shows or hides this |
| public void | show()
Overrides java.
Deprecated
As of JDK version 1.5, replaced by
setVisible(boolean).
Makes the Window visible. |
| public 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. |
| pack-priv final void | |
| public void | toFront()
If this Window is visible, brings this Window to the front and may make it the focused Window. |
| pack-priv final void | |
| pack-priv static void | |
| pack-priv void | |
| private void | |
| pack-priv void | |
| private void | writeObject(ObjectOutputStream
the s)ObjectOutputStream to writeHides java. Writes default serializable fields to stream. |