java.awt
Class Window

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

public class Window
extends Container
implements javax.accessibility.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);
 

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

Since:
JDK1.0
Author:
Sami Shaio, Arthur van Hoff
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
Container.AccessibleAWTContainer, Container.DropTargetEventTargetFilter, Container.EventTargetFilter, Container.MouseEventTargetFilter
 
Nested classes inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.AWTTreeLock, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
private static String base
           
(package private)  boolean beforeFirstShow
           
private static sun.awt.DebugHelper dbg
           
private  boolean focusableWindowState
          Indicates whether this Window can become the focused Window.
private  FocusManager focusMgr
          Unused.
(package private)  InputContext inputContext
           
private  Object inputContextLock
           
private static int nameCounter
           
(package private) static int OPENED
           
(package private)  Vector ownedWindowList
          A vector containing all the windows this window currently owns.
private static long serialVersionUID
           
private  boolean showWithParent
           
(package private)  int state
          An Integer value representing the Window State.
(package private)  boolean syncLWRequests
           
(package private) static boolean systemSyncLWRequests
           
private  Component temporaryLostComponent
          Holds the reference to the component which last had focus in this window before it lost focus.
(package private)  String warningString
          This represents the warning message that is to be displayed in a non secure window. ie : a window that has a security manager installed for which calling SecurityManager.checkTopLevelWindow() is false.
private  WeakReference weakThis
           
(package private)  WindowFocusListener windowFocusListener
           
(package private)  WindowListener windowListener
           
private  int windowSerializedDataVersion
          The window serialized data version.
(package private)  WindowStateListener windowStateListener
           
 
Fields inherited from class java.awt.Container
component, containerListener, descendantsCount, INCLUDE_SELF, layoutMgr, listeningBoundsChildren, listeningChildren, ncomponents, SEARCH_HEAVYWEIGHTS
 
Fields inherited from class java.awt.Component
accessibleContext, actionListenerK, adjustmentListenerK, appContext, background, BOTTOM_ALIGNMENT, bufferStrategy, CENTER_ALIGNMENT, componentListener, componentListenerK, componentOrientation, containerListenerK, cursor, dropTarget, enabled, eventMask, focusListener, focusListenerK, focusTraversalKeys, font, foreground, graphicsConfig, height, hierarchyBoundsListener, hierarchyBoundsListenerK, hierarchyListener, hierarchyListenerK, ignoreRepaint, incRate, inputMethodListener, inputMethodListenerK, isInc, isPacked, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, metrics, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, mouseWheelListener, mouseWheelListenerK, newEventsOnly, ownedWindowK, parent, peer, peerFont, popups, prefSize, RIGHT_ALIGNMENT, textListenerK, TOP_ALIGNMENT, valid, visible, width, windowClosingException, windowFocusListenerK, windowListenerK, windowStateListenerK, x, y
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
(package private) Window()
          Constructs a new window in the default size.
  Window(Frame owner)
          Constructs a new invisible window with the specified Frame as its owner.
(package private) Window(GraphicsConfiguration gc)
          Constructs a new window in default size with the specified GraphicsConfiguration.
  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.
(package private)  void addOwnedWindow(WeakReference weakWindow)
           
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Adds a PropertyChangeListener to the listener list.
 void addPropertyChangeListener(String propertyName, java.beans.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.
(package private)  void adjustDecendantsOnParent(int num)
           
(package private)  void adjustListeningChildrenOnParent(long mask, int num)
           
 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.
(package private)  void clearMostRecentFocusOwnerOnHide()
           
(package private)  void connectOwnedWindow(Window child)
           
(package private)  String constructComponentName()
          Construct a name for this component.
 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.
(package private)  void deliverMouseWheelToAncestor(MouseWheelEvent e)
          Overridden from Component.
(package private)  void dispatchEventImpl(AWTEvent e)
          Dispatches an event to this window or one of its sub components.
(package private)  boolean dispatchMouseWheelToAncestor(MouseWheelEvent e)
          Overridden from Component.
 void dispose()
          Releases all of the native screen resources used by this Window, its subcomponents, and all of its owned children.
(package private)  boolean eventEnabled(AWTEvent e)
           
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.
 javax.accessibility.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.
(package private)  Component getTemporaryLostComponent()
           
 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.
private  void init(GraphicsConfiguration gc)
           
private static void initIDs()
          Initialize JNI field and method IDs for fields that may be accessed from C.
 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.
private  void ownedInit(Window owner)
           
 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).
(package private)  void postProcessKeyEvent(KeyEvent e)
           
(package private)  void postWindowEvent(int id)
           
(package private)  void preProcessKeyEvent(KeyEvent e)
          Implements a debugging hook -- checks to see if the user has typed control-shift-F1.
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.
private  void readObject(ObjectInputStream s)
          Reads the ObjectInputStream and an optional list of listeners to receive various events fired by the component; also reads a list of (possibly null) child windows.
(package private)  void removeOwnedWindow(WeakReference weakWindow)
           
 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.
(package private)  void resetGC()
          Reset this Window's GraphicsConfiguration to match its peer.
 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.
(package private)  Component setTemporaryLostComponent(Component component)
           
private  void setWarningString()
           
 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.
private  void writeObject(ObjectOutputStream s)
          Writes default serializable fields to stream.
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, adjustDescendants, adjustListeningChildren, applyComponentOrientation, areFocusTraversalKeysSet, checkGD, clearCurrentFocusCycleRootOnHide, containsFocus, countComponents, countHierarchyMembers, createChildHierarchyEvents, createHierarchyEvents, deliverEvent, dispatchEventToSelf, doLayout, findComponentAt, findComponentAt, findComponentAt, getAccessibleAt, getAccessibleChild, getAccessibleChildrenCount, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents_NoClientCode, getComponents, getContainerListeners, getDropTargetEventTarget, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMouseEventTarget, getPreferredSize, initializeFocusTraversalKeys, insets, invalidate, invalidateTree, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicySet, isParentOf, layout, lightweightPaint, lightweightPrint, list, list, locate, minimumSize, nextFocusHelper, numListening, paint, paintComponents, paintHeavyweightComponents, paramString, postsOldMouseEvents, preferredSize, print, printComponents, printHeavyweightComponents, processContainerEvent, proxyEnableEvents, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, setLayout, setZOrder, transferFocusBackward, transferFocusDownCycle, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, areInputMethodsEnabled, autoProcessMouseWheel, autoTransferFocus, bounds, checkImage, checkImage, checkWindowClosingException, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, eventTypeEnabled, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleIndexInParent, getAccessibleStateSet, getBackBuffer, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeys_NoIDCheck, getFocusTraversalKeysEnabled, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen_NoTreeLock, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkitImpl, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isEnabledImpl, isFocusable, isFocusOwner, isFocusTraversable, isFocusTraversableOverridden, isFontSet, isForegroundSet, isLightweight, isOpaque, isRecursivelyVisible, 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, requestFocusHelper, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys_NoIDCheck, setFocusTraversalKeysEnabled, setForeground, setGCFromPeer, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle, updateCursorImmediately
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

warningString

String warningString
This represents the warning message that is to be displayed in a non secure window. ie : a window that has a security manager installed for which calling SecurityManager.checkTopLevelWindow() is false. This message can be displayed anywhere in the window.

See Also:
getWarningString()

temporaryLostComponent

private transient Component temporaryLostComponent
Holds the reference to the component which last had focus in this window before it lost focus.


systemSyncLWRequests

static boolean systemSyncLWRequests

syncLWRequests

boolean syncLWRequests

beforeFirstShow

transient boolean beforeFirstShow

OPENED

static final int OPENED
See Also:
Constant Field Values

state

int state
An Integer value representing the Window State.

Since:
1.2
See Also:
show()

ownedWindowList

transient Vector ownedWindowList
A vector containing all the windows this window currently owns.

Since:
1.2
See Also:
getOwnedWindows()

weakThis

private transient WeakReference weakThis

showWithParent

private transient boolean showWithParent

windowListener

transient WindowListener windowListener

windowStateListener

transient WindowStateListener windowStateListener

windowFocusListener

transient WindowFocusListener windowFocusListener

inputContext

transient InputContext inputContext

inputContextLock

private transient Object inputContextLock

focusMgr

private FocusManager focusMgr
Unused. Maintained for serialization backward-compatibility.

Since:
1.2

focusableWindowState

private boolean focusableWindowState
Indicates whether this Window can become the focused Window.

Since:
1.4
See Also:
getFocusableWindowState(), setFocusableWindowState(boolean)

base

private static final String base
See Also:
Constant Field Values

nameCounter

private static int nameCounter

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

dbg

private static final sun.awt.DebugHelper dbg

windowSerializedDataVersion

private int windowSerializedDataVersion
The window serialized data version.

Constructor Detail

Window

Window(GraphicsConfiguration gc)
Constructs a new window in default size with the specified GraphicsConfiguration.

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:
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. This exception is always thrown when GraphicsEnvironment.isHeadless() returns true.
See Also:
GraphicsEnvironment.isHeadless(), SecurityManager.checkTopLevelWindow(java.lang.Object)

Window

Window()
 throws HeadlessException
Constructs a new window in the default size.

First, if there is a security manager, its checkTopLevelWindow method is called with this as its argument to see if it's ok to display the window without a warning banner. If the default implementation of checkTopLevelWindow is used (that is, that method is not overriden), then this results in a call to the security manager's checkPermission method with an AWTPermission("showWindowWithoutWarningBanner") permission. It that method raises a SecurityException, checkTopLevelWindow returns false, otherwise it returns true. If it returns false, a warning banner is created.

Throws:
HeadlessException - if GraphicsEnvironment.isHeadless() returns true
See Also:
GraphicsEnvironment.isHeadless(), SecurityManager.checkTopLevelWindow(java.lang.Object)

Window

public Window(Frame owner)
Constructs a new 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
Throws:
IllegalArgumentException - if the owner's GraphicsConfiguration is not from a screen device
IllegalArgumentException - if owner is null; this exception is always thrown when GraphicsEnvironment.isHeadless returns true
See Also:
GraphicsEnvironment.isHeadless(), SecurityManager.checkTopLevelWindow(java.lang.Object), isShowing()

Window

public Window(Window owner)
Constructs a new invisible window with the specified Window as its owner. 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
Throws:
IllegalArgumentException - if the owner's GraphicsConfiguration is not from a screen device
IllegalArgumentException - if owner is null. This exception is always thrown 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 invisible window with the specified window as its owner 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
gc - the GraphicsConfiguration of the target screen device; if gc is null, the system default GraphicsConfiguration is assumed
Throws:
IllegalArgumentException - if owner is null
IllegalArgumentException - if gc is not from a screen device; this exception is always thrown when GraphicsEnvironment.isHeadless returns true
Since:
1.3
See Also:
GraphicsEnvironment.isHeadless(), SecurityManager.checkTopLevelWindow(java.lang.Object), GraphicsConfiguration.getBounds(), isShowing()
Method Detail

initIDs

private static void initIDs()
Initialize JNI field and method IDs for fields that may be accessed from C.


init

private void init(GraphicsConfiguration gc)

ownedInit

private void ownedInit(Window owner)

finalize

protected void finalize()
                 throws Throwable
Disposes of the input methods and context, and removes the WeakReference which formerly pointed to this Window from the parent's owned Window list.

Overrides:
finalize in class Object
Throws:
Throwable - the Exception raised by this method

constructComponentName

String constructComponentName()
Construct a name for this component. Called by getName() when the name is null.

Overrides:
constructComponentName in class Component

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()

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.

See Also:
Component.isDisplayable()

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

postWindowEvent

void postWindowEvent(int id)

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

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

clearMostRecentFocusOwnerOnHide

final void clearMostRecentFocusOwnerOnHide()
Overrides:
clearMostRecentFocusOwnerOnHide in class Container

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()

adjustListeningChildrenOnParent

void adjustListeningChildrenOnParent(long mask,
                                     int num)
Overrides:
adjustListeningChildrenOnParent in class Component

adjustDecendantsOnParent

void adjustDecendantsOnParent(int num)
Overrides:
adjustDecendantsOnParent in class Container

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.

See Also:
toBack()

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)

setWarningString

private void setWarningString()

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.

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

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.

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.

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.

Parameters:
l - the window focus listener
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.

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.

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.

Parameters:
l - the window focus listener
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 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
Throws:
ClassCastException - if listenerType doesn't specify a class or interface that implements java.util.EventListener
Since:
1.3
See Also:
getWindowListeners()

eventEnabled

boolean eventEnabled(AWTEvent e)
Overrides:
eventEnabled in class Container

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
See Also:
Component.enableEvents(long)

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
See Also:
Component.enableEvents(long)

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
Since:
1.4
See Also:
Component.enableEvents(long)

preProcessKeyEvent

void preProcessKeyEvent(KeyEvent e)
Implements a debugging hook -- checks to see if the user has typed control-shift-F1. If so, the list of child windows is dumped to System.out.

Overrides:
preProcessKeyEvent in class Container
Parameters:
e - the keyboard event

postProcessKeyEvent

void postProcessKeyEvent(KeyEvent e)
Overrides:
postProcessKeyEvent in class Container

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
See Also:
getMostRecentFocusOwner(), isFocused()

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
Since:
1.4
See Also:
getFocusOwner(), isFocused(), isFocusableWindow()

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.
Since:
1.4
See Also:
isFocused()

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.
Since:
1.4
See Also:
isActive()

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
Throws:
IllegalArgumentException - if id is not one of KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, or KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS
Since:
1.4
See Also:
Container.setFocusTraversalKeys(int, java.util.Set), KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS

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
Since:
1.4
See Also:
isFocusCycleRoot(), Container.setFocusTraversalPolicy(java.awt.FocusTraversalPolicy), Container.getFocusTraversalPolicy()

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
Since:
1.4
See Also:
setFocusCycleRoot(boolean), Container.setFocusTraversalPolicy(java.awt.FocusTraversalPolicy), Container.getFocusTraversalPolicy()

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
Since:
1.4
See Also:
Container.isFocusCycleRoot()

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
Since:
1.4
See Also:
getFocusableWindowState(), setFocusableWindowState(boolean), isShowing(), Component.isFocusable()

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
Since:
1.4
See Also:
isFocusableWindow(), setFocusableWindowState(boolean), isShowing(), Component.setFocusable(boolean)

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.

Parameters:
focusableWindowState - whether this Window can be the focused Window
Since:
1.4
See Also:
isFocusableWindow(), getFocusableWindowState(), isShowing(), Component.setFocusable(boolean)

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.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
See Also:
Component.removePropertyChangeListener(java.beans.PropertyChangeListener), addPropertyChangeListener(java.lang.String,java.beans.PropertyChangeListener)

addPropertyChangeListener

public void addPropertyChangeListener(String propertyName,
                                      java.beans.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
See Also:
addPropertyChangeListener(java.beans.PropertyChangeListener), Component.removePropertyChangeListener(java.beans.PropertyChangeListener)

dispatchEventImpl

void dispatchEventImpl(AWTEvent e)
Dispatches an event to this window or one of its sub components.

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

postEvent

public boolean postEvent(Event e)
Deprecated. As of JDK version 1.1 replaced by dispatchEvent(AWTEvent).

Specified by:
postEvent in interface MenuContainer
Overrides:
postEvent in class Component

isShowing

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

Overrides:
isShowing in class Component
Returns:
true if the component is showing, false otherwise
See Also:
Component.setVisible(boolean)

applyResourceBundle

public void applyResourceBundle(ResourceBundle rb)
Deprecated. As of J2SE 1.4, replaced by Component.applyComponentOrientation.

Applies the ResourceBundle's ComponentOrientation to this Window and all components contained within it.

Since:
1.2
See Also:
ComponentOrientation

applyResourceBundle

public void applyResourceBundle(String rbName)
Deprecated. As of J2SE 1.4, replaced by Component.applyComponentOrientation.

Loads the ResourceBundle with the given name using the default locale and applies its ComponentOrientation to this Window and all components contained within it.

Since:
1.2
See Also:
ComponentOrientation

addOwnedWindow

void addOwnedWindow(WeakReference weakWindow)

removeOwnedWindow

void removeOwnedWindow(WeakReference weakWindow)

connectOwnedWindow

void connectOwnedWindow(Window child)

writeObject

private void writeObject(ObjectOutputStream s)
                  throws IOException
Writes default serializable fields to stream. Writes a list of serializable WindowListeners and WindowFocusListeners as optional data. Writes a list of child windows as optional data.

Parameters:
s - the ObjectOutputStream to write
Throws:
IOException
See Also:
AWTEventMulticaster.save(java.io.ObjectOutputStream, java.lang.String, java.util.EventListener), Component.windowListenerK, Component.windowFocusListenerK, Component.ownedWindowK, readObject(ObjectInputStream)

readObject

private void readObject(ObjectInputStream s)
                 throws ClassNotFoundException,
                        IOException,
                        HeadlessException
Reads the ObjectInputStream and an optional list of listeners to receive various events fired by the component; also reads a list of (possibly null) child windows. Unrecognized keys or values will be ignored.

Parameters:
s - the ObjectInputStream to read
Throws:
HeadlessException - if GraphicsEnvironment.isHeadless returns true
ClassNotFoundException
IOException
See Also:
GraphicsEnvironment.isHeadless(), writeObject(java.io.ObjectOutputStream)

getAccessibleContext

public javax.accessibility.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.

Specified by:
getAccessibleContext in interface javax.accessibility.Accessible
Overrides:
getAccessibleContext in class Component
Returns:
an AccessibleAWTWindow that serves as the AccessibleContext of this Window

getGraphicsConfiguration

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

Overrides:
getGraphicsConfiguration in class Component
Returns:
the GraphicsConfiguration used by this Component or null

resetGC

void resetGC()
Reset this Window's GraphicsConfiguration to match its peer.

Overrides:
resetGC in class Component

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 centered on the screen. 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
Since:
1.4

deliverMouseWheelToAncestor

void deliverMouseWheelToAncestor(MouseWheelEvent e)
Overridden from Component. Top-level Windows should not propagate a MouseWheelEvent beyond themselves into their owning Windows.


dispatchMouseWheelToAncestor

boolean dispatchMouseWheelToAncestor(MouseWheelEvent e)
Overridden from Component. Top-level Windows don't dispatch to ancestors

Overrides:
dispatchMouseWheelToAncestor in class Component

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
Throws:
IllegalArgumentException - if numBuffers is less than 1.
IllegalStateException - if the component is not displayable
Since:
1.4
See Also:
Component.isDisplayable(), getBufferStrategy()

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.
IllegalArgumentException - if numBuffers is less than 1, or if caps is null
Since:
1.4
See Also:
getBufferStrategy()

getBufferStrategy

public BufferStrategy getBufferStrategy()
Overrides:
getBufferStrategy in class Component
Returns:
the buffer strategy used by this component
Since:
1.4
See Also:
createBufferStrategy(int)

getTemporaryLostComponent

Component getTemporaryLostComponent()

setTemporaryLostComponent

Component setTemporaryLostComponent(Component component)