GeezerVison is showing docs.oracle.com — Window (Java Platform SE 8 )
Java™ Platform Standard Ed. 8
-
-
Nested Class Summary
Nested Classes
| Modifier and Type |
Class |
Description |
protected class |
Window.AccessibleAWTWindow |
This class implements accessibility support for the
Window class.
|
static class |
Window.Type |
Enumeration of available window types.
|
-
Constructor Summary
Constructors
| Constructor |
Description |
Window(Frame owner) |
Constructs a new, initially invisible window with the specified
Frame as its owner.
|
Window(Window owner) |
Constructs a new, initially invisible window with the specified
Window as its owner.
|
Window(Window owner,
GraphicsConfiguration gc) |
Constructs a new, initially invisible window with the specified owner
Window and a GraphicsConfiguration
of a screen device.
|
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
| Modifier and Type |
Method |
Description |
void |
addNotify() |
Makes this Window displayable by creating the connection to its
native screen resource.
|
void |
addPropertyChangeListener(PropertyChangeListener listener) |
Adds a PropertyChangeListener to the listener list.
|
void |
addPropertyChangeListener(String propertyName,
PropertyChangeListener listener) |
Adds a PropertyChangeListener to the listener list for a specific
property.
|
void |
addWindowFocusListener(WindowFocusListener l) |
Adds the specified window focus listener to receive window events
from this window.
|
void |
addWindowListener(WindowListener l) |
Adds the specified window listener to receive window events from
this window.
|
void |
addWindowStateListener(WindowStateListener l) |
Adds the specified window state listener to receive window
events from this window.
|
void |
applyResourceBundle(ResourceBundle rb) |
|
void |
applyResourceBundle(String rbName) |
|
void |
createBufferStrategy(int numBuffers) |
Creates a new strategy for multi-buffering on this component.
|
void |
createBufferStrategy(int numBuffers,
BufferCapabilities caps) |
Creates a new strategy for multi-buffering on this component with the
required buffer capabilities.
|
void |
dispose() |
Releases all of the native screen resources used by this
Window, its subcomponents, and all of its owned
children.
|
AccessibleContext |
getAccessibleContext() |
Gets the AccessibleContext associated with this Window.
|
Color |
getBackground() |
Gets the background color of this window.
|
BufferStrategy |
getBufferStrategy() |
Returns the BufferStrategy used by this component.
|
boolean |
getFocusableWindowState() |
Returns whether this Window can become the focused Window if it meets
the other requirements outlined in isFocusableWindow.
|
Container |
getFocusCycleRootAncestor() |
Always returns null because Windows have no ancestors; they
represent the top of the Component hierarchy.
|
Component |
getFocusOwner() |
Returns the child Component of this Window that has focus if this Window
is focused; returns null otherwise.
|
Set<AWTKeyStroke> |
getFocusTraversalKeys(int id) |
Gets a focus traversal key for this Window.
|
List<Image> |
getIconImages() |
Returns the sequence of images to be displayed as the icon for this window.
|
InputContext |
getInputContext() |
Gets the input context for this window.
|
<T extends EventListener> T[] |
getListeners(Class<T> listenerType) |
Returns an array of all the objects currently registered
as FooListeners
upon this Window.
|
Locale |
getLocale() |
Gets the Locale object that is associated
with this window, if the locale has been set.
|
Dialog.ModalExclusionType |
getModalExclusionType() |
Returns the modal exclusion type of this window.
|
Component |
getMostRecentFocusOwner() |
Returns the child Component of this Window that will receive the focus
when this Window is focused.
|
float |
getOpacity() |
Returns the opacity of the window.
|
Window[] |
getOwnedWindows() |
Return an array containing all the windows this
window currently owns.
|
Window |
getOwner() |
Returns the owner of this window.
|
static Window[] |
getOwnerlessWindows() |
Returns an array of all Windows created by this application
that have no owner.
|
Shape |
getShape() |
Returns the shape of the window.
|
Toolkit |
getToolkit() |
Returns the toolkit of this frame.
|
Window.Type |
getType() |
Returns the type of the window.
|
String |
getWarningString() |
Gets the warning string that is displayed with this window.
|
WindowFocusListener[] |
getWindowFocusListeners() |
Returns an array of all the window focus listeners
registered on this window.
|
WindowListener[] |
getWindowListeners() |
Returns an array of all the window listeners
registered on this window.
|
static Window[] |
getWindows() |
Returns an array of all Windows, both owned and ownerless,
created by this application.
|
WindowStateListener[] |
getWindowStateListeners() |
Returns an array of all the window state listeners
registered on this window.
|
void |
hide() |
|
boolean |
isActive() |
Returns whether this Window is active.
|
boolean |
isAlwaysOnTop() |
Returns whether this window is an always-on-top window.
|
boolean |
isAlwaysOnTopSupported() |
Returns whether the always-on-top mode is supported for this
window.
|
boolean |
isAutoRequestFocus() |
Returns whether this window should receive focus on subsequently being shown
(with a call to setVisible(true)), or being moved to the front
(with a call to toFront()).
|
boolean |
isFocusableWindow() |
Returns whether this Window can become the focused Window, that is,
whether this Window or any of its subcomponents can become the focus
owner.
|
boolean |
isFocusCycleRoot() |
Always returns true because all Windows must be roots of a
focus traversal cycle.
|
boolean |
isFocused() |
Returns whether this Window is focused.
|
boolean |
isLocationByPlatform() |
Returns true if this Window will appear at the default location
for the native windowing system the next time this Window is made visible.
|
boolean |
isOpaque() |
Indicates if the window is currently opaque.
|
boolean |
isShowing() |
Checks if this Window is showing on screen.
|
boolean |
isValidateRoot() |
Indicates if this container is a validate root.
|
void |
pack() |
Causes this Window to be sized to fit the preferred size
and layouts of its subcomponents.
|
void |
paint(Graphics g) |
Paints the container.
|
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 occurring on this window by
dispatching them to any registered WindowFocusListener objects.
|
protected void |
processWindowStateEvent(WindowEvent e) |
Processes window state event occurring on this window by
dispatching them to any registered WindowStateListener
objects.
|
void |
removeNotify() |
Makes this Container undisplayable by removing its connection
to its native screen resource.
|
void |
removeWindowFocusListener(WindowFocusListener l) |
Removes the specified window focus listener so that it no longer
receives window events from this window.
|
void |
removeWindowListener(WindowListener l) |
Removes the specified window listener so that it no longer
receives window events from this window.
|
void |
removeWindowStateListener(WindowStateListener l) |
Removes the specified window state listener so that it no
longer receives window events from this window.
|
void |
reshape(int x,
int y,
int width,
int height) |
Deprecated.
As of JDK version 1.1,
replaced by setBounds(int, int, int, int).
|
void |
setAlwaysOnTop(boolean alwaysOnTop) |
Sets whether this window should always be above other windows.
|
void |
setAutoRequestFocus(boolean autoRequestFocus) |
Sets whether this window should receive focus on
subsequently being shown (with a call to setVisible(true)),
or being moved to the front (with a call to toFront()).
|
void |
setBackground(Color bgColor) |
Sets the background color of this window.
|
void |
setBounds(int x,
int y,
int width,
int height) |
Moves and resizes this component.
|
void |
setBounds(Rectangle r) |
Moves and resizes this component to conform to the new
bounding rectangle r.
|
void |
setCursor(Cursor cursor) |
Set the cursor image to a specified cursor.
|
void |
setFocusableWindowState(boolean focusableWindowState) |
Sets whether this Window can become the focused Window if it meets
the other requirements outlined in isFocusableWindow.
|
void |
setFocusCycleRoot(boolean focusCycleRoot) |
Does nothing because Windows must always be roots of a focus traversal
cycle.
|
void |
setIconImage(Image image) |
Sets the image to be displayed as the icon for this window.
|
void |
setIconImages(List<? extends Image> icons) |
Sets the sequence of images to be displayed as the icon
for this window.
|
void |
setLocation(int x,
int y) |
Moves this component to a new location.
|
void |
setLocation(Point p) |
Moves this component to a new location.
|
void |
setLocationByPlatform(boolean locationByPlatform) |
Sets whether this Window should appear at the default location for the
native windowing system or at the current location (returned by
getLocation) the next time the Window is made visible.
|
void |
setLocationRelativeTo(Component c) |
Sets the location of the window relative to the specified
component according to the following scenarios.
|
void |
setMinimumSize(Dimension minimumSize) |
Sets the minimum size of this window to a constant
value.
|
void |
setModalExclusionType(Dialog.ModalExclusionType exclusionType) |
Specifies the modal exclusion type for this window.
|
void |
setOpacity(float opacity) |
Sets the opacity of the window.
|
void |
setShape(Shape shape) |
Sets the shape of the window.
|
void |
setSize(Dimension d) |
Resizes this component so that it has width d.width
and height d.height.
|
void |
setSize(int width,
int height) |
Resizes this component so that it has width width
and height height.
|
void |
setType(Window.Type type) |
Sets the type of the window.
|
void |
setVisible(boolean b) |
Shows or hides this Window depending on the value of parameter
b.
|
void |
show() |
|
void |
toBack() |
If this Window is visible, sends this Window to the back and may cause
it to lose focus or activation if it is the focused or active Window.
|
void |
toFront() |
If this Window is visible, brings this Window to the front and may make
it the focused Window.
|
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusDownCycle, update, validate, validateTree
-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
Method Detail
-
removeNotify
public void removeNotify()
Makes this Container undisplayable by removing its connection
to its native screen resource. Making a container undisplayable
will cause all of its children to be made undisplayable.
This method is called by the toolkit internally and should
not be called directly by programs.
- Overrides:
removeNotify in class Container
- See Also:
Component.isDisplayable(),
Container.addNotify()
-
pack
public void pack()
Causes this Window to be sized to fit the preferred size
and layouts of its subcomponents. The resulting width and
height of the window are automatically enlarged if either
of dimensions is less than the minimum size as specified
by the previous call to the setMinimumSize method.
If the window and/or its owner are not displayable yet,
both of them are made displayable before calculating
the preferred size. The Window is validated after its
size is being calculated.
- See Also:
Component.isDisplayable(),
setMinimumSize(java.awt.Dimension)
-
reshape
@Deprecated
public void reshape(int x,
int y,
int width,
int height)
Deprecated. As of JDK version 1.1,
replaced by setBounds(int, int, int, int).
- Overrides:
reshape in class Component
-
show
@Deprecated
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()
-
hide
@Deprecated
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()
-
dispose
public void dispose()
Releases all of the native screen resources used by this
Window, its subcomponents, and all of its owned
children. That is, the resources for these Components
will be destroyed, any memory they consume will be returned to the
OS, and they will be marked as undisplayable.
The Window and its subcomponents can be made displayable
again by rebuilding the native resources with a subsequent call to
pack or show. The states of the recreated
Window and its subcomponents will be identical to the
states of these objects at the point where the Window
was disposed (not accounting for additional modifications between
those actions).
Note: When the last displayable window
within the Java virtual machine (VM) is disposed of, the VM may
terminate. See
AWT Threading Issues for more information.
- See Also:
Component.isDisplayable(),
pack(),
show()
-
toFront
public void toFront()
If this Window is visible, brings this Window to the front and may make
it the focused Window.
Places this Window at the top of the stacking order and shows it in
front of any other Windows in this VM. No action will take place if this
Window is not visible. Some platforms do not allow Windows which own
other Windows to appear on top of those owned Windows. Some platforms
may not permit this VM to place its Windows above windows of native
applications, or Windows of other VMs. This permission may depend on
whether a Window in this VM is already focused. Every attempt will be
made to move this Window as high as possible in the stacking order;
however, developers should not assume that this method will move this
Window above all other windows in every situation.
Developers must never assume that this Window is the focused or active
Window until this Window receives a WINDOW_GAINED_FOCUS or WINDOW_ACTIVATED
event. On platforms where the top-most window is the focused window, this
method will probably focus this Window (if it is not already focused)
under the following conditions:
- The window meets the requirements outlined in the
isFocusableWindow() method.
- The window's property
autoRequestFocus is of the
true value.
- Native windowing system allows the window to get 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.
If this window is blocked by modal dialog, then the blocking dialog
is brought to the front and remains above the blocked window.
- See Also:
toBack(),
setAutoRequestFocus(boolean),
isFocusableWindow()
-
toBack
public void toBack()
If this Window is visible, sends this Window to the back and may cause
it to lose focus or activation if it is the focused or active Window.
Places this Window at the bottom of the stacking order and shows it
behind any other Windows in this VM. No action will take place is this
Window is not visible. Some platforms do not allow Windows which are
owned by other Windows to appear below their owners. Every attempt will
be made to move this Window as low as possible in the stacking order;
however, developers should not assume that this method will move this
Window below all other windows in every situation.
Because of variations in native windowing systems, no guarantees about
changes to the focused and active Windows can be made. Developers must
never assume that this Window is no longer the focused or active Window
until this Window receives a WINDOW_LOST_FOCUS or WINDOW_DEACTIVATED
event. On platforms where the top-most window is the focused window,
this method will probably cause this Window to lose focus. In
that case, the next highest, focusable Window in this VM will receive
focus. On platforms where the stacking order does not typically affect
the focused window, this method will probably leave the focused
and active Windows unchanged.
- See Also:
toFront()
-
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()
-
isAlwaysOnTopSupported
public boolean isAlwaysOnTopSupported()
Returns whether the always-on-top mode is supported for this
window. Some platforms may not support always-on-top windows, some
may support only some kinds of top-level windows; for example,
a platform may not support always-on-top modal dialogs.
- Returns:
true, if the always-on-top mode is supported for
this window and this window's toolkit supports always-on-top windows,
false otherwise
- Since:
- 1.6
- See Also:
setAlwaysOnTop(boolean),
getToolkit(),
Toolkit.isAlwaysOnTopSupported()
-
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()
-
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()
-
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 in interface Accessible
- Overrides:
getAccessibleContext in class Component
- Returns:
- an AccessibleAWTWindow that serves as the
AccessibleContext of this Window
- Since:
- 1.3
-
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()
-
paint
public void paint(Graphics g)
Paints the container. This forwards the paint to any lightweight
components that are children of this container. If this method is
reimplemented, super.paint(g) should be called so that lightweight
components are properly rendered. If a child component is entirely
clipped by the current clipping setting in g, paint() will not be
forwarded to that child.
- Overrides:
paint in class Container
- Parameters:
g - the specified Graphics window
- Since:
- 1.7
- See Also:
Component.update(Graphics)
Java™ Platform Standard Ed. 8
Submit a bug or feature For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. Copyright © 1993, 2026, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
|