java.awt
Class Window

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Window
All Implemented Interfaces:
Accessible, ImageObserver, MenuContainer, Serializable
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.

In such an environment, when calling setLocation, 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);
 

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 inherited from class java.awt.Container
 
Nested classes inherited from class java.awt.Component
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 invisible window with the specified Frame as its owner.
Window(Window owner)
    Constructs a new invisible window with the specified Window as its owner.
Window(Window owner, GraphicsConfiguration gc)
    Constructs a new invisible window with the specified window as its owner and a GraphicsConfiguration of a screen device.
 

 

Method Summary

 void addNotify()
    Makes this Window displayable by creating the connection to its native screen resource.
 void addPropertyChangeListener(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.
protected  void finalize()
    Disposes of the input methods and context, and removes the WeakReference which formerly pointed to this Window from the parent's owned Window list.
 AccessibleContext getAccessibleContext()
    Gets the AccessibleContext associated with this Window.
 BufferStrategy getBufferStrategy()
    
 boolean getFocusableWindowState()
    Returns whether this Window can become the focused Window if it meets the other requirements outlined in isFocusableWindow.
 Container getFocusCycleRootAncestor()
    Always returns null because Windows have no ancestors; they represent the top of the Component hierarchy.
 Component getFocusOwner()
    Returns the child Component of this Window that has focus if this Window is focused; returns null otherwise.
 Set getFocusTraversalKeys(int id)
    Gets a focus traversal key for this Window.
 GraphicsConfiguration getGraphicsConfiguration()
    This method returns the GraphicsConfiguration used by this Window.
 InputContext getInputContext()
    Gets the input context for this window.
 EventListener[] getListeners(Class 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.
 Component getMostRecentFocusOwner()
    Returns the child Component of this Window that will receive the focus when this Window is focused.
 Window[] getOwnedWindows()
    Return an array containing all the windows this window currently owns.
 Window getOwner()
    Returns the owner of this window.
 Toolkit getToolkit()
    Returns the toolkit of this frame.
 String getWarningString()
    Gets the warning string that is displayed with this window.
 WindowFocusListener[] getWindowFocusListeners()
    Returns an array of all the window focus listeners registered on this window.
 WindowListener[] getWindowListeners()
    Returns an array of all the window listeners registered on this window.
 WindowStateListener[] getWindowStateListeners()
    Returns an array of all the window state listeners registered on this window.
 void hide()
    Hide this Window, its subcomponents, and all of its owned children.
 boolean isActive()
    Returns whether this Window is active.
 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 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 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 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 setLocationRelativeTo(Component c)
    Sets the location of the window relative to the specified component.
 void show()
    Makes the Window visible.
 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, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents,