This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.


java.awt
class Window

java.lang.Object extended by java.awt.Component extended by java.awt.Container extended by java.awt.Window
All Implemented Interfaces:
MenuContainer, ImageObserver, Serializable, Accessible
Direct Known Subclasses:
BasicToolBarUI.DragWindow, Dialog, Frame, JWindow

public class Window
extends Container
implements Accessible

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 {@link #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.

Diagram shows virtual device containing 4 physical screens. Primary physical screen shows coords (0,0), other screen shows (-80,-100).

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.

An application may set the size and location of an invisible {@code Window} arbitrarily, but the window management system may subsequently change its size and/or location when the {@code Window} is made visible. One or more {@code ComponentEvent}s will be generated to indicate the new geometry.

Windows are capable of generating the following WindowEvents: WindowOpened, WindowClosed, WindowGainedFocus, WindowLostFocus.


Nested Class Summary
protected class

           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, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
   
Field Summary
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
Window(Frame owner)

          Constructs a new, initially invisible window with the specified Frame as its owner.
Window(Window owner)

          Constructs a new, initially invisible window with the specified Window as its owner.

          Constructs a new, initially invisible window with the specified owner Window and a GraphicsConfiguration of a screen device.
 
Method Summary
 void

          Makes this Window displayable by creating the connection to its native screen resource.
 void

          Adds a PropertyChangeListener to the listener list.
 void

          Adds a PropertyChangeListener to the listener list for a specific property.
 void

          Adds the specified window focus listener to receive window events from this window.
 void

          Adds the specified window listener to receive window events from this window.
 void

          Adds the specified window state listener to receive window events from this window.
 void

          
 void

          
 void
createBufferStrategy(int numBuffers)

          Creates a new strategy for multi-buffering on this component.
 void

          Creates a new strategy for multi-buffering on this component with the required buffer capabilities.
 void

          Releases all of the native screen resources used by this Window, its subcomponents, and all of its owned children.
 AccessibleContext

          Gets the AccessibleContext associated with this Window.
 BufferStrategy

          Returns the BufferStrategy used by this component.
 boolean

          Returns whether this Window can become the focused Window if it meets the other requirements outlined in isFocusableWindow.
 Container

          Always returns null because Windows have no ancestors; they represent the top of the Component hierarchy.
 Component

          Returns the child Component of this Window that has focus if this Window is focused; returns null otherwise.
 Set

          Gets a focus traversal key for this Window.
 GraphicsConfiguration

          This method returns the GraphicsConfiguration used by this Window.
 List

          Returns the sequence of images to be displayed as the icon for this window.
 InputContext

          Gets the input context for this window.
 EventListener[]
getListeners(Class listenerType)

          Returns an array of all the objects currently registered as FooListeners upon this Window.
 Locale

          Gets the Locale object that is associated with this window, if the locale has been set.
 Dialog.ModalExclusionType

          Returns the modal exclusion type of this window.
 Component

          Returns the child Component of this Window that will receive the focus when this Window is focused.
 Window[]

          Return an array containing all the windows this window currently owns.
 Window

          Returns the owner of this window.
static Window[]

          Returns an array of all s created by this application that have no owner.
 Toolkit

          Returns the toolkit of this frame.
 String

          Gets the warning string that is displayed with this window.
 WindowFocusListener[]

          Returns an array of all the window focus listeners registered on this window.
 WindowListener[]

          Returns an array of all the window listeners registered on this window.
static Window[]

          Returns an array of all s, both owned and ownerless, created by this application.
 WindowStateListener[]

          Returns an array of all the window state listeners registered on this window.
 void

          Hide this Window, its subcomponents, and all of its owned children.
 boolean

          Returns whether this Window is active.
 boolean

          Returns whether this window is an always-on-top window.
 boolean

          Returns whether the always-on-top mode is supported for this window.
 boolean

          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

          Always returns true because all Windows must be roots of a focus traversal cycle.
 boolean

          Returns whether this Window is focused.
 boolean

          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

          Checks if this Window is showing on screen.
 void

          Causes this Window to be sized to fit the preferred size and layouts of its subcomponents.
 boolean

          
protected void

          Processes events on this window.
protected void

          Processes window events occurring on this window by dispatching them to any registered WindowListener objects.
protected void

          Processes window focus event occuring on this window by dispatching them to any registered WindowFocusListener objects.
protected void

          Processes window state event occuring on this window by dispatching them to any registered WindowStateListener objects.
 void

          Makes this Container undisplayable by removing its connection to its native screen resource.
 void

          Removes the specified window focus listener so that it no longer receives window events from this window.
 void

          Removes the specified window listener so that it no longer receives window events from this window.
 void

          Removes the specified window state listener so that it no longer receives window events from this window.
 void
reshape(int x, int y, int width, int height)

          
 void
setAlwaysOnTop(boolean alwaysOnTop)

          Sets whether this window should always be above other windows.
 void
setBounds(int x, int y, int width, int height)

          Moves and resizes this component.
 void

          Moves and resizes this component.
 void
setCursor(Cursor cursor)

          Set the cursor image to a specified cursor.
 void
setFocusableWindowState(boolean focusableWindowState)

          Sets whether this Window can become the focused Window if it meets the other requirements outlined in isFocusableWindow.
 void
setFocusCycleRoot(boolean focusCycleRoot)

          Does nothing because Windows must always be roots of a focus traversal cycle.
 void

          Sets the image to be displayed as the icon for this window.
 void

          Sets the sequence of images to be displayed as the icon for this window.
 void
setLocationByPlatform(boolean locationByPlatform)

          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

          Sets the location of the window relative to the specified component.
 void

          Sets the minimum size of this window to a constant value.
 void

          Specifies the modal exclusion type for this window.
 void

          Resizes this component so that it has width width and height height.
 void
setSize(int width, int height)

          Resizes this component so that it has width width and height height.
 void
setVisible(boolean b)

          Shows or hides this depending on the value of parameter .
 void

          Makes the Window visible.
 void

          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

          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, add, add, add, add, addContainerListener, addImpl, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, validate, validateTree
 
Methods inherited from class 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, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, 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, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, 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, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Window

public Window(Frame owner)
Constructs a new, initially invisible window with the specified Frame as its owner. The window will not be focusable unless its owner is showing on the screen.

If there is a security manager, this method first calls the security manager's checkTopLevelWindow method with this as its argument to determine whether or not the window must be displayed with a warning banner.

Parameters:
owner - the Frame to act as owner or null if this window has no owner

Window

public Window(Window owner)
Constructs a new, initially invisible window with the specified Window as its owner. This window will not be focusable unless its nearest owning Frame or Dialog is showing on the screen.

If there is a security manager, this method first calls the security manager's checkTopLevelWindow method with this as its argument to determine whether or not the window must be displayed with a warning banner.

Parameters:
owner - the Window to act as owner or null if this window has no owner

Window

public Window(Window owner,
              GraphicsConfiguration gc)
Constructs a new, initially invisible window with the specified owner Window and a GraphicsConfiguration of a screen device. The Window will not be focusable unless its nearest owning Frame or Dialog is showing on the screen.

If there is a security manager, this method first calls the security manager's checkTopLevelWindow method with this as its argument to determine whether or not the window must be displayed with a warning banner.

Parameters:
owner - the window to act as owner or null if this window has no owner
gc - the GraphicsConfiguration of the target screen device; if gc is null, the system default GraphicsConfiguration is assumed
Method Detail

addNotify

public void addNotify()
Makes this Window displayable by creating the connection to its native screen resource. This method is called internally by the toolkit and should not be called directly by programs.

Overrides:
addNotify in class Container

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list. The listener is registered for all bound properties of this class, including the following: Note that if this Window is inheriting a bound property, then no event will be fired in response to a change in the inherited property.

If listener is null, no exception is thrown and no action is performed.

Overrides:
addPropertyChangeListener in class Container
Parameters:
listener - the PropertyChangeListener to be added

addPropertyChangeListener

public void addPropertyChangeListener(String propertyName,
                                      PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list for a specific property. The specified property may be user-defined, or one of the following: Note that if this Window is inheriting a bound property, then no event will be fired in response to a change in the inherited property.

If listener is null, no exception is thrown and no action is performed.

Overrides:
addPropertyChangeListener in class Container
Parameters:
propertyName - one of the property names listed above
listener - the PropertyChangeListener to be added

addWindowFocusListener

public synchronized void addWindowFocusListener(WindowFocusListener l)
Adds the specified window focus listener to receive window events from this window. If l is null, no exception is thrown and no action is performed.

Refer to AWT Threading Issues for details on AWT's threading model.

Parameters:
l - the window focus listener

addWindowListener

public synchronized void addWindowListener(WindowListener l)
Adds the specified window listener to receive window events from this window. If l is null, no exception is thrown and no action is performed.

Refer to AWT Threading Issues for details on AWT's threading model.

Parameters:
l - the window listener

addWindowStateListener

public synchronized void addWindowStateListener(WindowStateListener l)
Adds the specified window state listener to receive window events from this window. If l is null, no exception is thrown and no action is performed.

Refer to AWT Threading Issues for details on AWT's threading model.

Parameters:
l - the window state listener

applyResourceBundle

public void applyResourceBundle(ResourceBundle rb)
Parameters:
rb

applyResourceBundle

public void applyResourceBundle(String rbName)
Parameters:
rbName

createBufferStrategy

public void createBufferStrategy(int numBuffers)
Creates a new strategy for multi-buffering on this component. Multi-buffering is useful for rendering performance. This method attempts to create the best strategy available with the number of buffers supplied. It will always create a BufferStrategy with that number of buffers. A page-flipping strategy is attempted first, then a blitting strategy using accelerated buffers. Finally, an unaccelerated blitting strategy is used.

Each time this method is called, the existing buffer strategy for this component is discarded.

Overrides:
createBufferStrategy in class Component
Parameters:
numBuffers - number of buffers to create

createBufferStrategy

public void createBufferStrategy(int numBuffers,
                                 BufferCapabilities caps)
                          throws AWTException
Creates a new strategy for multi-buffering on this component with the required buffer capabilities. This is useful, for example, if only accelerated memory or page flipping is desired (as specified by the buffer capabilities).

Each time this method is called, the existing buffer strategy for this component is discarded.

Overrides:
createBufferStrategy in class Component
Parameters:
numBuffers - number of buffers to create, including the front buffer
caps - the required capabilities for creating the buffer strategy; cannot be null
Throws:
AWTException - if the capabilities supplied could not be supported or met; this may happen, for example, if there is not enough accelerated memory currently available, or if page flipping is specified but not possible.

dispose

public void dispose()
Releases all of the native screen resources used by this Window, its subcomponents, and all of its owned children. That is, the resources for these Components will be destroyed, any memory they consume will be returned to the OS, and they will be marked as undisplayable.

The Window and its subcomponents can be made displayable again by rebuilding the native resources with a subsequent call to pack or show. The states of the recreated Window and its subcomponents will be identical to the states of these objects at the point where the Window was disposed (not accounting for additional modifications between those actions).

Note: When the last displayable window within the Java virtual machine (VM) is disposed of, the VM may terminate. See AWT Threading Issues for more information.


getAccessibleContext

public AccessibleContext getAccessibleContext()
Gets the AccessibleContext associated with this Window. For windows, the AccessibleContext takes the form of an AccessibleAWTWindow. A new AccessibleAWTWindow instance is created if necessary.

Overrides:
getAccessibleContext in class Component
Returns:
an AccessibleAWTWindow that serves as the AccessibleContext of this Window

getBufferStrategy

public BufferStrategy getBufferStrategy()
Returns the BufferStrategy used by this component. This method will return null if a BufferStrategy has not yet been created or has been disposed.

Overrides:
getBufferStrategy in class Component
Returns:
the buffer strategy used by this component

getFocusableWindowState

public boolean getFocusableWindowState()
Returns whether this Window can become the focused Window if it meets the other requirements outlined in isFocusableWindow. If this method returns false, then isFocusableWindow will return false as well. If this method returns true, then isFocusableWindow may return true or false depending upon the other requirements which must be met in order for a Window to be focusable.

By default, all Windows have a focusable Window state of true.

Returns:
whether this Window can be the focused Window

getFocusCycleRootAncestor

public final Container getFocusCycleRootAncestor()
Always returns null because Windows have no ancestors; they represent the top of the Component hierarchy.

Overrides:
getFocusCycleRootAncestor in class Component
Returns:
null

getFocusOwner

public Component getFocusOwner()
Returns the child Component of this Window that has focus if this Window is focused; returns null otherwise.

Returns:
the child Component with focus, or null if this Window is not focused

getFocusTraversalKeys

public Set getFocusTraversalKeys(int id)
Gets a focus traversal key for this Window. (See setFocusTraversalKeys for a full description of each key.)

If the traversal key has not been explicitly set for this Window, then this Window's parent's traversal key is returned. If the traversal key has not been explicitly set for any of this Window's ancestors, then the current KeyboardFocusManager's default traversal key is returned.

Overrides:
getFocusTraversalKeys in class Container
Parameters:
id - one of KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, or KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS
Returns:
the AWTKeyStroke for the specified key

getGraphicsConfiguration

public GraphicsConfiguration getGraphicsConfiguration()
This method returns the GraphicsConfiguration used by this Window.

Overrides:
getGraphicsConfiguration in class Component

getIconImages

public List getIconImages()
Returns the sequence of images to be displayed as the icon for this window.

This method returns a copy of the internally stored list, so all operations on the returned object will not affect the window's behavior.

Returns:
the copy of icon images' list for this window, or empty list if this window doesn't have icon images.

getInputContext

public InputContext getInputContext()
Gets the input context for this window. A window always has an input context, which is shared by subcomponents unless they create and set their own.

Overrides:
getInputContext in class Component

getListeners

public EventListener[] getListeners(Class listenerType)
Returns an array of all the objects currently registered as FooListeners upon this Window. FooListeners are registered using the addFooListener method.

You can specify the listenerType argument with a class literal, such as FooListener.class. For example, you can query a Window w for its window listeners with the following code:

WindowListener[] wls = (WindowListener[])(w.getListeners(WindowListener.class));
If no such listeners exist, this method returns an empty array.

Overrides:
getListeners in class Container
Parameters:
listenerType - the type of listeners requested; this parameter should specify an interface that descends from java.util.EventListener
Returns:
an array of all objects registered as FooListeners on this window, or an empty array if no such listeners have been added

getLocale

public Locale getLocale()
Gets the Locale object that is associated with this window, if the locale has been set. If no locale has been set, then the default locale is returned.

Overrides:
getLocale in class Component
Returns:
the locale that is set for this window.

getModalExclusionType

public Dialog.ModalExclusionType getModalExclusionType()
Returns the modal exclusion type of this window.

Returns:
the modal exclusion type of this window

getMostRecentFocusOwner

public Component getMostRecentFocusOwner()
Returns the child Component of this Window that will receive the focus when this Window is focused. If this Window is currently focused, this method returns the same Component as getFocusOwner(). If this Window is not focused, then the child Component that most recently requested focus will be returned. If no child Component has ever requested focus, and this is a focusable Window, then this Window's initial focusable Component is returned. If no child Component has ever requested focus, and this is a non-focusable Window, null is returned.

Returns:
the child Component that will receive focus when this Window is focused

getOwnedWindows

public Window[] getOwnedWindows()
Return an array containing all the windows this window currently owns.


getOwner

public Window getOwner()
Returns the owner of this window.


getOwnerlessWindows

public static Window[] getOwnerlessWindows()
Returns an array of all {@code Window}s created by this application that have no owner. They include {@code Frame}s and ownerless {@code Dialog}s and {@code Window}s. If called from an applet, the array includes only the {@code Window}s accessible by that applet.

Warning: this method may return system created windows, such as a print dialog. Applications should not assume the existence of these dialogs, nor should an application assume anything about these dialogs such as component positions, LayoutManagers or serialization.


getToolkit

public Toolkit getToolkit()
Returns the toolkit of this frame.

Overrides:
getToolkit in class Component
Returns:
the toolkit of this window.

getWarningString

public final String getWarningString()
Gets the warning string that is displayed with this window. If this window is insecure, the warning string is displayed somewhere in the visible area of the window. A window is insecure if there is a security manager, and the security manager's checkTopLevelWindow method returns false when this window is passed to it as an argument.

If the window is secure, then getWarningString returns null. If the window is insecure, this method checks for the system property awt.appletWarning and returns the string value of that property.

Returns:
the warning string for this window.

getWindowFocusListeners

public synchronized WindowFocusListener[] getWindowFocusListeners()
Returns an array of all the window focus listeners registered on this window.

Returns:
all of this window's WindowFocusListeners or an empty array if no window focus listeners are currently registered

getWindowListeners

public synchronized WindowListener[] getWindowListeners()
Returns an array of all the window listeners registered on this window.

Returns:
all of this window's WindowListeners or an empty array if no window listeners are currently registered

getWindows

public static Window[] getWindows()
Returns an array of all {@code Window}s, both owned and ownerless, created by this application. If called from an applet, the array includes only the {@code Window}s accessible by that applet.

Warning: this method may return system created windows, such as a print dialog. Applications should not assume the existence of these dialogs, nor should an application assume anything about these dialogs such as component positions, LayoutManagers or serialization.


getWindowStateListeners

public synchronized WindowStateListener[] getWindowStateListeners()
Returns an array of all the window state listeners registered on this window.

Returns:
all of this window's WindowStateListeners or an empty array if no window state listeners are currently registered

hide

public void hide()
Hide this Window, its subcomponents, and all of its owned children. The Window and its subcomponents can be made visible again with a call to {@code show}.

Overrides:
hide in class Component

isActive

public boolean isActive()
Returns whether this Window is active. Only a Frame or a Dialog may be active. The native windowing system may denote the active Window or its children with special decorations, such as a highlighted title bar. The active Window is always either the focused Window, or the first Frame or Dialog that is an owner of the focused Window.

Returns:
whether this is the active Window.

isAlwaysOnTop

public final boolean isAlwaysOnTop()
Returns whether this window is an always-on-top window.

Returns:
true, if the window is in always-on-top state, false otherwise

isAlwaysOnTopSupported

public boolean isAlwaysOnTopSupported()
Returns whether the always-on-top mode is supported for this window. Some platforms may not support always-on-top windows, some may support only some kinds of top-level windows; for example, a platform may not support always-on-top modal dialogs.

Returns:
true, if the always-on-top mode is supported by the toolkit and for this window, false, if always-on-top mode is not supported for this window or toolkit doesn't support always-on-top windows.

isFocusableWindow

public final 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. For a Frame or Dialog to be focusable, its focusable Window state must be set to true. For a Window which is not a Frame or Dialog to be focusable, its focusable Window state must be set to true, its nearest owning Frame or Dialog must be showing on the screen, and it must contain at least one Component in its focus traversal cycle. If any of these conditions is not met, then neither this Window nor any of its subcomponents can become the focus owner.

Returns:
true if this Window can be the focused Window; false otherwise

isFocusCycleRoot

public final boolean isFocusCycleRoot()
Always returns true because all Windows must be roots of a focus traversal cycle.

Overrides:
isFocusCycleRoot in class Container
Returns:
true

isFocused

public boolean isFocused()
Returns whether this Window is focused. If there exists a focus owner, the focused Window is the Window that is, or contains, that focus owner. If there is no focus owner, then no Window is focused.

If the focused Window is a Frame or a Dialog it is also the active Window. Otherwise, the active Window is the first Frame or Dialog that is an owner of the focused Window.

Returns:
whether this is the focused Window.

isLocationByPlatform

public 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. This method always returns false if the Window is showing on the screen.

Returns:
whether this Window will appear at the default location

isShowing

public boolean isShowing()
Checks if this Window is showing on screen.

Overrides:
isShowing in class Component

pack

public void pack()
Causes this Window to be sized to fit the preferred size and layouts of its subcomponents. If the window and/or its owner are not yet displayable, both are made displayable before calculating the preferred size. The Window will be validated after the preferredSize is calculated.


postEvent

public boolean postEvent(Event e)
Overrides:
postEvent in class Component
Parameters:
e

processEvent

protected void processEvent(AWTEvent e)
Processes events on this window. If the event is an WindowEvent, it invokes the processWindowEvent method, else it invokes its superclass's processEvent.

Note that if the event parameter is null the behavior is unspecified and may result in an exception.

Overrides:
processEvent in class Container
Parameters:
e - the event

processWindowEvent

protected void processWindowEvent(WindowEvent e)
Processes window events occurring on this window by dispatching them to any registered WindowListener objects. NOTE: This method will not be called unless window events are enabled for this component; this happens when one of the following occurs:

Note that if the event parameter is null the behavior is unspecified and may result in an exception.

Parameters:
e - the window event

processWindowFocusEvent

protected void processWindowFocusEvent(WindowEvent e)
Processes window focus event occuring on this window by dispatching them to any registered WindowFocusListener objects. NOTE: this method will not be called unless window focus events are enabled for this window. This happens when one of the following occurs:

Note that if the event parameter is null the behavior is unspecified and may result in an exception.

Parameters:
e - the window focus event

processWindowStateEvent

protected void processWindowStateEvent(WindowEvent e)
Processes window state event occuring on this window by dispatching them to any registered WindowStateListener objects. NOTE: this method will not be called unless window state events are enabled for this window. This happens when one of the following occurs:

Note that if the event parameter is null the behavior is unspecified and may result in an exception.

Parameters:
e - the window state event

removeNotify

public void removeNotify()
{@inheritDoc}

Overrides:
removeNotify in class Container

removeWindowFocusListener

public synchronized void removeWindowFocusListener(WindowFocusListener l)
Removes the specified window focus listener so that it no longer receives window events from this window. If l is null, no exception is thrown and no action is performed.

Refer to AWT Threading Issues for details on AWT's threading model.

Parameters:
l - the window focus listener

removeWindowListener

public synchronized void removeWindowListener(WindowListener l)
Removes the specified window listener so that it no longer receives window events from this window. If l is null, no exception is thrown and no action is performed.

Refer to AWT Threading Issues for details on AWT's threading model.

Parameters:
l - the window listener

removeWindowStateListener

public synchronized void removeWindowStateListener(WindowStateListener l)
Removes the specified window state listener so that it no longer receives window events from this window. If l is null, no exception is thrown and no action is performed.

Refer to AWT Threading Issues for details on AWT's threading model.

Parameters:
l - the window state listener

reshape

public void reshape(int x,
                    int y,
                    int width,
                    int height)
Overrides:
reshape in class Component
Parameters:
x
y
width
height

setAlwaysOnTop

public final void setAlwaysOnTop(boolean alwaysOnTop)
                          throws SecurityException
Sets whether this window should always be above other windows. If there are multiple always-on-top windows, their relative order is unspecified and platform dependent.

If some other window is already always-on-top then the relative order between these windows is unspecified (depends on platform). No window can be brought to be over the always-on-top window except maybe another always-on-top window.

All windows owned by an always-on-top window inherit this state and automatically become always-on-top. If a window ceases to be always-on-top, the windows that it owns will no longer be always-on-top. When an always-on-top window is sent {@link #toBack toBack}, its always-on-top state is set to false.

When this method is called on a window with a value of true, and the window is visible and the platform supports always-on-top for this window, the window is immediately brought forward, "sticking" it in the top-most position. If the window isn`t currently visible, this method sets the always-on-top state to true but does not bring the window forward. When the window is later shown, it will be always-on-top.

When this method is called on a window with a value of false the always-on-top state is set to normal. The window remains in the top-most position but it`s z-order can be changed as for any other window. Calling this method with a value of false on a window that has a normal state has no effect. Setting the always-on-top state to false has no effect on the relative z-order of the windows if there are no other always-on-top windows.

Note: some platforms might not support always-on-top windows. To detect if always-on-top windows are supported by the current platform, use {@link Toolkit#isAlwaysOnTopSupported()} and {@link Window#isAlwaysOnTopSupported()}. If always-on-top mode isn't supported by the toolkit or for this window, calling this method has no effect.

If a SecurityManager is installed, the calling thread must be granted the AWTPermission "setWindowAlwaysOnTop" in order to set the value of this property. If this permission is not granted, this method will throw a SecurityException, and the current value of the property will be left unchanged.

Parameters:
alwaysOnTop - true if the window should always be above other windows
Throws:
SecurityException - if the calling thread does not have permission to set the value of always-on-top property

setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height)
{@inheritDoc}

The {@code width} or {@code height} values are automatically enlarged if either is less than the minimum size as specified by previous call to {@code setMinimumSize}.

Overrides:
setBounds in class Component
Parameters:
x
y
width
height

setBounds

public void setBounds(Rectangle r)
{@inheritDoc}

The {@code r.width} or {@code r.height} values will be automatically enlarged if either is less than the minimum size as specified by previous call to {@code setMinimumSize}.

Overrides:
setBounds in class Component
Parameters:
r

setCursor

public void setCursor(Cursor cursor)
Set the cursor image to a specified cursor.

The method may have no visual effect if the Java platform implementation and/or the native system do not support changing the mouse cursor shape.

Overrides:
setCursor in class Component
Parameters:
cursor - One of the constants defined by the Cursor class. If this parameter is null then the cursor for this window will be set to the type Cursor.DEFAULT_CURSOR.

setFocusableWindowState

public void setFocusableWindowState(boolean focusableWindowState)
Sets whether this Window can become the focused Window if it meets the other requirements outlined in isFocusableWindow. If this Window's focusable Window state is set to false, then isFocusableWindow will return false. If this Window's focusable Window state is set to true, then isFocusableWindow may return true or false depending upon the other requirements which must be met in order for a Window to be focusable.

Setting a Window's focusability state to false is the standard mechanism for an application to identify to the AWT a Window which will be used as a floating palette or toolbar, and thus should be a non-focusable Window. Setting the focusability state on a visible Window can have a delayed effect on some platforms — the actual change may happen only when the Window becomes hidden and then visible again. To ensure consistent behavior across platforms, set the Window's focusable state when the Window is invisible and then show it.

Parameters:
focusableWindowState - whether this Window can be the focused Window

setFocusCycleRoot

public final void setFocusCycleRoot(boolean focusCycleRoot)
Does nothing because Windows must always be roots of a focus traversal cycle. The passed-in value is ignored.

Overrides:
setFocusCycleRoot in class Container
Parameters:
focusCycleRoot - this value is ignored

setIconImage

public void setIconImage(Image image)
Sets the image to be displayed as the icon for this window.

This method can be used instead of {@link #setIconImages setIconImages()} to specify a single image as a window's icon.

The following statement:

     setIconImage(image);
 
is equivalent to:
     ArrayList imageList = new ArrayList();
     imageList.add(image);
     setIconImages(imageList);
 

Note : Native windowing systems may use different images of differing dimensions to represent a window, depending on the context (e.g. window decoration, window list, taskbar, etc.). They could also use just a single image for all contexts or no image at all.

Parameters:
image - the icon image to be displayed.

setIconImages

public synchronized void setIconImages(List icons)
Sets the sequence of images to be displayed as the icon for this window. Subsequent calls to {@code getIconImages} will always return a copy of the {@code icons} list.

Depending on the platform capabilities one or several images of different dimensions will be used as the window's icon.

The {@code icons} list is scanned for the images of most appropriate dimensions from the beginning. If the list contains several images of the same size, the first will be used.

Ownerless windows with no icon specified use platfrom-default icon. The icon of an owned window may be inherited from the owner unless explicitly overridden. Setting the icon to {@code null} or empty list restores the default behavior.

Note : Native windowing systems may use different images of differing dimensions to represent a window, depending on the context (e.g. window decoration, window list, taskbar, etc.). They could also use just a single image for all contexts or no image at all.

Parameters:
icons - the list of icon images to be displayed.

setLocationByPlatform

public void setLocationByPlatform(boolean locationByPlatform)
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. This behavior resembles a native window shown without programmatically setting its location. Most windowing systems cascade windows if their locations are not explicitly set. The actual location is determined once the window is shown on the screen.

This behavior can also be enabled by setting the System Property "java.awt.Window.locationByPlatform" to "true", though calls to this method take precedence.

Calls to setVisible, setLocation and setBounds after calling setLocationByPlatform clear this property of the Window.

For example, after the following code is executed:

setLocationByPlatform(true); setVisible(true); boolean flag = isLocationByPlatform();
The window will be shown at platform's default location and flag will be false.

In the following sample:

setLocationByPlatform(true); setLocation(10, 10); boolean flag = isLocationByPlatform(); setVisible(true);
The window will be shown at (10, 10) and flag will be false.

Parameters:
locationByPlatform - true if this Window should appear at the default location, false if at the current location

setLocationRelativeTo

public void setLocationRelativeTo(Component c)
Sets the location of the window relative to the specified component.

If the component is not currently showing, or c is null, the window is placed at the center of the screen. The center point can be determined with {@link GraphicsEnvironment#getCenterPoint GraphicsEnvironment.getCenterPoint}

If the bottom of the component is offscreen, the window is placed to the side of the Component that is closest to the center of the screen. So if the Component is on the right part of the screen, the Window is placed to its left, and visa versa.

Parameters:
c - the component in relation to which the window's location is determined

setMinimumSize

public void setMinimumSize(Dimension minimumSize)
Sets the minimum size of this window to a constant value. Subsequent calls to {@code getMinimumSize} will always return this value. If current window's size is less than {@code minimumSize} the size of the window is automatically enlarged to honor the minimum size.

If the {@code setSize} or {@code setBounds} methods are called afterwards with a width or height less than that specified by {@code setMinimumSize} the window is automatically enlarged to honor the {@code minimumSize} value. Setting the minimum size to {@code null} restores the default behavior.

Resizing operation may be restricted if the user tries to resize window below the {@code minimumSize} value. This behaviour is platform-dependent.

Overrides:
setMinimumSize in class Component
Parameters:
minimumSize - the new minimum size of this window

setModalExclusionType

public void setModalExclusionType(Dialog.ModalExclusionType exclusionType)
Specifies the modal exclusion type for this window. If a window is modal excluded, it is not blocked by some modal dialogs. See {@link java.awt.Dialog.ModalExclusionType Dialog.ModalExclusionType} for possible modal exclusion types.

If the given type is not supported, NO_EXCLUDE is used.

Note: changing the modal exclusion type for a visible window may have no effect until it is hidden and then shown again.

Parameters:
exclusionType - the modal exclusion type for this window; a null value is equivivalent to {@link Dialog.ModalExclusionType#NO_EXCLUDE NO_EXCLUDE}

setSize

public void setSize(Dimension d)
{@inheritDoc}

The {@code d.width} and {@code d.height} values are automatically enlarged if either is less than the minimum size as specified by previous call to {@code setMinimumSize}.

Overrides:
setSize in class Component
Parameters:
d

setSize

public void setSize(int width,
                    int height)
{@inheritDoc}

The {@code width} and {@code height} values are automatically enlarged if either is less than the minimum size as specified by previous call to {@code setMinimumSize}.

Overrides:
setSize in class Component
Parameters:
width
height

setVisible

public void setVisible(boolean b)
Shows or hides this {@code Window} depending on the value of parameter {@code b}.

Overrides:
setVisible in class Component
Parameters:
b - if {@code true}, makes the {@code Window} visible, otherwise hides the {@code Window}. If the {@code Window} and/or its owner are not yet displayable, both are made displayable. The {@code Window} will be validated prior to being made visible. If the {@code Window} is already visible, this will bring the {@code Window} to the front.

If {@code false}, hides this {@code Window}, its subcomponents, and all of its owned children. The {@code Window} and its subcomponents can be made visible again with a call to {@code #setVisible(true)}.


show

public void show()
Makes the Window visible. 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.

Overrides:
show in class Component

toBack

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.

Places this Window at the bottom of the stacking order and shows it behind any other Windows in this VM. No action will take place is this Window is not visible. Some platforms do not allow Windows which are owned by other Windows to appear below their owners. Every attempt will be made to move this Window as low as possible in the stacking order; however, developers should not assume that this method will move this Window below all other windows in every situation.

Because of variations in native windowing systems, no guarantees about changes to the focused and active Windows can be made. Developers must never assume that this Window is no longer the focused or active Window until this Window receives a WINDOW_LOST_FOCUS or WINDOW_DEACTIVATED event. On platforms where the top-most window is the focused window, this method will probably cause this Window to lose focus. In that case, the next highest, focusable Window in this VM will receive focus. On platforms where the stacking order does not typically affect the focused window, this method will probably leave the focused and active Windows unchanged.


toFront

public void toFront()
If this Window is visible, brings this Window to the front and may make it the focused Window.

Places this Window at the top of the stacking order and shows it in front of any other Windows in this VM. No action will take place if this Window is not visible. Some platforms do not allow Windows which own other Windows to appear on top of those owned Windows. Some platforms may not permit this VM to place its Windows above windows of native applications, or Windows of other VMs. This permission may depend on whether a Window in this VM is already focused. Every attempt will be made to move this Window as high as possible in the stacking order; however, developers should not assume that this method will move this Window above all other windows in every situation.

Because of variations in native windowing systems, no guarantees about changes to the focused and active Windows can be made. Developers must never assume that this Window is the focused or active Window until this Window receives a WINDOW_GAINED_FOCUS or WINDOW_ACTIVATED event. On platforms where the top-most window is the focused window, this method will probably focus this Window, if it is not already focused. On platforms where the stacking order does not typically affect the focused window, this method will probably leave the focused and active Windows unchanged.

If this method causes this Window to be focused, and this Window is a Frame or a Dialog, it will also become activated. If this Window is focused, but it is not a Frame or a Dialog, then the first Frame or Dialog that is an owner of this Window will be activated.

If this window is blocked by modal dialog, then the blocking dialog is brought to the front and remains above the blocked window.



This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.
This page displays the Jadeite version of the documention, which is derived from the offical documentation that contains this copyright notice:
Copyright 2008 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
The official Sun™ documentation can be found here at http://java.sun.com/javase/6/docs/api/.