Window (Java 2 Platform SE 5.0) (original) (raw)


java.awt

Class Window

java.lang.Object extended by java.awt.Component extended by java.awt.Container extended by java.awt.Window

All Implemented Interfaces:

ImageObserver, MenuContainer, Serializable, Accessible

Direct Known Subclasses:

BasicToolBarUI.DragWindow, Dialog, Frame, JWindow


public class Window

extends Container

implements Accessible

A Window object is a top-level window with no borders and no menubar. The default layout for a window is BorderLayout.

A window must have either a frame, dialog, or another window defined as its owner when it's constructed.

In a multi-screen environment, you can create a Window on a different screen device by constructing the Window with [Window(Window, GraphicsConfiguration)](../../java/awt/Window.html#Window%28java.awt.Window, java.awt.GraphicsConfiguration%29). The GraphicsConfiguration object is one of the GraphicsConfiguration objects of the target screen device.

In a virtual device multi-screen environment in which the desktop area could span multiple physical screen devices, the bounds of all configurations are relative to the virtual device coordinate system. The origin of the virtual-coordinate system is at the upper left-hand corner of the primary physical screen. Depending on the location of the primary screen in the virtual device, negative coordinates are possible, as shown in the following figure.

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

In such an environment, when calling setLocation, you must pass a virtual coordinate to this method. Similarly, calling getLocationOnScreen on a Window returns virtual device coordinates. Call the getBounds method of a GraphicsConfiguration to find its origin in the virtual coordinate system.

The following code sets the location of a Window at (10, 10) relative to the origin of the physical screen of the corresponding GraphicsConfiguration. If the bounds of the GraphicsConfiguration is not taken into account, the Window location would be set at (10, 10) relative to the virtual-coordinate system and would appear on the primary physical screen, which might be different from the physical screen of the specified GraphicsConfiguration.

    Window w = new Window(Window owner, GraphicsConfiguration gc);
    Rectangle bounds = gc.getBounds();
    w.setLocation(10 + bounds.x, 10 + bounds.y);

Note: the location and size of top-level windows (includingWindows, Frames, and Dialogs) are under the control of the desktop's window management system. Calls to setLocation, setSize, andsetBounds are requests (not directives) which are forwarded to the window management system. Every effort will be made to honor such requests. However, in some cases the window management system may ignore such requests, or modify the requested geometry in order to place and size the Window in a way that more closely matches the desktop settings. Due to the asynchronous nature of native event handling, the results returned by getBounds, getLocation,getLocationOnScreen, and getSize might not reflect the actual geometry of the Window on screen until the last request has been processed. During the processing of subsequent requests these values might change accordingly while the window management system fulfills the requests.

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

Since:

JDK1.0

See Also:

WindowEvent, addWindowListener(java.awt.event.WindowListener), BorderLayout, Serialized Form


Nested Class Summary
protected class Window.AccessibleAWTWindow This class implements accessibility support for the Window class.
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.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 specifiedFrame as its owner.
Window(Window owner) Constructs a new invisible window with the specifiedWindow as its owner.
[Window](../../java/awt/Window.html#Window%28java.awt.Window, java.awt.GraphicsConfiguration%29)(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](../../java/awt/Window.html#addPropertyChangeListener%28java.lang.String, java.beans.PropertyChangeListener%29)(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 byComponent.applyComponentOrientation.
void applyResourceBundle(String rbName) Deprecated. As of J2SE 1.4, replaced byComponent.applyComponentOrientation.
void createBufferStrategy(int numBuffers) Creates a new strategy for multi-buffering on this component.
void [createBufferStrategy](../../java/awt/Window.html#createBufferStrategy%28int, java.awt.BufferCapabilities%29)(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 thisWindow, its subcomponents, and all of its owned children.
protected void finalize() Disposes of the input methods and context, and removes this Window from the GUI hierarchy.
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<AWTKeyStroke> 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.
<T extends EventListener> T[] getListeners(Class listenerType) Returns an array of all the objects currently registered as _Foo_Listeners 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() Deprecated. As of JDK 5, replaced byComponent.setVisible(boolean).
boolean isActive() Returns whether this Window is active.
boolean isAlwaysOnTop() Returns whether this window is an always-on-top window.
boolean isFocusableWindow() Returns whether this Window can become the focused Window, that is, whether this Window or any of its subcomponents can become the focus owner.
boolean isFocusCycleRoot() Always returns true because all Windows must be roots of a focus traversal cycle.
boolean isFocused() Returns whether this Window is focused.
boolean isLocationByPlatform() Returns true if this Window will appear at the default location for the native windowing system the next time this Window is made visible.
boolean isShowing() Checks if this Window is showing on screen.
void pack() Causes this Window to be sized to fit the preferred size and layouts of its subcomponents.
boolean postEvent(Event e) Deprecated. As of JDK version 1.1 replaced by dispatchEvent(AWTEvent).
protected void processEvent(AWTEvent e) Processes events on this window.
protected void processWindowEvent(WindowEvent e) Processes window events occurring on this window by dispatching them to any registered WindowListener objects.
protected void processWindowFocusEvent(WindowEvent e) Processes window focus event occuring on this window by dispatching them to any registered WindowFocusListener objects.
protected void processWindowStateEvent(WindowEvent e) Processes window state event occuring on this window by dispatching them to any registered WindowStateListener objects.
void 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 setAlwaysOnTop(boolean alwaysOnTop) Changes the always-on-top window state.
void [setBounds](../../java/awt/Window.html#setBounds%28int, int, int, int%29)(int x, int y, int width, int height) Moves and resizes this component.
void setCursor(Cursor cursor) Set the cursor image to a specified cursor.
void setFocusableWindowState(boolean focusableWindowState) Sets whether this Window can become the focused Window if it meets the other requirements outlined in isFocusableWindow.
void setFocusCycleRoot(boolean focusCycleRoot) Does nothing because Windows must always be roots of a focus traversal cycle.
void setLocationByPlatform(boolean locationByPlatform) Sets whether this Window should appear at the default location for the native windowing system or at the current location (returned bygetLocation) the next time the Window is made visible.
void setLocationRelativeTo(Component c) Sets the location of the window relative to the specified component.
void show() Deprecated. As of JDK 5, replaced byComponent.setVisible(boolean).
void toBack() If this Window is visible, sends this Window to the back and may cause it to lose focus or activation if it is the focused or active Window.
void toFront() If this Window is visible, brings this Window to the front and may make it the focused Window.
Methods inherited from class java.awt.Container
add, [add](../../java/awt/Container.html#add%28java.awt.Component, int%29), [add](../../java/awt/Container.html#add%28java.awt.Component, java.lang.Object%29), [add](../../java/awt/Container.html#add%28java.awt.Component, java.lang.Object, int%29), [add](../../java/awt/Container.html#add%28java.lang.String, java.awt.Component%29), addContainerListener, [addImpl](../../java/awt/Container.html#addImpl%28java.awt.Component, java.lang.Object, int%29), applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, [findComponentAt](../../java/awt/Container.html#findComponentAt%28int, int%29), findComponentAt, getAlignmentX, getAlignmentY, getComponent, [getComponentAt](../../java/awt/Container.html#getComponentAt%28int, int%29), getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, [list](../../java/awt/Container.html#list%28java.io.PrintStream, int%29), [list](../../java/awt/Container.html#list%28java.io.PrintWriter, int%29), [locate](../../java/awt/Container.html#locate%28int, int%29), minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, removeNotify, [setComponentZOrder](../../java/awt/Container.html#setComponentZOrder%28java.awt.Component, int%29), [setFocusTraversalKeys](../../java/awt/Container.html#setFocusTraversalKeys%28int, java.util.Set%29), setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, validate, validateTree
Methods inherited from class java.awt.Component
[action](../../java/awt/Component.html#action%28java.awt.Event, java.lang.Object%29), add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, [checkImage](../../java/awt/Component.html#checkImage%28java.awt.Image, java.awt.image.ImageObserver%29), [checkImage](../../java/awt/Component.html#checkImage%28java.awt.Image, int, int, java.awt.image.ImageObserver%29), [coalesceEvents](../../java/awt/Component.html#coalesceEvents%28java.awt.AWTEvent, java.awt.AWTEvent%29), [contains](../../java/awt/Component.html#contains%28int, int%29), contains, createImage, [createImage](../../java/awt/Component.html#createImage%28int, int%29), [createVolatileImage](../../java/awt/Component.html#createVolatileImage%28int, int%29), [createVolatileImage](../../java/awt/Component.html#createVolatileImage%28int, int, java.awt.ImageCapabilities%29), disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, [firePropertyChange](../../java/awt/Component.html#firePropertyChange%28java.lang.String, boolean, boolean%29), [firePropertyChange](../../java/awt/Component.html#firePropertyChange%28java.lang.String, byte, byte%29), [firePropertyChange](../../java/awt/Component.html#firePropertyChange%28java.lang.String, char, char%29), [firePropertyChange](../../java/awt/Component.html#firePropertyChange%28java.lang.String, double, double%29), [firePropertyChange](../../java/awt/Component.html#firePropertyChange%28java.lang.String, float, float%29), [firePropertyChange](../../java/awt/Component.html#firePropertyChange%28java.lang.String, int, int%29), [firePropertyChange](../../java/awt/Component.html#firePropertyChange%28java.lang.String, long, long%29), [firePropertyChange](../../java/awt/Component.html#firePropertyChange%28java.lang.String, java.lang.Object, java.lang.Object%29), [firePropertyChange](../../java/awt/Component.html#firePropertyChange%28java.lang.String, short, short%29), getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, [gotFocus](../../java/awt/Component.html#gotFocus%28java.awt.Event, java.lang.Object%29), handleEvent, hasFocus, [imageUpdate](../../java/awt/Component.html#imageUpdate%28java.awt.Image, int, int, int, int, int%29), [inside](../../java/awt/Component.html#inside%28int, int%29), isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, [keyDown](../../java/awt/Component.html#keyDown%28java.awt.Event, int%29), [keyUp](../../java/awt/Component.html#keyUp%28java.awt.Event, int%29), list, list, list, location, [lostFocus](../../java/awt/Component.html#lostFocus%28java.awt.Event, java.lang.Object%29), [mouseDown](../../java/awt/Component.html#mouseDown%28java.awt.Event, int, int%29), [mouseDrag](../../java/awt/Component.html#mouseDrag%28java.awt.Event, int, int%29), [mouseEnter](../../java/awt/Component.html#mouseEnter%28java.awt.Event, int, int%29), [mouseExit](../../java/awt/Component.html#mouseExit%28java.awt.Event, int, int%29), [mouseMove](../../java/awt/Component.html#mouseMove%28java.awt.Event, int, int%29), [mouseUp](../../java/awt/Component.html#mouseUp%28java.awt.Event, int, int%29), [move](../../java/awt/Component.html#move%28int, int%29), nextFocus, paintAll, [prepareImage](../../java/awt/Component.html#prepareImage%28java.awt.Image, java.awt.image.ImageObserver%29), [prepareImage](../../java/awt/Component.html#prepareImage%28java.awt.Image, int, int, java.awt.image.ImageObserver%29), printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, [removePropertyChangeListener](../../java/awt/Component.html#removePropertyChangeListener%28java.lang.String, java.beans.PropertyChangeListener%29), repaint, [repaint](../../java/awt/Component.html#repaint%28int, int, int, int%29), repaint, [repaint](../../java/awt/Component.html#repaint%28long, int, int, int, int%29), requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, [reshape](../../java/awt/Component.html#reshape%28int, int, int, int%29), resize, [resize](../../java/awt/Component.html#resize%28int, int%29), setBackground, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, [setLocation](../../java/awt/Component.html#setLocation%28int, int%29), setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, [setSize](../../java/awt/Component.html#setSize%28int, int%29), setVisible, show, size, toString, transferFocus, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, [wait](../../java/lang/Object.html#wait%28long, int%29)
Constructor Detail

Window

public Window(Frame owner)

Constructs a new invisible window with the specifiedFrame 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](../../java/lang/IllegalArgumentException.html "class in java.lang") - if the owner'sGraphicsConfiguration is not from a screen device

[IllegalArgumentException](../../java/lang/IllegalArgumentException.html "class in java.lang") - 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 specifiedWindow 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](../../java/lang/IllegalArgumentException.html "class in java.lang") - if the owner'sGraphicsConfiguration is not from a screen device

[IllegalArgumentException](../../java/lang/IllegalArgumentException.html "class in java.lang") - 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](../../java/lang/IllegalArgumentException.html "class in java.lang") - ifowner is null

[IllegalArgumentException](../../java/lang/IllegalArgumentException.html "class in java.lang") - if gc is not from a screen device; this exception is always thrown whenGraphicsEnvironment.isHeadless returnstrue

Since:

1.3

See Also:

GraphicsEnvironment.isHeadless(), SecurityManager.checkTopLevelWindow(java.lang.Object), GraphicsConfiguration.getBounds(), isShowing()

Method Detail

finalize

protected void finalize() throws Throwable

Disposes of the input methods and context, and removes this Window from the GUI hierarchy. Subclasses that override this method should call super.finalize().

Overrides:

[finalize](../../java/lang/Object.html#finalize%28%29) in class [Object](../../java/lang/Object.html "class in java.lang")

Throws:

[Throwable](../../java/lang/Throwable.html "class in java.lang") - the Exception raised by this method


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](../../java/awt/Container.html#addNotify%28%29) in class [Container](../../java/awt/Container.html "class in java.awt")

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

@Deprecated public void show()

Deprecated. As of JDK 5, replaced byComponent.setVisible(boolean).

Overrides:

[show](../../java/awt/Component.html#show%28%29) in class [Component](../../java/awt/Component.html "class in java.awt")


hide

@Deprecated public void hide()

Deprecated. As of JDK 5, replaced byComponent.setVisible(boolean).

Overrides:

[hide](../../java/awt/Component.html#hide%28%29) in class [Component](../../java/awt/Component.html "class in java.awt")


dispose

public void dispose()

Releases all of the native screen resources used by thisWindow, 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 topack or show. The states of the recreatedWindow and its subcomponents will be identical to the states of these objects at the point where the Window was disposed (not accounting for additional modifications between those actions).

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

See Also:

Component.isDisplayable(), pack(), show()


toFront

public void toFront()

If this Window is visible, brings this Window to the front and may make it the focused Window.

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

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](../../java/awt/Component.html#getToolkit%28%29) in class [Component](../../java/awt/Component.html "class in java.awt")

Returns:

the toolkit of this window.

See Also:

Toolkit, Toolkit.getDefaultToolkit(), Component.getToolkit()


getWarningString

public final String getWarningString()

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

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

Returns:

the warning string for this window.

See Also:

SecurityManager.checkTopLevelWindow(java.lang.Object)


getLocale

public Locale getLocale()

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

Overrides:

[getLocale](../../java/awt/Component.html#getLocale%28%29) in class [Component](../../java/awt/Component.html "class in java.awt")

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](../../java/awt/Component.html#getInputContext%28%29) in class [Component](../../java/awt/Component.html "class in java.awt")

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](../../java/awt/Component.html#setCursor%28java.awt.Cursor%29) in class [Component](../../java/awt/Component.html "class in java.awt")

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. Ifl 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 <T extends EventListener> T[] getListeners(Class listenerType)

Returns an array of all the objects currently registered as _Foo_Listeners upon this Window._Foo_Listeners are registered using theadd_Foo_Listener method.

You can specify the listenerType argument with a class literal, such as_Foo_Listener.class. For example, you can query aWindow 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](../../java/awt/Container.html#getListeners%28java.lang.Class%29) in class [Container](../../java/awt/Container.html "class in java.awt")

Parameters:

listenerType - the type of listeners requested; this parameter should specify an interface that descends fromjava.util.EventListener

Returns:

an array of all objects registered as_Foo_Listeners on this window, or an empty array if no such listeners have been added

Throws:

[ClassCastException](../../java/lang/ClassCastException.html "class in java.lang") - if listenerType doesn't specify a class or interface that implementsjava.util.EventListener

Since:

1.3

See Also:

getWindowListeners()


processEvent

protected void processEvent(AWTEvent e)

Processes events on this window. If the event is anWindowEvent, it invokes theprocessWindowEvent 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](../../java/awt/Container.html#processEvent%28java.awt.AWTEvent%29) in class [Container](../../java/awt/Container.html "class in java.awt")

Parameters:

e - the event

See Also:

Component.processComponentEvent(java.awt.event.ComponentEvent), Component.processFocusEvent(java.awt.event.FocusEvent), Component.processKeyEvent(java.awt.event.KeyEvent), Component.processMouseEvent(java.awt.event.MouseEvent), Component.processMouseMotionEvent(java.awt.event.MouseEvent), Component.processInputMethodEvent(java.awt.event.InputMethodEvent), Component.processHierarchyEvent(java.awt.event.HierarchyEvent), Component.processMouseWheelEvent(java.awt.event.MouseWheelEvent)


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)


setAlwaysOnTop

public final void setAlwaysOnTop(boolean alwaysOnTop) throws SecurityException

Changes the always-on-top window state. An always-on-top window is a window that stays above all other windows except maybe other always-on-top windows. If there are several always-on-top windows the order in which they stay relative to each other is not specified and is platform dependent.

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

All owned windows of an always-on-top window automatically become always-on-top windows. If a window ceases to be always-on-top its owned windows cease to be always-on-top.

When an always-on-top window is sent toBack its always-on-top state is set to false.

This method makes the window always-on-top ifalwaysOnTop is true. If the window is visible, this includes bringing window toFront, then "sticking" it to the top-most position. If the window is not visible it does nothing other than setting the always-on-top property. If later the window is shown, it will be always-on-top. If the Window is already always-on-top, this call does nothing.

If alwaysOnTop is false this method changes the state from always-on-top to normal. The window remains top-most but its z-order can be changed in the normal way as for any other window. Does nothing if this Window is not always-on-top. Has no effect on relative z-order of windows if there are no other always-on-top windows.

Note: some platforms might not support always-on-top windows. There is no public API to detect if the platform supports always-on-top at runtime.

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

Parameters:

alwaysOnTop - new value of always-on-top state of the window

Throws:

[SecurityException](../../java/lang/SecurityException.html "class in java.lang") - if the calling thread does not have permission to set the value of always-on-top property

Since:

1.5

See Also:

isAlwaysOnTop(), toFront(), toBack(), AWTPermission


isAlwaysOnTop

public final boolean isAlwaysOnTop()

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

Returns:

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

Since:

1.5

See Also:

setAlwaysOnTop(boolean)


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<AWTKeyStroke> 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](../../java/awt/Container.html#getFocusTraversalKeys%28int%29) in class [Container](../../java/awt/Container.html "class in java.awt")

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](../../java/lang/IllegalArgumentException.html "class in java.lang") - 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)](../../java/awt/Container.html#setFocusTraversalKeys%28int, java.util.Set%29), 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](../../java/awt/Container.html#setFocusCycleRoot%28boolean%29) in class [Container](../../java/awt/Container.html "class in java.awt")

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](../../java/awt/Container.html#isFocusCycleRoot%28%29) in class [Container](../../java/awt/Container.html "class in java.awt")

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](../../java/awt/Component.html#getFocusCycleRootAncestor%28%29) in class [Component](../../java/awt/Component.html "class in java.awt")

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 totrue, 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, thenisFocusableWindow will return false as well. If this method returns true, thenisFocusableWindow may return true orfalse 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 oftrue.

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, thenisFocusableWindow will return false. If this Window's focusable Window state is set to true, thenisFocusableWindow may return true orfalse depending upon the other requirements which must be met in order for a Window to be focusable.

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

Parameters:

focusableWindowState - whether this Window can be the focused Window

Since:

1.4

See Also:

isFocusableWindow(), getFocusableWindowState(), isShowing(), Component.setFocusable(boolean)


addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)

Adds a PropertyChangeListener to the listener list. The listener is registered for all bound properties of this class, including the following:

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

Overrides:

[addPropertyChangeListener](../../java/awt/Container.html#addPropertyChangeListener%28java.beans.PropertyChangeListener%29) in class [Container](../../java/awt/Container.html "class in java.awt")

Parameters:

listener - the PropertyChangeListener to be added

See Also:

Component.removePropertyChangeListener(java.beans.PropertyChangeListener), [addPropertyChangeListener(java.lang.String,java.beans.PropertyChangeListener)](../../java/awt/Window.html#addPropertyChangeListener%28java.lang.String, java.beans.PropertyChangeListener%29)


addPropertyChangeListener

public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)

Adds a PropertyChangeListener to the listener list for a specific property. The specified property may be user-defined, or one of the following:

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

Overrides:

[addPropertyChangeListener](../../java/awt/Container.html#addPropertyChangeListener%28java.lang.String, java.beans.PropertyChangeListener%29) in class [Container](../../java/awt/Container.html "class in java.awt")

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)


postEvent

@Deprecated public boolean postEvent(Event e)

Deprecated. As of JDK version 1.1 replaced by dispatchEvent(AWTEvent).

Specified by:

[postEvent](../../java/awt/MenuContainer.html#postEvent%28java.awt.Event%29) in interface [MenuContainer](../../java/awt/MenuContainer.html "interface in java.awt")

Overrides:

[postEvent](../../java/awt/Component.html#postEvent%28java.awt.Event%29) in class [Component](../../java/awt/Component.html "class in java.awt")


isShowing

public boolean isShowing()

Checks if this Window is showing on screen.

Overrides:

[isShowing](../../java/awt/Component.html#isShowing%28%29) in class [Component](../../java/awt/Component.html "class in java.awt")

Returns:

true if the component is showing,false otherwise

See Also:

Component.setVisible(boolean)


applyResourceBundle

@Deprecated public void applyResourceBundle(ResourceBundle rb)

Deprecated. As of J2SE 1.4, replaced byComponent.applyComponentOrientation.


applyResourceBundle

@Deprecated public void applyResourceBundle(String rbName)

Deprecated. As of J2SE 1.4, replaced byComponent.applyComponentOrientation.


getAccessibleContext

public AccessibleContext getAccessibleContext()

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

Specified by:

[getAccessibleContext](../../javax/accessibility/Accessible.html#getAccessibleContext%28%29) in interface [Accessible](../../javax/accessibility/Accessible.html "interface in javax.accessibility")

Overrides:

[getAccessibleContext](../../java/awt/Component.html#getAccessibleContext%28%29) in class [Component](../../java/awt/Component.html "class in java.awt")

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](../../java/awt/Component.html#getGraphicsConfiguration%28%29) in class [Component](../../java/awt/Component.html "class in java.awt")

Returns:

the GraphicsConfiguration used by thisComponent or null


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


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.

Parameters:

numBuffers - number of buffers to create

Throws:

[IllegalArgumentException](../../java/lang/IllegalArgumentException.html "class in java.lang") - if numBuffers is less than 1.

[IllegalStateException](../../java/lang/IllegalStateException.html "class in java.lang") - 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.

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](../../java/awt/AWTException.html "class in java.awt") - 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](../../java/lang/IllegalArgumentException.html "class in java.lang") - if numBuffers is less than 1, or if caps is null

Since:

1.4

See Also:

getBufferStrategy()


getBufferStrategy

public BufferStrategy getBufferStrategy()

Returns:

the buffer strategy used by this component

Since:

1.4

See Also:

createBufferStrategy(int)


setLocationByPlatform

public void setLocationByPlatform(boolean locationByPlatform)

Sets whether this Window should appear at the default location for the native windowing system or at the current location (returned bygetLocation) the next time the Window is made visible. This behavior resembles a native window shown without programmatically setting its location. Most windowing systems cascade windows if their locations are not explicitly set. The actual location is determined once the window is shown on the screen.

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

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

For example, after the following code is executed:

setLocationByPlatform(true); setVisible(true); boolean flag = isLocationByPlatform();

The window will be shown at platform's default location andflag will be false.

In the following sample:

setLocationByPlatform(true); setLocation(10, 10); boolean flag = isLocationByPlatform(); setVisible(true);

The window will be shown at (10, 10) and flag will befalse.

Parameters:

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

Throws:

`IllegalComponentStateException` - if the window is showing on screen and locationByPlatform is true.

Since:

1.5

See Also:

[Component.setLocation(int, int)](../../java/awt/Component.html#setLocation%28int, int%29), isShowing(), Component.setVisible(boolean), isLocationByPlatform(), System.getProperty(String)


isLocationByPlatform

public boolean isLocationByPlatform()

Returns true if this Window will appear at the default location for the native windowing system the next time this Window is made visible. This method always returns false if the Window is showing on the screen.

Returns:

whether this Window will appear at the default location

Since:

1.5

See Also:

setLocationByPlatform(boolean), isShowing()


setBounds

public void setBounds(int x, int y, int width, int height)

Description copied from class: [Component](../../java/awt/Component.html#setBounds%28int, int, int, int%29)

Moves and resizes this component. The new location of the top-left corner is specified by x and y, and the new size is specified by width and height.

Overrides:

[setBounds](../../java/awt/Component.html#setBounds%28int, int, int, int%29) in class [Component](../../java/awt/Component.html "class in java.awt")

Parameters:

x - the new _x_-coordinate of this component

y - the new _y_-coordinate of this component

width - the new width of this component

height - the new height of this component

Since:

1.5

See Also:

setLocationByPlatform(boolean), isLocationByPlatform()



Submit a bug or feature
For further API reference and developer documentation, see Java 2 SDK SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.

Copyright © 2004, 2010 Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.