java.awt

Class Window

Implemented Interfaces:
Accessible, ImageObserver, MenuContainer, Serializable
Known Direct Subclasses:
BasicToolBarUI.DragWindow, Dialog, Frame, JWindow

public class Window
extends Container
implements Accessible

This class represents a top-level window with no decorations.
See Also:
Serialized Form

Nested Class Summary

protected class
Window.AccessibleAWTWindow

Nested classes/interfaces inherited from class java.awt.Container

Container.AccessibleAWTContainer

Nested classes/interfaces inherited from class java.awt.Component

Component.AccessibleAWTComponent, 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)
Initializes a new instance of Window with the specified parent.
Window(Window owner)
Initializes a new instance of Window with the specified parent.
Window(Window owner, GraphicsConfiguration gc)
Initializes a new instance of Window with the specified parent.

Method Summary

void
addNotify()
Creates the native peer for this window.
void
addWindowFocusListener(WindowFocusListener wfl)
Adds the specified listener to this window.
void
addWindowListener(WindowListener listener)
Adds the specified listener to the list of WindowListeners that will receive events for this window.
void
addWindowStateListener(WindowStateListener wsl)
Adds the specified listener to this window.
void
applyResourceBundle(String rbName)
Deprecated.
void
applyResourceBundle(ResourceBundle rb)
Deprecated. replaced by Component.applyComponentOrientation.
void
createBufferStrategy(int numBuffers)
Creates a buffering strategy that manages how this window is repainted.
void
createBufferStrategy(int numBuffers, BufferCapabilities caps)
Creates a buffering strategy that manages how this window is repainted.
void
dispose()
Destroys any resources associated with this window.
extends EventListener> T[] getListeners(Class listenerType)
Returns an array of all the objects currently registered as FooListeners upon this Window.
AccessibleContext
getAccessibleContext()
Gets the AccessibleContext associated with this Window.
BufferStrategy
getBufferStrategy()
Returns the buffer strategy used by the window.
Container
getFocusCycleRootAncestor()
Returns the root container that owns the focus cycle where this component resides.
Component
getFocusOwner()
Returns the child window that has focus if this window is active.
boolean
getFocusableWindowState()
Returns the value of the focusableWindowState property.
GraphicsConfiguration
getGraphicsConfiguration()
Get graphics configuration.
Locale
getLocale()
Returns the locale that this window is configured for.
Component
getMostRecentFocusOwner()
Returns the child component of this window that would receive focus if this window were to become focused.
Window[]
getOwnedWindows()
Window
getOwner()
Toolkit
getToolkit()
Returns the toolkit used to create this window.
String
getWarningString()
Returns the warning string that will be displayed if this window is popped up by an unsecure applet or application.
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.
boolean
isActive()
Identifies if this window is active.
boolean
isAlwaysOnTop()
Returns whether the Windows is an always-on-top window, meaning whether the window can be obscured by other windows or not.
boolean
isFocusCycleRoot()
Check whether this Container is a focus cycle root.
boolean
isFocusableWindow()
Returns whether this Window can get the focus or not.
boolean
isFocused()
Identifies if this window is focused.
boolean
isShowing()
Tests whether or not this window is visible on the screen.
void
pack()
Relays out this window's child components at their preferred size.
boolean
postEvent(Event e)
Deprecated.
protected void
processEvent(AWTEvent evt)
Processes the specified event for this window.
protected void
processWindowEvent(WindowEvent evt)
Dispatches this event to any listeners that are listening for WindowEvents on this window.
protected void
processWindowFocusEvent(WindowEvent event)
protected void
processWindowStateEvent(WindowEvent event)
void
removeWindowFocusListener(WindowFocusListener wfl)
Removes the specified listener from this window.
void
removeWindowListener(WindowListener listener)
Removes the specified listener from the list of WindowListeners that will receive events for this window.
void
removeWindowStateListener(WindowStateListener wsl)
Removes the specified listener from this window.
void
setAlwaysOnTop(boolean alwaysOnTop)
Sets the always-on-top state of this window (if supported).
void
setCursor(Cursor cursor)
Sets the cursor for this window to the specifiec cursor.
void
setFocusCycleRoot(boolean focusCycleRoot)
Set whether or not this Container is the root of a focus traversal cycle.
void
setFocusableWindowState(boolean focusableWindowState)
Sets the value of the focusableWindowState property.
void
setLocationRelativeTo(Component c)
void
toBack()
Sends this window to the back so that all other windows display in front of it.
void
toFront()
Brings this window to the front so that it displays in front of any other windows.
@Deprecated
void hide()
@Deprecated
void show()
Shows on-screen this window and any of its owned windows for whom isVisible returns true.

Methods inherited from class java.awt.Container

add, add, add, add, add, addContainerListener, addImpl, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, extends EventListener> T[] getListeners, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponentZOrder, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusDownCycle, update, validate, validateTree

Methods inherited from class java.awt.Component

action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, extends EventListener> T[] getListeners, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFocusable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFocusable, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

Window

public Window(Frame owner)
Initializes a new instance of Window with the specified parent. The window will initially be invisible.
Parameters:
owner - The owning Frame of this window.
Throws:
IllegalArgumentException - If the owner's GraphicsConfiguration is not from a screen device, or if owner is null; this exception is always thrown when GraphicsEnvironment.isHeadless returns true.

Window

public Window(Window owner)
Initializes a new instance of Window with the specified parent. The window will initially be invisible.
Throws:
IllegalArgumentException - If the owner's GraphicsConfiguration is not from a screen device, or if owner is null; this exception is always thrown when GraphicsEnvironment.isHeadless returns true.
Since:
1.2

Window

public Window(Window owner,
              GraphicsConfiguration gc)
Initializes a new instance of Window with the specified parent. The window will initially be invisible.
Throws:
IllegalArgumentException - If owner is null or if gc is not from a screen device; this exception is always thrown when GraphicsEnvironment.isHeadless returns true.
Since:
1.3

Method Details

addNotify

public void addNotify()
Creates the native peer for this window.
Overrides:
addNotify in interface Container

addWindowFocusListener

public void addWindowFocusListener(WindowFocusListener wfl)
Adds the specified listener to this window.

addWindowListener

public void addWindowListener(WindowListener listener)
Adds the specified listener to the list of WindowListeners that will receive events for this window.
Parameters:
listener - The WindowListener to add.

addWindowStateListener

public void addWindowStateListener(WindowStateListener wsl)
Adds the specified listener to this window.
Since:
1.4

applyResourceBundle

public void applyResourceBundle(String rbName)

Deprecated.

Since:
1.2

applyResourceBundle

public void applyResourceBundle(ResourceBundle rb)

Deprecated. replaced by Component.applyComponentOrientation.

Since:
1.2

createBufferStrategy

public void createBufferStrategy(int numBuffers)
Creates a buffering strategy that manages how this window is repainted. This method attempts to create the optimum strategy based on the desired number of buffers. Hardware or software acceleration may be used. createBufferStrategy attempts different levels of optimization, but guarantees that some strategy with the requested number of buffers will be created even if it is not optimal. First it attempts to create a page flipping strategy, then an accelerated blitting strategy, then an unaccelerated blitting strategy. Calling this method causes any existing buffer strategy to be destroyed.
Parameters:
numBuffers - the number of buffers in this strategy
Throws:
IllegalArgumentException - if requested number of buffers is less than one
IllegalStateException - if this window is not displayable
Since:
1.4

createBufferStrategy

public void createBufferStrategy(int numBuffers,
                                 BufferCapabilities caps)
            throws AWTException
Creates a buffering strategy that manages how this window is repainted. This method attempts to create a strategy based on the specified capabilities and throws an exception if the requested strategy is not supported. Calling this method causes any existing buffer strategy to be destroyed.
Parameters:
numBuffers - the number of buffers in this strategy
caps - the requested buffering capabilities
Throws:
AWTException - if the requested capabilities are not supported
IllegalArgumentException - if requested number of buffers is less than one or if caps is null
Since:
1.4

dispose

public void dispose()
Destroys any resources associated with this window. This includes all components in the window and all owned top-level windows.

extends EventListener> T[] getListeners

public extends EventListener> T[] getListeners(Class listenerType)
Returns an array of all the objects currently registered as FooListeners upon this Window. FooListeners are registered using the addFooListener method.
Overrides:
extends EventListener> T[] getListeners in interface Container
Throws:
ClassCastException - If listenerType doesn't specify a class or interface that implements java.util.EventListener.
Since:
1.3

getAccessibleContext

public AccessibleContext getAccessibleContext()
Gets the AccessibleContext associated with this Window. The context is created, if necessary.
Specified by:
getAccessibleContext in interface Accessible
Overrides:
getAccessibleContext in interface Component
Returns:
the associated context

getBufferStrategy

public BufferStrategy getBufferStrategy()
Returns the buffer strategy used by the window.
Returns:
the buffer strategy.
Since:
1.4

getFocusCycleRootAncestor

public final Container getFocusCycleRootAncestor()
Returns the root container that owns the focus cycle where this component resides. Windows have no ancestors and this method returns always null.
Overrides:
getFocusCycleRootAncestor in interface Component
Returns:
Always null.
Since:
1.4

getFocusOwner

public Component getFocusOwner()
Returns the child window that has focus if this window is active. This method returns null if this window is not active or no children have focus.
Returns:
The component that has focus, or null if no component has focus.

getFocusableWindowState

public boolean getFocusableWindowState()
Returns the value of the focusableWindowState property.
Since:
1.4

getGraphicsConfiguration

public GraphicsConfiguration getGraphicsConfiguration()
Get graphics configuration. The implementation for Window will not ask any parent containers, since Window is a toplevel window and not actually embedded in the parent component.
Overrides:
getGraphicsConfiguration in interface Component

getLocale

public Locale getLocale()
Returns the locale that this window is configured for.
Overrides:
getLocale in interface Component
Returns:
The locale this window is configured for.

getMostRecentFocusOwner

public Component getMostRecentFocusOwner()
Returns the child component of this window that would receive focus if this window were to become focused. If the window already has the top-level focus, then this method returns the same component as getFocusOwner. If no child component has requested focus within the window, then the initial focus owner is returned. If this is a non-focusable window, this method returns null.
Returns:
the child component of this window that most recently had the focus, or null
Since:
1.4

getOwnedWindows

public Window[] getOwnedWindows()
Since:
1.2

getOwner

public Window getOwner()

getToolkit

public Toolkit getToolkit()
Returns the toolkit used to create this window.
Overrides:
getToolkit in interface Component
Returns:
The toolkit used to create this window.

getWarningString

public final String getWarningString()
Returns the warning string that will be displayed if this window is popped up by an unsecure applet or application.
Returns:
The unsecure window warning message.

getWindowFocusListeners

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

getWindowListeners

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

getWindowStateListeners

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

isActive

public boolean isActive()
Identifies if this window is active. The active window is a Frame or Dialog that has focus or owns the active window.
Returns:
true if active, else false.
Since:
1.4

isAlwaysOnTop

public final boolean isAlwaysOnTop()
Returns whether the Windows is an always-on-top window, meaning whether the window can be obscured by other windows or not.
Returns:
true if the windows is always-on-top, false otherwise.
Since:
1.5

isFocusCycleRoot

public final boolean isFocusCycleRoot()
Check whether this Container is a focus cycle root. Returns always true as Windows are the root of the focus cycle.
Overrides:
isFocusCycleRoot in interface Container
Returns:
Always true.
Since:
1.4

isFocusableWindow

public final boolean isFocusableWindow()
Returns whether this Window can get the focus or not.
Since:
1.4

isFocused

public boolean isFocused()
Identifies if this window is focused. A window is focused if it is the focus owner or it contains the focus owner.
Returns:
true if focused, else false.
Since:
1.4

isShowing

public boolean isShowing()
Tests whether or not this window is visible on the screen. In contrast to the normal behaviour of Container, which is that a container is showing if its parent is visible and showing, a Window is even showing, if its parent (i.e. an invisible Frame) is not showing.
Overrides:
isShowing in interface Component
Returns:
true if this window is visible, false otherwise.

pack

public void pack()
Relays out this window's child components at their preferred size.

postEvent

public boolean postEvent(Event e)

Deprecated.

Post a Java 1.0 event to the event queue.
Specified by:
postEvent in interface MenuContainer
Overrides:
postEvent in interface Component
Parameters:
e - The event to post.

processEvent

protected void processEvent(AWTEvent evt)
Processes the specified event for this window. If the event is an instance of WindowEvent, then processWindowEvent() is called to process the event, otherwise the superclass version of this method is invoked.
Overrides:
processEvent in interface Container
Parameters:
evt - The event to process.

processWindowEvent

protected void processWindowEvent(WindowEvent evt)
Dispatches this event to any listeners that are listening for WindowEvents on this window. This method only gets invoked if it is enabled via enableEvents() or if a listener has been added.
Parameters:
evt - The event to process.

processWindowFocusEvent

protected void processWindowFocusEvent(WindowEvent event)

processWindowStateEvent

protected void processWindowStateEvent(WindowEvent event)
Since:
1.4

removeWindowFocusListener

public void removeWindowFocusListener(WindowFocusListener wfl)
Removes the specified listener from this window.

removeWindowListener

public void removeWindowListener(WindowListener listener)
Removes the specified listener from the list of WindowListeners that will receive events for this window.
Parameters:
listener - The WindowListener to remove.

removeWindowStateListener

public void removeWindowStateListener(WindowStateListener wsl)
Removes the specified listener from this window.
Since:
1.4

setAlwaysOnTop

public final void setAlwaysOnTop(boolean alwaysOnTop)
Sets the always-on-top state of this window (if supported). Setting a window to always-on-top means it will not be obscured by any other windows (with the exception of other always-on-top windows). Not all platforms may support this. If an window's always-on-top status is changed to false, the window will remain at the front but not be anchored there. Calling toBack() on an always-on-top window will change its always-on-top status to false.
Since:
1.5

setCursor

public void setCursor(Cursor cursor)
Sets the cursor for this window to the specifiec cursor.
Overrides:
setCursor in interface Component
Parameters:
cursor - The new cursor for this window.

setFocusCycleRoot

public final void setFocusCycleRoot(boolean focusCycleRoot)
Set whether or not this Container is the root of a focus traversal cycle. Windows are the root of the focus cycle and therefore this method does nothing.
Overrides:
setFocusCycleRoot in interface Container
Parameters:
focusCycleRoot - ignored.
Since:
1.4

setFocusableWindowState

public void setFocusableWindowState(boolean focusableWindowState)
Sets the value of the focusableWindowState property.
Since:
1.4

setLocationRelativeTo

public void setLocationRelativeTo(Component c)

toBack

public void toBack()
Sends this window to the back so that all other windows display in front of it. If the window is set to be always-on-top, this will remove its always-on-top status.

toFront

public void toFront()
Brings this window to the front so that it displays in front of any other windows.

void hide

public @Deprecated void hide()

void show

public @Deprecated void show()
Shows on-screen this window and any of its owned windows for whom isVisible returns true.

Window.java -- Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005 Free Software Foundation This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.