Please note that this documentation is not final and is subject to change.

Java™ Platform
Standard Ed. 7

DRAFT ea-b36

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:
ImageObserver, MenuContainer, 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 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 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.

Since:
JDK1.0
See Also:
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, 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
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
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.
Window(Window owner, GraphicsConfiguration gc)
          Constructs a new, initially invisible window with the specified owner Window 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(PropertyChangeListener listener)
          Adds a PropertyChangeListener to the listener list.
 void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
          Adds a PropertyChangeListener to the listener list for a specific property.
 void addWindowFocusListener(WindowFocusListener l)
          Adds the specified window focus listener to receive window events from this window.
 void addWindowListener(WindowListener l)
          Adds the specified window listener to receive window events from this window.
 void addWindowStateListener(WindowStateListener l)
          Adds the specified window state listener to receive window events from this window.
 void applyResourceBundle(ResourceBundle rb)
          Deprecated. As of J2SE 1.4, replaced by Component.applyComponentOrientation.
 void applyResourceBundle(String rbName)
          Deprecated. As of J2SE 1.4, replaced by Component.applyComponentOrientation.
 void createBufferStrategy(int numBuffers)
          Creates a new strategy for multi-buffering on this component.
 void createBufferStrategy(int numBuffers, BufferCapabilities caps)
          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.
 AccessibleContext getAccessibleContext()
          Gets the AccessibleContext associated with this Window.
 BufferStrategy getBufferStrategy()
          Returns the BufferStrategy used by this component.
 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<AWTKeyStroke> getFocusTraversalKeys(int id)
          Gets a focus traversal key for this Window.
 GraphicsConfiguration getGraphicsConfiguration()
          This method returns the GraphicsConfiguration used by this Window.
 List<Image> getIconImages()
          Returns the sequence of images to be displayed as the icon for this window.
 InputContext getInputContext()
          Gets the input context for this window.
<T extends EventListener>
T[]
getListeners(Class<T> listenerType)
          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.
 Dialog.ModalExclusionType getModalExclusionType()
          Returns the modal exclusion type of this window.
 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.
static Window[] getOwnerlessWindows()
          Returns an array of all Windows created by this application that have no owner.
 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.
static Window[] getWindows()
          Returns an array of all Windows, both owned and ownerless, created by this application.
 WindowStateListener[] getWindowStateListeners()
          Returns an array of all the window state listeners registered on this window.
 void hide()
          Deprecated. As of JDK version 1.5, replaced by setVisible(boolean).
 boolean isActive()
          Returns whether this Window is active.
 boolean isAlwaysOnTop()
          Returns whether this window is an always-on-top window.
 boolean isAlwaysOnTopSupported()
          Returns whether the always-on-top mode is supported for this window.
 boolean isAutoRequestFocus()
          Returns whether this window should receive focus on subsequently being shown (with a call to setVisible(true)), or being moved to the front (with a call to toFront()).
 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(Event e)
          Deprecated. As of JDK version 1.1 replaced by dispatchEvent(AWTEvent).
protected  void processEvent(AWTEvent e)
          Processes events on this window.
protected  void processWindowEvent(WindowEvent e)
          Processes window events occurring on this window by dispatching them to any registered WindowListener objects.
protected  void processWindowFocusEvent(WindowEvent e)
          Processes window focus event occuring on this window by dispatching them to any registered WindowFocusListener objects.
protected  void processWindowStateEvent(WindowEvent e)
          Processes window state event occuring on this window by dispatching them to any registered WindowStateListener objects.
 void removeNotify()
          Makes this Container undisplayable by removing its connection to its native screen resource.
 void removeWindowFocusListener(WindowFocusListener l)
          Removes the specified window focus listener so that it no longer receives window events from this window.
 void removeWindowListener(WindowListener l)
          Removes the specified window listener so that it no longer receives window events from this window.
 void removeWindowStateListener(WindowStateListener l)
          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)
          Deprecated. As of JDK version 1.1, replaced by setBounds(int, int, int, int).
 void setAlwaysOnTop(boolean alwaysOnTop)
          Sets whether this window should always be above other windows.
 void setAutoRequestFocus(boolean autoRequestFocus)
          Sets whether this window should receive focus on subsequently being shown (with a call to setVisible(true)), or being moved to the front (with a call to toFront()).
 void setBounds(int x, int y, int width, int height)
          Moves and resizes this component.
 void setBounds(Rectangle r)
          Moves and resizes this component to conform to the new bounding rectangle r.
 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 setIconImage(Image image)
          Sets the image to be displayed as the icon for this window.
 void setIconImages(List<? extends Image> icons)
          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 setLocationRelativeTo(Component c)
          Sets the location of the window relative to the specified component according to the following scenarios.
 void setMinimumSize(Dimension minimumSize)
          Sets the minimum size of this window to a constant value.
 void setModalExclusionType(Dialog.ModalExclusionType exclusionType)
          Specifies the modal exclusion type for this window.
 void setSize(Dimension d)
          Resizes this component so that it has width d.width and height d.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 Window depending on the value of parameter b.
 void show()
          Deprecated. As of JDK version 1.5, replaced by 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, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusDownCycle, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, 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
Throws:
IllegalArgumentException - if the owner's GraphicsConfiguration is not from a screen device
HeadlessException - when GraphicsEnvironment.isHeadless returns true
See Also:
GraphicsEnvironment.isHeadless(), SecurityManager.checkTopLevelWindow(java.lang.Object), isShowing()

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
Throws:
IllegalArgumentException - if the owner's GraphicsConfiguration is not from a screen device
HeadlessException - when GraphicsEnvironment.isHeadless() returns true
Since:
1.2
See Also:
GraphicsEnvironment.isHeadless(), SecurityManager.checkTopLevelWindow(java.lang.Object), isShowing()

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
Throws:
IllegalArgumentException - if gc is not from a screen device
HeadlessException - when GraphicsEnvironment.isHeadless() returns true
Since:
1.3
See Also:
GraphicsEnvironment.isHeadless(), SecurityManager.checkTopLevelWindow(java.lang.Object), GraphicsConfiguration.getBounds(), isShowing()
Method Detail

getIconImages

public List<Image> 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.
Since:
1.6
See Also:
setIconImages(java.util.List), setIconImage(Image)

setIconImages

public void setIconImages(List<? extends Image> icons)
Sets the sequence of images to be displayed as the icon for this window. Subsequent calls to getIconImages will always return a copy of the icons list.

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

The 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 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.
Since:
1.6
See Also:
getIconImages(), setIconImage(Image)

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 setIconImages() to specify a single image as a window's icon.

The following statement:

     setIconImage(image);
 
is equivalent to:
     ArrayList<Image> imageList = new ArrayList<Image>();
     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.
Since:
1.6
See Also:
setIconImages(java.util.List), getIconImages()

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
Since:
JDK1.0
See Also:
Component.isDisplayable(), Container.removeNotify()

removeNotify

public void removeNotify()
Makes this Container undisplayable by removing its connection to its native screen resource. Making a container undisplayable will cause all of its children to be made undisplayable. This method is called by the toolkit internally and should not be called directly by programs.

Overrides:
removeNotify in class Container
See Also:
Component.isDisplayable(), Container.addNotify()

pack

public void pack()
Causes this Window to be sized to fit the preferred size and layouts of its subcomponents. The resulting width and height of the window are automatically enlarged if either of dimensions is less than the minimum size as specified by the previous call to the setMinimumSize method.

If the window and/or its owner are not displayable yet, both of them are made displayable before calculating the preferred size. The Window is validated after its size is being calculated.

See Also:
Component.isDisplayable(), setMinimumSize(java.awt.Dimension)

setMinimumSize

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

If the setSize or setBounds methods are called afterwards with a width or height less than that was specified by the setMinimumSize method the window is automatically enlarged to meet the minimumSize value. The minimumSize value also affects the behaviour of the pack method.

The default behavior is restored by setting the minimum size parameter to the null value.

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

Overrides:
setMinimumSize in class Component
Parameters:
minimumSize - the new minimum size of this window
Since:
1.6
See Also:
Component.setMinimumSize(java.awt.Dimension), Container.getMinimumSize(), Component.isMinimumSizeSet(), setSize(Dimension), pack()

setSize

public void setSize(Dimension d)
Resizes this component so that it has width d.width and height d.height.

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

Overrides:
setSize in class Component
Parameters:
d - the dimension specifying the new size of this component
Since:
1.6
See Also:
Component.getSize(), setBounds(int, int, int, int), setMinimumSize(java.awt.Dimension)

setSize

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

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

Overrides:
setSize in class Component
Parameters:
width - the new width of this component in pixels
height - the new height of this component in pixels
Since:
1.6
See Also:
Component.getSize(), setBounds(int, int, int, int), setMinimumSize(java.awt.Dimension)

reshape

@Deprecated
public void reshape(int x,
                               int y,
                               int width,
                               int height)
Deprecated. As of JDK version 1.1, replaced by setBounds(int, int, int, int).

Overrides:
reshape in class Component

setVisible

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

If the method shows the window then the window is also made focused under the following conditions:

There is an exception for the second condition (the value of the autoRequestFocus property). The property is not taken into account if the window is a modal dialog, which blocks the currently focused window.

Developers must never assume that the window is the focused or active window until it receives a WINDOW_GAINED_FOCUS or WINDOW_ACTIVATED event.

Overrides:
setVisible in class Component
Parameters:
b - if 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 false, hides this Window, its subcomponents, and all of its owned children. The Window and its subcomponents can be made visible again with a call to #setVisible(true).

See Also:
Component.isDisplayable(), Component.setVisible(boolean), toFront(), dispose(), setAutoRequestFocus(boolean), isFocusableWindow()

show

@Deprecated
public void show()
Deprecated. As of JDK version 1.5, replaced by setVisible(boolean).

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
See Also:
Component.isDisplayable(), toFront()

hide

@Deprecated
public void hide()
Deprecated. As of JDK version 1.5, replaced by setVisible(boolean).

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

Overrides:
hide in class Component
See Also:
show(), dispose()

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.

See Also:
Component.isDisplayable(), pack(), show()

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.

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) under the following conditions:

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.

See Also:
toBack(), setAutoRequestFocus(boolean), isFocusableWindow()

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.

See Also:
toFront()

getToolkit

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

Overrides:
getToolkit in class Component
Returns:
the toolkit of this window.
See Also:
Toolkit, Toolkit.getDefaultToolkit(), Component.getToolkit()

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.
See Also:
SecurityManager.checkTopLevelWindow(java.lang.Object)

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.
Since:
JDK1.1
See Also:
Locale

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
Returns:
the input context used by this component; null if no context can be determined
Since:
1.2
See Also:
Component.getInputContext()

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.
Since:
JDK1.1
See Also:
Component.getCursor(), Cursor

getOwner

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

Since:
1.2

getOwnedWindows

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

Since:
1.2

getWindows

public static Window[] getWindows()
Returns an array of all Windows, both owned and ownerless, created by this application. If called from an applet, the array includes only the Windows 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.

Since:
1.6
See Also:
Frame.getFrames(), getOwnerlessWindows()

getOwnerlessWindows

public static Window[] getOwnerlessWindows()
Returns an array of all Windows created by this application that have no owner. They include Frames and ownerless Dialogs and Windows. If called from an applet, the array includes only the Windows 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.

Since:
1.6
See Also:
Frame.getFrames(), getWindows()

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 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 NO_EXCLUDE
Throws:
SecurityException - if the calling thread does not have permission to set the modal exclusion property to the window with the given exclusionType
Since:
1.6
See Also:
Dialog.ModalExclusionType, getModalExclusionType(), Toolkit.isModalExclusionTypeSupported(java.awt.Dialog.ModalExclusionType)

getModalExclusionType

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

Returns:
the modal exclusion type of this window
Since:
1.6
See Also:
Dialog.ModalExclusionType, setModalExclusionType(java.awt.Dialog.ModalExclusionType)

addWindowListener

public 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
See Also:
removeWindowListener(java.awt.event.WindowListener), getWindowListeners()

addWindowStateListener

public 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
Since:
1.4
See Also:
removeWindowStateListener(java.awt.event.WindowStateListener), getWindowStateListeners()

addWindowFocusListener

public 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
Since:
1.4
See Also:
removeWindowFocusListener(java.awt.event.WindowFocusListener), getWindowFocusListeners()

removeWindowListener

public 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
See Also:
addWindowListener(java.awt.event.WindowListener), getWindowListeners()

removeWindowStateListener

public 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
Since:
1.4
See Also:
addWindowStateListener(java.awt.event.WindowStateListener), getWindowStateListeners()

removeWindowFocusListener

public 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
Since:
1.4
See Also:
addWindowFocusListener(java.awt.event.WindowFocusListener), getWindowFocusListeners()

getWindowListeners

public 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
Since:
1.4
See Also:
addWindowListener(java.awt.event.WindowListener), removeWindowListener(java.awt.event.WindowListener)

getWindowFocusListeners

public 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
Since:
1.4
See Also:
addWindowFocusListener(java.awt.event.WindowFocusListener), removeWindowFocusListener(java.awt.event.WindowFocusListener)

getWindowStateListeners

public 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
Since:
1.4
See Also:
addWindowStateListener(java.awt.event.WindowStateListener), removeWindowStateListener(java.awt.event.WindowStateListener)

getListeners

public <T extends EventListener> T[] getListeners(Class<T> 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
Throws:
ClassCastException - if listenerType doesn't specify a class or interface that implements java.util.EventListener
Since:
1.3
See Also:
getWindowListeners()

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
See Also:
Component.processComponentEvent(java.awt.event.ComponentEvent), Component.processFocusEvent(java.awt.event.FocusEvent), Component.processKeyEvent(java.awt.event.KeyEvent),