A Frame is a top-level window with a title and a border.

The size of the frame includes any area designated for the border. The dimensions of the border area may be obtained using the getInsets method, however, since these dimensions are platform-dependent, a valid insets value cannot be obtained until the frame is made displayable by either calling pack or show. Since the border area is included in the overall size of the frame, the border effectively obscures a portion of the frame, constraining the area available for rendering and/or displaying subcomponents to the rectangle which has an upper-left corner location of (insets.left, insets.top), and has a size of width - (insets.left + insets.right) by height - (insets.top + insets.bottom).

The default layout for a frame is BorderLayout.

A frame may have its native decorations (i.e. Frame and Titlebar) turned off with setUndecorated. This can only be done while the frame is not displayable .

In a multi-screen environment, you can create a Frame on a different screen device by constructing the Frame with or . 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-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 of virtual device encompassing three physical screens and one primary physical screen. The primary physical screen
 shows (0,0) coords while a different physical screen shows (-80,-100) coords.

In such an environment, when calling setLocation, you must pass a virtual coordinate to this method. Similarly, calling getLocationOnScreen on a Frame 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 the Frame 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 Frame 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.

      Frame f = new Frame(GraphicsConfiguration gc);
      Rectangle bounds = gc.getBounds();
      f.setLocation(10 + bounds.x, 10 + bounds.y);
 

Frames are capable of generating the following types of WindowEvents:

@version
1.147, 05/18/04
@author
Sami Shaio
@since
JDK1.0
Constructs a new instance of Frame that is initially invisible. The title of the Frame is empty.
Throws
HeadlessExceptionwhen GraphicsEnvironment.isHeadless() returns true
Create a Frame with the specified GraphicsConfiguration of a screen device.
Parameters
gcthe GraphicsConfiguration of the target screen device. If gc is null, the system default GraphicsConfiguration is assumed.
Throws
IllegalArgumentExceptionif gc is not from a screen device. This exception is always thrown when GraphicsEnvironment.isHeadless() returns true
@since
1.3
Constructs a new, initially invisible Frame object with the specified title.
Parameters
titlethe title to be displayed in the frame's border. A null value is treated as an empty string, "".
Throws
HeadlessExceptionwhen GraphicsEnvironment.isHeadless() returns true
Constructs a new, initially invisible Frame object with the specified title and a GraphicsConfiguration.
Parameters
titlethe title to be displayed in the frame's border. A null value is treated as an empty string, "".
gcthe GraphicsConfiguration of the target screen device. If gc is null, the system default GraphicsConfiguration is assumed.
Throws
IllegalArgumentExceptionif gc is not from a screen device. This exception is always thrown when GraphicsEnvironment.isHeadless() returns true
Ease-of-use constant for getAlignmentY. Specifies an alignment to the bottom of the component.
Ease-of-use constant for getAlignmentY and getAlignmentX. Specifies an alignment to the center of the component
@deprecated
replaced by Cursor.CROSSHAIR_CURSOR.
@deprecated
replaced by Cursor.DEFAULT_CURSOR.
@deprecated
replaced by Cursor.E_RESIZE_CURSOR.
@deprecated
replaced by Cursor.HAND_CURSOR.
This state bit indicates that frame is iconified.
Ease-of-use constant for getAlignmentX. Specifies an alignment to the left side of the component.
This state bit mask indicates that frame is fully maximized (that is both horizontally and vertically). It is just a convenience alias for MAXIMIZED_VERT | MAXIMIZED_HORIZ.

Note that the correct test for frame being fully maximized is

     (state & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH
 

To test is frame is maximized in some direction use

     (state & Frame.MAXIMIZED_BOTH) != 0
 
This state bit indicates that frame is maximized in the horizontal direction.
This state bit indicates that frame is maximized in the vertical direction.
@deprecated
replaced by Cursor.MOVE_CURSOR.
@deprecated
replaced by Cursor.N_RESIZE_CURSOR.
@deprecated
replaced by Cursor.NE_RESIZE_CURSOR.
Frame is in the "normal" state. This symbolic constant names a frame state with all state bits cleared.
@deprecated
replaced by Cursor.NW_RESIZE_CURSOR.
Ease-of-use constant for getAlignmentX. Specifies an alignment to the right side of the component.
@deprecated
replaced by Cursor.S_RESIZE_CURSOR.
@deprecated
replaced by Cursor.SE_RESIZE_CURSOR.
@deprecated
replaced by Cursor.SW_RESIZE_CURSOR.
@deprecated
replaced by Cursor.TEXT_CURSOR.
Ease-of-use constant for getAlignmentY(). Specifies an alignment to the top of the component.
@deprecated
replaced by Cursor.W_RESIZE_CURSOR.
@deprecated
replaced by Cursor.WAIT_CURSOR.
@deprecated
As of JDK version 1.1, should register this component as ActionListener on component which fires action events.
Appends the specified component to the end of this container. This is a convenience method for #addImpl .

Note: If a component has been added to a container that has been displayed, validate must be called on that container to display the new component. If multiple components are being added, you can improve efficiency by calling validate only once, after all the components have been added.

Parameters
compthe component to be added
Return
the component argument
Adds the specified component to this container at the given position. This is a convenience method for #addImpl .

Note: If a component has been added to a container that has been displayed, validate must be called on that container to display the new component. If multiple components are being added, you can improve efficiency by calling validate only once, after all the components have been added.

Parameters
compthe component to be added
indexthe position at which to insert the component, or -1 to append the component to the end
Return
the component comp
Adds the specified component to the end of this container. Also notifies the layout manager to add the component to this container's layout using the specified constraints object. This is a convenience method for #addImpl .

Note: If a component has been added to a container that has been displayed, validate must be called on that container to display the new component. If multiple components are being added, you can improve efficiency by calling validate only once, after all the components have been added.

Parameters
compthe component to be added
constraintsan object expressing layout contraints for this component
@since
JDK1.1
Adds the specified component to this container with the specified constraints at the specified index. Also notifies the layout manager to add the component to the this container's layout using the specified constraints object. This is a convenience method for #addImpl .

Note: If a component has been added to a container that has been displayed, validate must be called on that container to display the new component. If multiple components are being added, you can improve efficiency by calling validate only once, after all the components have been added.

Parameters
compthe component to be added
constraintsan object expressing layout contraints for this
indexthe position in the container's list at which to insert the component; -1 means insert at the end component
Adds the specified popup menu to the component.
Parameters
popupthe popup menu to be added to the component.
@since
JDK1.1
Adds the specified component to this container. This is a convenience method for #addImpl .

This method is obsolete as of 1.1. Please use the method add(Component, Object) instead.

Adds the specified component listener to receive component events from this component. If listener l is null, no exception is thrown and no action is performed.
Adds the specified container listener to receive container events from this container. If l is null, no exception is thrown and no action is performed.
Parameters
lthe container listener
Adds the specified focus listener to receive focus events from this component when this component gains input focus. If listener l is null, no exception is thrown and no action is performed.
Parameters
lthe focus listener
@since
JDK1.1
Adds the specified hierarchy bounds listener to receive hierarchy bounds events from this component when the hierarchy to which this container belongs changes. If listener l is null, no exception is thrown and no action is performed.
Adds the specified hierarchy listener to receive hierarchy changed events from this component when the hierarchy to which this container belongs changes. If listener l is null, no exception is thrown and no action is performed.
Adds the specified input method listener to receive input method events from this component. A component will only receive input method events from input methods if it also overrides getInputMethodRequests to return an InputMethodRequests instance. If listener l is null, no exception is thrown and no action is performed.
Adds the specified key listener to receive key events from this component. If l is null, no exception is thrown and no action is performed.
Parameters
lthe key listener.
@since
JDK1.1
Adds the specified mouse listener to receive mouse events from this component. If listener l is null, no exception is thrown and no action is performed.
Parameters
lthe mouse listener
@since
JDK1.1
Adds the specified mouse motion listener to receive mouse motion events from this component. If listener l is null, no exception is thrown and no action is performed.
Adds the specified mouse wheel listener to receive mouse wheel events from this component. Containers also receive mouse wheel events from sub-components.

For information on how mouse wheel events are dispatched, see the class description for MouseWheelEvent .

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

Makes this Frame displayable by connecting it to a native screen resource. Making a frame displayable will cause any of its children to be made displayable. This method is called internally by the toolkit and should not be called directly by programs.
Adds a PropertyChangeListener to the listener list. The listener is registered for all bound properties of this class, including the following:
  • this Window's font ("font")
  • this Window's background color ("background")
  • this Window's foreground color ("foreground")
  • this Window's focusability ("focusable")
  • this Window's focus traversal keys enabled state ("focusTraversalKeysEnabled")
  • this Window's Set of FORWARD_TRAVERSAL_KEYS ("forwardFocusTraversalKeys")
  • this Window's Set of BACKWARD_TRAVERSAL_KEYS ("backwardFocusTraversalKeys")
  • this Window's Set of UP_CYCLE_TRAVERSAL_KEYS ("upCycleFocusTraversalKeys")
  • this Window's Set of DOWN_CYCLE_TRAVERSAL_KEYS ("downCycleFocusTraversalKeys")
  • this Window's focus traversal policy ("focusTraversalPolicy")
  • this Window's focusable Window state ("focusableWindowState")
  • this Window's always-on-top state("alwaysOnTop")
Note that if this Window is inheriting a bound property, then no event will be fired in response to a change in the inherited property.

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

Adds a PropertyChangeListener to the listener list for a specific property. The specified property may be user-defined, or one of the following:
  • this Window's font ("font")
  • this Window's background color ("background")
  • this Window's foreground color ("foreground")
  • this Window's focusability ("focusable")
  • this Window's focus traversal keys enabled state ("focusTraversalKeysEnabled")
  • this Window's Set of FORWARD_TRAVERSAL_KEYS ("forwardFocusTraversalKeys")
  • this Window's Set of BACKWARD_TRAVERSAL_KEYS ("backwardFocusTraversalKeys")
  • this Window's Set of UP_CYCLE_TRAVERSAL_KEYS ("upCycleFocusTraversalKeys")
  • this Window's Set of DOWN_CYCLE_TRAVERSAL_KEYS ("downCycleFocusTraversalKeys")
  • this Window's focus traversal policy ("focusTraversalPolicy")
  • this Window's focusable Window state ("focusableWindowState")
  • this Window's always-on-top state("alwaysOnTop")
Note that if this Window is inheriting a bound property, then no event will be fired in response to a change in the inherited property.

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

Parameters
propertyNameone of the property names listed above
listenerthe PropertyChangeListener to be added
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
lthe window focus listener
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
lthe window listener
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
lthe window state listener
@since
1.4
Sets the ComponentOrientation property of this container and all components contained within it.
Parameters
othe new component orientation of this container and the components contained within it.
Throws
NullPointerExceptionif orientation is null.
@since
1.4
@deprecated
As of J2SE 1.4, replaced by {@link Component#applyComponentOrientation Component.applyComponentOrientation}.
@deprecated
As of J2SE 1.4, replaced by {@link Component#applyComponentOrientation Component.applyComponentOrientation}.
Returns whether the Set of focus traversal keys for the given focus traversal operation has been explicitly defined for this Container. If this method returns false, this Container is inheriting the Set from an ancestor, or from the current KeyboardFocusManager.
Parameters
idone of KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, or KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS
Return
true if the the Set of focus traversal keys for the given focus traversal operation has been explicitly defined for this Component; false otherwise.
Throws
IllegalArgumentExceptionif 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
@deprecated
As of JDK version 1.1, replaced by getBounds().
Returns the status of the construction of a screen representation of the specified image.

This method does not cause the image to begin loading. An application must use the prepareImage method to force the loading of an image.

Information on the flags returned by this method can be found with the discussion of the ImageObserver interface.

Parameters
imagethe Image object whose status is being checked
observerthe ImageObserver object to be notified as the image is being prepared
Return
the bitwise inclusive OR of ImageObserver flags indicating what information about the image is currently available
@since
JDK1.0
Returns the status of the construction of a screen representation of the specified image.

This method does not cause the image to begin loading. An application must use the prepareImage method to force the loading of an image.

The checkImage method of Component calls its peer's checkImage method to calculate the flags. If this component does not yet have a peer, the component's toolkit's checkImage method is called instead.

Information on the flags returned by this method can be found with the discussion of the ImageObserver interface.

Parameters
imagethe Image object whose status is being checked
widththe width of the scaled version whose status is to be checked
heightthe height of the scaled version whose status is to be checked
observerthe ImageObserver object to be notified as the image is being prepared
Return
the bitwise inclusive OR of ImageObserver flags indicating what information about the image is currently available
@since
JDK1.0
Checks whether this component "contains" the specified point, where x and y are defined to be relative to the coordinate system of this component.
Parameters
xthe x coordinate of the point
ythe y coordinate of the point
@since
JDK1.1
Checks whether this component "contains" the specified point, where the point's x and y coordinates are defined to be relative to the coordinate system of this component.
Parameters
pthe point
@since
JDK1.1
@deprecated
As of JDK version 1.1, replaced by getComponentCount().
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
numBuffersnumber of buffers to create
Throws
IllegalArgumentExceptionif numBuffers is less than 1.
IllegalStateExceptionif the component is not displayable
@since
1.4
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
numBuffersnumber of buffers to create, including the front buffer
capsthe required capabilities for creating the buffer strategy; cannot be null
Throws
AWTExceptionif 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.
IllegalArgumentExceptionif numBuffers is less than 1, or if caps is null
@since
1.4
Creates an image from the specified image producer.
Parameters
producerthe image producer
Return
the image produced
@since
JDK1.0
Creates an off-screen drawable image to be used for double buffering.
Parameters
widththe specified width
heightthe specified height
Return
an off-screen drawable image, which can be used for double buffering. The return value may be null if the component is not displayable. This will always happen if GraphicsEnvironment.isHeadless() returns true.
@since
JDK1.0
Creates a volatile off-screen drawable image to be used for double buffering.
Parameters
widththe specified width.
heightthe specified height.
Return
an off-screen drawable image, which can be used for double buffering. The return value may be null if the component is not displayable. This will always happen if GraphicsEnvironment.isHeadless() returns true.
@since
1.4
Creates a volatile off-screen drawable image, with the given capabilities. The contents of this image may be lost at any time due to operating system issues, so the image must be managed via the VolatileImage interface.
Parameters
widththe specified width.
heightthe specified height.
capsthe image capabilities
Return
a VolatileImage object, which can be used to manage surface contents loss and capabilities.
Throws
AWTExceptionif an image with the specified capabilities cannot be created
@since
1.4
@deprecated
As of JDK version 1.1, replaced by dispatchEvent(AWTEvent e)
@deprecated
As of JDK version 1.1, replaced by setEnabled(boolean).
Dispatches an event to this component or one of its sub components. Calls processEvent before returning for 1.1-style events which have been enabled for the Component.
Parameters
ethe event
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.

Causes this container to lay out its components. Most programs should not call this method directly, but should invoke the validate method instead.
@deprecated
As of JDK version 1.1, replaced by setEnabled(boolean).
@deprecated
As of JDK version 1.1, replaced by setEnabled(boolean).
Enables or disables input method support for this component. If input method support is enabled and the component also processes key events, incoming events are offered to the current input method and will only be processed by the component or dispatched to its listeners if the input method does not consume them. By default, input method support is enabled.
Parameters
enabletrue to enable, false to disable
@since
1.2
Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

The equals method for class Object implements the most discriminating possible equivalence relation on objects; that is, for any non-null reference values x and y, this method returns true if and only if x and y refer to the same object (x == y has the value true).

Note that it is generally necessary to override the hashCode method whenever this method is overridden, so as to maintain the general contract for the hashCode method, which states that equal objects must have equal hash codes.

Parameters
objthe reference object with which to compare.
Return
true if this object is the same as the obj argument; false otherwise.
Locates the visible child component that contains the specified position. The top-most child component is returned in the case where there is overlap in the components. If the containing child component is a Container, this method will continue searching for the deepest nested child component. Components which are not visible are ignored during the search.

The findComponentAt method is different from getComponentAt in that getComponentAt only searches the Container's immediate children; if the containing component is a Container, findComponentAt will search that child to find a nested component.

Parameters
xthe x coordinate
ythe y coordinate
Return
null if the component does not contain the position. If there is no child component at the requested point and the point is within the bounds of the container the container itself is returned.
@since
1.2
Locates the visible child component that contains the specified point. The top-most child component is returned in the case where there is overlap in the components. If the containing child component is a Container, this method will continue searching for the deepest nested child component. Components which are not visible are ignored during the search.

The findComponentAt method is different from getComponentAt in that getComponentAt only searches the Container's immediate children; if the containing component is a Container, findComponentAt will search that child to find a nested component.

Parameters
pthe point.
Return
null if the component does not contain the position. If there is no child component at the requested point and the point is within the bounds of the container the container itself is returned.
@since
1.2
Reports a bound property change.
Parameters
propertyNamethe programmatic name of the property that was changed
oldValuethe old value of the property (as a byte)
newValuethe new value of the property (as a byte)
@since
1.5
Reports a bound property change.
Parameters
propertyNamethe programmatic name of the property that was changed
oldValuethe old value of the property (as a char)
newValuethe new value of the property (as a char)
@since
1.5
Reports a bound property change.
Parameters
propertyNamethe programmatic name of the property that was changed
oldValuethe old value of the property (as a double)
newValuethe new value of the property (as a double)
@since
1.5
Reports a bound property change.
Parameters
propertyNamethe programmatic name of the property that was changed
oldValuethe old value of the property (as a float)
newValuethe new value of the property (as a float)
@since
1.5
Reports a bound property change.
Parameters
propertyNamethe programmatic name of the property that was changed
oldValuethe old value of the property (as a long)
newValuethe new value of the property (as a long)
@since
1.5
Reports a bound property change.
Parameters
propertyNamethe programmatic name of the property that was changed
oldValuethe old value of the property (as a short)
newValuethe old value of the property (as a short)
@since
1.5
Gets the AccessibleContext associated with this Frame. For frames, the AccessibleContext takes the form of an AccessibleAWTFrame. A new AccessibleAWTFrame instance is created if necessary.
Return
an AccessibleAWTFrame that serves as the AccessibleContext of this Frame
Returns the alignment along the x axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.
Returns the alignment along the y axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.
Gets the background color of this component.
Return
this component's background color; if this component does not have a background color, the background color of its parent is returned
@since
JDK1.0
Gets the bounds of this component in the form of a Rectangle object. The bounds specify this component's width, height, and location relative to its parent.
Return
a rectangle indicating this component's bounds
Stores the bounds of this component into "return value" rv and return rv. If rv is null a new Rectangle is allocated. This version of getBounds is useful if the caller wants to avoid allocating a new Rectangle object on the heap.
Parameters
rvthe return value, modified to the components bounds
Return
rv
Return
the buffer strategy used by this component
@since
1.4
Returns the runtime class of an object. That Class object is the object that is locked by static synchronized methods of the represented class.
Return
The java.lang.Class object that represents the runtime class of the object. The result is of type {@code Class} where X is the erasure of the static type of the expression on which getClass is called.
Gets the instance of ColorModel used to display the component on the output device.
Return
the color model used by this component
@since
JDK1.0
Gets the nth component in this container.
Parameters
nthe index of the component to get.
Return
the nth component in this container.
Throws
ArrayIndexOutOfBoundsExceptionif the nth value does not exist.
Locates the component that contains the x,y position. The top-most child component is returned in the case where there is overlap in the components. This is determined by finding the component closest to the index 0 that claims to contain the given point via Component.contains(), except that Components which have native peers take precedence over those which do not (i.e., lightweight Components).
Parameters
xthe x coordinate
ythe y coordinate
Return
null if the component does not contain the position. If there is no child component at the requested point and the point is within the bounds of the container the container itself is returned; otherwise the top-most child is returned.
@since
JDK1.1
Gets the component that contains the specified point.
Parameters
pthe point.
Return
returns the component that contains the point, or null if the component does not contain the point.
@since
JDK1.1
Gets the number of components in this panel.
Return
the number of components in this panel.
@since
JDK1.1
See Also
Returns an array of all the component listeners registered on this component.
Return
all of this comonent's ComponentListeners or an empty array if no component listeners are currently registered
@since
1.4
Retrieves the language-sensitive orientation that is to be used to order the elements or text within this component. LayoutManager and Component subclasses that wish to respect orientation should call this method to get the component's orientation before performing layout or drawing.
@author
Laura Werner, IBM
Gets all the components in this container.
Return
an array of all the components in this container.
Returns the z-order index of the component inside the container. The higher a component is in the z-order hierarchy, the lower its index. The component with the lowest z-order index is painted last, above all other child components.
Parameters
compthe component being queried
Return
the z-order index of the component; otherwise returns -1 if the component is null
@since
1.5
Returns an array of all the container listeners registered on this container.
Return
all of this container's ContainerListeners or an empty array if no container listeners are currently registered
@since
1.4
Gets the cursor set in the component. If the component does not have a cursor set, the cursor of its parent is returned. If no cursor is set in the entire hierarchy, Cursor.DEFAULT_CURSOR is returned.
@since
JDK1.1
See Also
@deprecated
As of JDK version 1.1, replaced by Component.getCursor().
Gets the DropTarget associated with this Component.
Gets the state of this frame. The state is represented as a bitwise mask.
  • NORMAL
    Indicates that no state bits are set.
  • ICONIFIED
  • MAXIMIZED_HORIZ
  • MAXIMIZED_VERT
  • MAXIMIZED_BOTH
    Concatenates MAXIMIZED_HORIZ and MAXIMIZED_VERT.
Return
a bitwise mask of frame state constants
@since
1.4
Returns whether this Window can become the focused Window if it meets the other requirements outlined in isFocusableWindow. If this method returns false, then isFocusableWindow will return false as well. If this method returns true, then isFocusableWindow may return true or false depending upon the other requirements which must be met in order for a Window to be focusable.

By default, all Windows have a focusable Window state of true.

Return
whether this Window can be the focused Window
@since
1.4
Always returns null because Windows have no ancestors; they represent the top of the Component hierarchy.
Return
null
@since
1.4
Returns an array of all the focus listeners registered on this component.
Return
all of this component's FocusListeners or an empty array if no component listeners are currently registered
@since
1.4
Returns the child Component of this Window that has focus if this Window is focused; returns null otherwise.
Return
the child Component with focus, or null if this Window is not focused
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.

Parameters
idone of KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, or KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS
Return
the AWTKeyStroke for the specified key
Throws
IllegalArgumentExceptionif 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
Returns whether focus traversal keys are enabled for this Component. Components for which focus traversal keys are disabled receive key events for focus traversal keys. Components for which focus traversal keys are enabled do not see these events; instead, the events are automatically converted to traversal operations.
Return
whether focus traversal keys are enabled for this Component
@since
1.4
Returns the focus traversal policy that will manage keyboard traversal of this Container's children, or null if this Container is not a focus cycle root. If no traversal policy has been explicitly set for this Container, then this Container's focus-cycle-root ancestor's policy is returned.
Return
this Container's focus traversal policy, or null if this Container is not a focus cycle root.
@since
1.4
Gets the font of this component.
Return
this component's font; if a font has not been set for this component, the font of its parent is returned
@since
JDK1.0
See Also
Gets the font metrics for the specified font.
Parameters
fontthe font for which font metrics is to be obtained
Return
the font metrics for font
@since
JDK1.0
Gets the foreground color of this component.
Return
this component's foreground color; if this component does not have a foreground color, the foreground color of its parent is returned
@since
JDK1.0
@beaninfo
bound: true
Returns an array containing all Frames created by the application. If called from an applet, the array will only include the Frames accessible by that applet.
@since
1.2
Creates a graphics context for this component. This method will return null if this component is currently not displayable.
Return
a graphics context for this component, or null if it has none
@since
JDK1.0
See Also
This method returns the GraphicsConfiguration used by this Window.
Returns the current height of this component. This method is preferable to writing component.getBounds().heightcomponent.getSize().height because it doesn't cause any heap allocations.
Return
the current height of this component
@since
1.2
Returns an array of all the hierarchy bounds listeners registered on this component.
Return
all of this component's HierarchyBoundsListeners or an empty array if no hierarchy bounds listeners are currently registered
@since
1.4
Returns an array of all the hierarchy listeners registered on this component.
Return
all of this component's HierarchyListeners or an empty array if no hierarchy listeners are currently registered
@since
1.4
Gets the image to be displayed in the minimized icon for this frame.
Return
the icon image for this frame, or null if this frame doesn't have an icon image.
Return
whether or not paint messages received from the operating system should be ignored.
@since
1.4
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.
@since
1.2
Returns an array of all the input method listeners registered on this component.
Return
all of this component's InputMethodListeners or an empty array if no input method listeners are currently registered
@since
1.4
Gets the input method request handler which supports requests from input methods for this component. A component that supports on-the-spot text input must override this method to return an InputMethodRequests instance. At the same time, it also has to handle input method events.
Return
the input method request handler for this component, null by default
@since
1.2
Determines the insets of this container, which indicate the size of the container's border.

A Frame object, for example, has a top inset that corresponds to the height of the frame's title bar.

Return
the insets of this container.
@since
JDK1.1
Returns an array of all the key listeners registered on this component.
Return
all of this component's KeyListeners or an empty array if no key listeners are currently registered
@since
1.4
Gets the layout manager for this container.
Returns an array of all the objects currently registered as FooListeners upon this Window. FooListeners are registered using the addFooListener method.

You can specify the listenerType argument with a class literal, such as FooListener.class. For example, you can query a Window w for its window listeners with the following code:

WindowListener[] wls = (WindowListener[])(w.getListeners(WindowListener.class));
If no such listeners exist, this method returns an empty array.
Parameters
listenerTypethe type of listeners requested; this parameter should specify an interface that descends from java.util.EventListener
Return
an array of all objects registered as FooListeners on this window, or an empty array if no such listeners have been added
Throws
ClassCastExceptionif listenerType doesn't specify a class or interface that implements java.util.EventListener
@since
1.3
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.
Return
the locale that is set for this window.
@since
JDK1.1
Gets the location of this component in the form of a point specifying the component's top-left corner. The location will be relative to the parent's coordinate space.

Due to the asynchronous nature of native event handling, this method can return outdated values (for instance, after several calls of setLocation() in rapid succession). For this reason, the recommended method of obtaining a component's position is within java.awt.event.ComponentListener.componentMoved(), which is called after the operating system has finished moving the component.

Return
an instance of Point representing the top-left corner of the component's bounds in the coordinate space of the component's parent
@since
JDK1.1
Stores the x,y origin of this component into "return value" rv and return rv. If rv is null a new Point is allocated. This version of getLocation is useful if the caller wants to avoid allocating a new Point object on the heap.
Parameters
rvthe return value, modified to the components location
Return
rv
Gets the location of this component in the form of a point specifying the component's top-left corner in the screen's coordinate space.
Return
an instance of Point representing the top-left corner of the component's bounds in the coordinate space of the screen
Throws
IllegalComponentStateExceptionif the component is not showing on the screen
Gets maximized bounds for this frame. Some fields may contain Integer.MAX_VALUE to indicate that system supplied values for this field must be used.
Return
maximized bounds for this frame; may be null
@since
1.4
Returns the maximum size of this container.
Gets the menu bar for this frame.
Return
the menu bar for this frame, or null if this frame doesn't have a menu bar.
Returns the minimum size of this container.
Return
an instance of Dimension that represents the minimum size of this container.
@since
JDK1.1
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.
Return
the child Component that will receive focus when this Window is focused
@since
1.4
Returns an array of all the mouse listeners registered on this component.
Return
all of this component's MouseListeners or an empty array if no mouse listeners are currently registered
@since
1.4
Returns an array of all the mouse motion listeners registered on this component.
Return
all of this component's MouseMotionListeners or an empty array if no mouse motion listeners are currently registered
@since
1.4
Returns the position of the mouse pointer in this Component's coordinate space if the Component is directly under the mouse pointer, otherwise returns null. If the Component is not showing on the screen, this method returns null even if the mouse pointer is above the area where the Component would be displayed. If the Component is partially or fully obscured by other Components or native windows, this method returns a non-null value only if the mouse pointer is located above the unobscured part of the Component.

For Containers it returns a non-null value if the mouse is above the Container itself or above any of its descendants. Use if you need to exclude children.

Sometimes the exact mouse coordinates are not important, and the only thing that matters is whether a specific Component is under the mouse pointer. If the return value of this method is null, mouse pointer is not directly above the Component.

Return
mouse coordinates relative to this Component, or null
Throws
HeadlessExceptionif GraphicsEnvironment.isHeadless() returns true
@since
1.5
Returns the position of the mouse pointer in this Container's coordinate space if the Container is under the mouse pointer, otherwise returns null. This method is similar to with the exception that it can take the Container's children into account. If allowChildren is false, this method will return a non-null value only if the mouse pointer is above the Container directly, not above the part obscured by children. If allowChildren is true, this method returns a non-null value if the mouse pointer is above Container or any of its descendants.
Parameters
allowChildrentrue if children should be taken into account
Return
mouse coordinates relative to this Component, or null
Throws
HeadlessExceptionif GraphicsEnvironment.isHeadless() returns true
@since
1.5
Returns an array of all the mouse wheel listeners registered on this component.
Return
all of this component's MouseWheelListeners or an empty array if no mouse wheel listeners are currently registered
@since
1.4
Gets the name of the component.
Return
this component's name
@since
JDK1.1
See Also
Return an array containing all the windows this window currently owns.
@since
1.2
Returns the owner of this window.
@since
1.2
Gets the parent of this component.
Return
the parent container of this component
@since
JDK1.0
@deprecated
As of JDK version 1.1, programs should not directly manipulate peers; replaced by boolean isDisplayable().
Returns the preferred size of this container.
Return
an instance of Dimension that represents the preferred size of this container.
Returns an array of all the property change listeners registered on this component.
Return
all of this component's PropertyChangeListeners or an empty array if no property change listeners are currently registered
@since
1.4
Returns an array of all the listeners which have been associated with the named property.
Return
all of the PropertyChangeListeners associated with the named property; if no such listeners have been added or if propertyName is null, an empty array is returned
@since
1.4
Returns the size of this component in the form of a Dimension object. The height field of the Dimension object contains this component's height, and the width field of the Dimension object contains this component's width.
Return
a Dimension object that indicates the size of this component
@since
JDK1.1
See Also
Stores the width/height of this component into "return value" rv and return rv. If rv is null a new Dimension object is allocated. This version of getSize is useful if the caller wants to avoid allocating a new Dimension object on the heap.
Parameters
rvthe return value, modified to the components size
Return
rv
Gets the state of this frame (obsolete).

In older versions of JDK a frame state could only be NORMAL or ICONIFIED. Since JDK 1.4 set of supported frame states is expanded and frame state is represented as a bitwise mask.

For compatibility with old programs this method still returns Frame.NORMAL and Frame.ICONIFIED but it only reports the iconic state of the frame, other aspects of frame state are not reported by this method.

Return
Frame.NORMAL or Frame.ICONIFIED.
Gets the title of the frame. The title is displayed in the frame's border.
Return
the title of this frame, or an empty string ("") if this frame doesn't have a title.
Returns the toolkit of this frame.
Return
the toolkit of this window.
Gets this component's locking object (the object that owns the thread sychronization monitor) for AWT component-tree and layout operations.
Return
this component's locking object
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.

Return
the warning string for this window.
Returns the current width of this component. This method is preferable to writing component.getBounds().width, or component.getSize().width because it doesn't cause any heap allocations.
Return
the current width of this component
@since
1.2
Returns an array of all the window focus listeners registered on this window.
Return
all of this window's WindowFocusListeners or an empty array if no window focus listeners are currently registered
@since
1.4
Returns an array of all the window listeners registered on this window.
Return
all of this window's WindowListeners or an empty array if no window listeners are currently registered
@since
1.4
Returns an array of all the window state listeners registered on this window.
Return
all of this window's WindowStateListeners or an empty array if no window state listeners are currently registered
@since
1.4
Returns the current x coordinate of the components origin. This method is preferable to writing component.getBounds().x, or component.getLocation().x because it doesn't cause any heap allocations.
Return
the current x coordinate of the components origin
@since
1.2
Returns the current y coordinate of the components origin. This method is preferable to writing component.getBounds().y, or component.getLocation().y because it doesn't cause any heap allocations.
Return
the current y coordinate of the components origin
@since
1.2
@deprecated
As of JDK version 1.1, replaced by processFocusEvent(FocusEvent).
@deprecated
As of JDK version 1.1 replaced by processEvent(AWTEvent).
Returns true if this Component is the focus owner. This method is obsolete, and has been replaced by isFocusOwner().
Return
true if this Component is the focus owner; false otherwise
@since
1.2
Returns a hash code value for the object. This method is supported for the benefit of hashtables such as those provided by java.util.Hashtable.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hashtables.

As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the JavaTM programming language.)

Return
a hash code value for this object.
@deprecated
As of JDK 5, replaced by {@link Component#setVisible(boolean) Component.setVisible(boolean)}.
Repaints the component when the image has changed. This imageUpdate method of an ImageObserver is called when more information about an image which had been previously requested using an asynchronous routine such as the drawImage method of Graphics becomes available. See the definition of imageUpdate for more information on this method and its arguments.

The imageUpdate method of Component incrementally draws an image on the component as more of the bits of the image are available.

If the system property awt.image.incrementaldraw is missing or has the value true, the image is incrementally drawn. If the system property has any other value, then the image is not drawn until it has been completely loaded.

Also, if incremental drawing is in effect, the value of the system property awt.image.redrawrate is interpreted as an integer to give the maximum redraw rate, in milliseconds. If the system property is missing or cannot be interpreted as an integer, the redraw rate is once every 100ms.

The interpretation of the x, y, width, and height arguments depends on the value of the infoflags argument.

Parameters
imgthe image being observed
infoflagssee imageUpdate for more information
xthe x coordinate
ythe y coordinate
wthe width
hthe height
Return
false if the infoflags indicate that the image is completely loaded; true otherwise.
@since
JDK1.0
@deprecated
As of JDK version 1.1, replaced by getInsets().
@deprecated
As of JDK version 1.1, replaced by contains(int, int).
Invalidates the container. The container and all parents above it are marked as needing to be laid out. This method can be called often, so it needs to execute quickly.
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.
Return
whether this is the active Window.
@since
1.4
See Also
Returns whether this window is an always-on-top window.
Return
true, if the window is in always-on-top state, false otherwise
@since
1.5
Checks if the component is contained in the component hierarchy of this container.
Parameters
cthe component
Return
true if it is an ancestor; false otherwise.
@since
JDK1.1
Returns whether the background color has been explicitly set for this Component. If this method returns false, this Component is inheriting its background color from an ancestor.
Return
true if the background color has been explicitly set for this Component; false otherwise.
@since
1.4
Returns whether the cursor has been explicitly set for this Component. If this method returns false, this Component is inheriting its cursor from an ancestor.
Return
true if the cursor has been explicitly set for this Component; false otherwise.
@since
1.4
Determines whether this component is displayable. A component is displayable when it is connected to a native screen resource.

A component is made displayable either when it is added to a displayable containment hierarchy or when its containment hierarchy is made displayable. A containment hierarchy is made displayable when its ancestor window is either packed or made visible.

A component is made undisplayable either when it is removed from a displayable containment hierarchy or when its containment hierarchy is made undisplayable. A containment hierarchy is made undisplayable when its ancestor window is disposed.

Return
true if the component is displayable, false otherwise
@since
1.2
Returns true if this component is painted to an offscreen image ("buffer") that's copied to the screen later. Component subclasses that support double buffering should override this method to return true if double buffering is enabled.
Return
false by default
Determines whether this component is enabled. An enabled component can respond to user input and generate events. Components are enabled initially by default. A component may be enabled or disabled by calling its setEnabled method.
Return
true if the component is enabled, false otherwise
@since
JDK1.0
See Also
Returns whether this Component can be focused.
Return
true if this Component is focusable; false otherwise.
@since
1.4
See Also
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.
Return
true if this Window can be the focused Window; false otherwise
@since
1.4
Always returns true because all Windows must be roots of a focus traversal cycle.
Returns whether the specified Container is the focus cycle root of this Container's focus traversal cycle. Each focus traversal cycle has only a single focus cycle root and each Container which is not a focus cycle root belongs to only a single focus traversal cycle. Containers which are focus cycle roots belong to two cycles: one rooted at the Container itself, and one rooted at the Container's nearest focus-cycle-root ancestor. This method will return true for both such Containers in this case.
Parameters
containerthe Container to be tested
Return
true if the specified Container is a focus-cycle- root of this Container; false otherwise
@since
1.4
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.

Return
whether this is the focused Window.
@since
1.4
See Also
Returns true if this Component is the focus owner.
Return
true if this Component is the focus owner; false otherwise
@since
1.4
Returns whether this Component can become the focus owner.
Return
true if this Component is focusable; false otherwise
@since
JDK1.1
@deprecated
As of 1.4, replaced by isFocusable().
See Also
Returns whether this container provides focus traversal policy. If this property is set to true then when keyboard focus manager searches container hierarchy for focus traversal policy and encounters this container before any other container with this property as true or focus cycle roots then its focus traversal policy will be used instead of focus cycle root's policy.
Return
true if this container provides focus traversal policy, false otherwise
@since
1.5
@beaninfo
bound: true
Returns whether the focus traversal policy has been explicitly set for this Container. If this method returns false, this Container will inherit its focus traversal policy from an ancestor.
Return
true if the focus traversal policy has been explicitly set for this Container; false otherwise.
@since
1.4
Returns whether the font has been explicitly set for this Component. If this method returns false, this Component is inheriting its font from an ancestor.
Return
true if the font has been explicitly set for this Component; false otherwise.
@since
1.4
Returns whether the foreground color has been explicitly set for this Component. If this method returns false, this Component is inheriting its foreground color from an ancestor.
Return
true if the foreground color has been explicitly set for this Component; false otherwise.
@since
1.4
A lightweight component doesn't have a native toolkit peer. Subclasses of Component and Container, other than the ones defined in this package like Button or Scrollbar, are lightweight. All of the Swing components are lightweights.

This method will always return false if this component is not displayable because it is impossible to determine the weight of an undisplayable component.

Return
true if this component has a lightweight peer; false if it has a native peer or no peer
@since
1.2
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.
Return
whether this Window will appear at the default location
@since
1.5
Returns true if the maximum size has been set to a non-null value otherwise returns false.
Return
true if maximumSize is non-null, false otherwise
@since
1.5
Returns whether or not setMinimumSize has been invoked with a non-null value.
Return
true if setMinimumSize has been invoked with a non-null value.
@since
1.5
Returns true if this component is completely opaque, returns false by default.

An opaque component paints every pixel within its rectangular region. A non-opaque component paints only some of its pixels, allowing the pixels underneath it to "show through". A component that does not fully paint its pixels therefore provides a degree of transparency. Only lightweight components can be transparent.

Subclasses that guarantee to always completely paint their contents should override this method and return true. All of the "heavyweight" AWT components are opaque.

Return
true if this component is completely opaque
@since
1.2
Returns true if the preferred size has been set to a non-null value otherwise returns false.
Return
true if setPreferredSize has been invoked with a non-null value.
@since
1.5
Indicates whether this frame is resizable by the user. By default, all frames are initially resizable.
Return
true if the user can resize this frame; false otherwise.
Checks if this Window is showing on screen.
Indicates whether this frame is undecorated. By default, all frames are initially decorated.
Return
true if frame is undecorated; false otherwise.
@since
1.4
Determines whether this component is valid. A component is valid when it is correctly sized and positioned within its parent container and all its children are also valid. In order to account for peers' size requirements, components are invalidated before they are first shown on the screen. By the time the parent container is fully realized, all its components will be valid.
Return
true if the component is valid, false otherwise
@since
JDK1.0
Determines whether this component should be visible when its parent is visible. Components are initially visible, with the exception of top level components such as Frame objects.
Return
true if the component is visible, false otherwise
@since
JDK1.0
See Also
@deprecated
As of JDK version 1.1, replaced by processKeyEvent(KeyEvent).
@deprecated
As of JDK version 1.1, replaced by processKeyEvent(KeyEvent).
@deprecated
As of JDK version 1.1, replaced by doLayout().
Prints a listing of this component to the standard system output stream System.out.
@since
JDK1.0
Prints a listing of this component to the specified output stream.
Parameters
outa print stream
@since
JDK1.0
Prints a listing of this container to the specified output stream. The listing starts at the specified indentation.

The immediate children of the container are printed with an indentation of indent+1. The children of those children are printed at indent+2 and so on.

Parameters
outa print stream
indentthe number of spaces to indent
@since
JDK1.0
Prints a listing to the specified print writer.
Parameters
outthe print writer to print to
@since
JDK1.1
Prints out a list, starting at the specified indentation, to the specified print writer.

The immediate children of the container are printed with an indentation of indent+1. The children of those children are printed at indent+2 and so on.

Parameters
outa print writer
indentthe number of spaces to indent
@since
JDK1.1
@deprecated
As of JDK version 1.1, replaced by getComponentAt(int, int).
@deprecated
As of JDK version 1.1, replaced by getLocation().
@deprecated
As of JDK version 1.1, replaced by processFocusEvent(FocusEvent).
@deprecated
As of JDK version 1.1, replaced by getMinimumSize().
@deprecated
As of JDK version 1.1, replaced by processMouseEvent(MouseEvent).
@deprecated
As of JDK version 1.1, replaced by processMouseMotionEvent(MouseEvent).
@deprecated
As of JDK version 1.1, replaced by processMouseEvent(MouseEvent).
@deprecated
As of JDK version 1.1, replaced by processMouseEvent(MouseEvent).
@deprecated
As of JDK version 1.1, replaced by processMouseMotionEvent(MouseEvent).
@deprecated
As of JDK version 1.1, replaced by processMouseEvent(MouseEvent).
@deprecated
As of JDK version 1.1, replaced by setLocation(int, int).
@deprecated
As of JDK version 1.1, replaced by transferFocus().
Wakes up a single thread that is waiting on this object's monitor. If any threads are waiting on this object, one of them is chosen to be awakened. The choice is arbitrary and occurs at the discretion of the implementation. A thread waits on an object's monitor by calling one of the wait methods.

The awakened thread will not be able to proceed until the current thread relinquishes the lock on this object. The awakened thread will compete in the usual manner with any other threads that might be actively competing to synchronize on this object; for example, the awakened thread enjoys no reliable privilege or disadvantage in being the next thread to lock this object.

This method should only be called by a thread that is the owner of this object's monitor. A thread becomes the owner of the object's monitor in one of three ways:

  • By executing a synchronized instance method of that object.
  • By executing the body of a synchronized statement that synchronizes on the object.
  • For objects of type Class, by executing a synchronized static method of that class.

Only one thread at a time can own an object's monitor.

Throws
IllegalMonitorStateExceptionif the current thread is not the owner of this object's monitor.
Wakes up all threads that are waiting on this object's monitor. A thread waits on an object's monitor by calling one of the wait methods.

The awakened threads will not be able to proceed until the current thread relinquishes the lock on this object. The awakened threads will compete in the usual manner with any other threads that might be actively competing to synchronize on this object; for example, the awakened threads enjoy no reliable privilege or disadvantage in being the next thread to lock this object.

This method should only be called by a thread that is the owner of this object's monitor. See the notify method for a description of the ways in which a thread can become the owner of a monitor.

Throws
IllegalMonitorStateExceptionif the current thread is not the owner of this object's monitor.
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.
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.
Parameters
gthe specified Graphics window
Paints this component and all of its subcomponents.

The origin of the graphics context, its (00) coordinate point, is the top-left corner of this component. The clipping region of the graphics context is the bounding rectangle of this component.

Parameters
gthe graphics context to use for painting
@since
JDK1.0
See Also
Paints each of the components in this container.
Parameters
gthe graphics context.
@deprecated
As of JDK version 1.1 replaced by dispatchEvent(AWTEvent).
@deprecated
As of JDK version 1.1, replaced by getPreferredSize().
Prepares an image for rendering on this component. The image data is downloaded asynchronously in another thread and the appropriate screen representation of the image is generated.
Parameters
imagethe Image for which to prepare a screen representation
observerthe ImageObserver object to be notified as the image is being prepared
Return
true if the image has already been fully prepared; false otherwise
@since
JDK1.0
Prepares an image for rendering on this component at the specified width and height.

The image data is downloaded asynchronously in another thread, and an appropriately scaled screen representation of the image is generated.

Parameters
imagethe instance of Image for which to prepare a screen representation
widththe width of the desired screen representation
heightthe height of the desired screen representation
observerthe ImageObserver object to be notified as the image is being prepared
Return
true if the image has already been fully prepared; false otherwise
@since
JDK1.0
Prints the container. This forwards the print to any lightweight components that are children of this container. If this method is reimplemented, super.print(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, print() will not be forwarded to that child.
Parameters
gthe specified Graphics window
Prints this component and all of its subcomponents.

The origin of the graphics context, its (00) coordinate point, is the top-left corner of this component. The clipping region of the graphics context is the bounding rectangle of this component.

Parameters
gthe graphics context to use for printing
@since
JDK1.0
Prints each of the components in this container.
Parameters
gthe graphics context.
Removes the specified component from this container. This method also notifies the layout manager to remove the component from this container's layout via the removeLayoutComponent method.
Parameters
compthe component to be removed
See Also
Removes the component, specified by index, from this container. This method also notifies the layout manager to remove the component from this container's layout via the removeLayoutComponent method.
Parameters
indexthe index of the component to be removed
@since
JDK1.1
See Also
Removes the specified menu bar from this frame.
Parameters
mthe menu component to remove. If m is null, then no action is taken
Removes all the components from this container. This method also notifies the layout manager to remove the components from this container's layout via the removeLayoutComponent method.
See Also
Removes the specified component listener so that it no longer receives component events from this component. This method performs no function, nor does it throw an exception, if the listener specified by the argument was not previously added to this component. If listener l is null, no exception is thrown and no action is performed.
Removes the specified container listener so it no longer receives container events from this container. If l is null, no exception is thrown and no action is performed.
Parameters
lthe container listener
Removes the specified focus listener so that it no longer receives focus events from this component. This method performs no function, nor does it throw an exception, if the listener specified by the argument was not previously added to this component. If listener l is null, no exception is thrown and no action is performed.
Parameters
lthe focus listener
@since
JDK1.1
Removes the specified hierarchy bounds listener so that it no longer receives hierarchy bounds events from this component. This method performs no function, nor does it throw an exception, if the listener specified by the argument was not previously added to this component. If listener l is null, no exception is thrown and no action is performed.
Removes the specified hierarchy listener so that it no longer receives hierarchy changed events from this component. This method performs no function, nor does it throw an exception, if the listener specified by the argument was not previously added to this component. If listener l is null, no exception is thrown and no action is performed.
Removes the specified input method listener so that it no longer receives input method events from this component. This method performs no function, nor does it throw an exception, if the listener specified by the argument was not previously added to this component. If listener l is null, no exception is thrown and no action is performed.
Removes the specified key listener so that it no longer receives key events from this component. This method performs no function, nor does it throw an exception, if the listener specified by the argument was not previously added to this component. If listener l is null, no exception is thrown and no action is performed.
Parameters
lthe key listener
@since
JDK1.1
Removes the specified mouse listener so that it no longer receives mouse events from this component. This method performs no function, nor does it throw an exception, if the listener specified by the argument was not previously added to this component. If listener l is null, no exception is thrown and no action is performed.
Parameters
lthe mouse listener
@since
JDK1.1
Removes the specified mouse motion listener so that it no longer receives mouse motion events from this component. This method performs no function, nor does it throw an exception, if the listener specified by the argument was not previously added to this component. If listener l is null, no exception is thrown and no action is performed.
Removes the specified mouse wheel listener so that it no longer receives mouse wheel events from this component. This method performs no function, nor does it throw an exception, if the listener specified by the argument was not previously added to this component. If l is null, no exception is thrown and no action is performed.
Makes this Frame undisplayable by removing its connection to its native screen resource. Making a Frame undisplayable will cause any of its children to be made undisplayable. This method is called by the toolkit internally and should not be called directly by programs.
Removes a PropertyChangeListener from the listener list. This method should be used to remove PropertyChangeListeners that were registered for all bound properties of this class.

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

Removes a PropertyChangeListener from the listener list for a specific property. This method should be used to remove PropertyChangeListeners that were registered for a specific bound property.

If propertyName or listener is null, no exception is thrown and no action is taken.

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
lthe window focus listener
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
lthe window listener
Removes the specified window state listener so that it no longer receives window events from this window. If l is null, no exception is thrown and no action is performed.
Parameters
lthe window state listener
@since
1.4
Repaints this component.

If this component is a lightweight component, this method causes a call to this component's paint method as soon as possible. Otherwise, this method causes a call to this component's update method as soon as possible.

Note: For more information on the paint mechanisms utilitized by AWT and Swing, including information on how to write the most efficient painting code, see Painting in AWT and Swing.

@since
JDK1.0
Repaints the specified rectangle of this component.

If this component is a lightweight component, this method causes a call to this component's paint method as soon as possible. Otherwise, this method causes a call to this component's update method as soon as possible.

Note: For more information on the paint mechanisms utilitized by AWT and Swing, including information on how to write the most efficient painting code, see Painting in AWT and Swing.

Parameters
xthe x coordinate
ythe y coordinate
widththe width
heightthe height
@since
JDK1.0
Repaints the component. If this component is a lightweight component, this results in a call to paint within tm milliseconds.

Note: For more information on the paint mechanisms utilitized by AWT and Swing, including information on how to write the most efficient painting code, see Painting in AWT and Swing.

Parameters
tmmaximum time in milliseconds before update
@since
JDK1.0
Repaints the specified rectangle of this component within tm milliseconds.

If this component is a lightweight component, this method causes a call to this component's paint method. Otherwise, this method causes a call to this component's update method.

Note: For more information on the paint mechanisms utilitized by AWT and Swing, including information on how to write the most efficient painting code, see Painting in AWT and Swing.

Parameters
tmmaximum time in milliseconds before update
xthe x coordinate
ythe y coordinate
widththe width
heightthe height
@since
JDK1.0
Requests that this Component get the input focus, and that this Component's top-level ancestor become the focused Window. This component must be displayable, visible, and focusable for the request to be granted. Every effort will be made to honor the request; however, in some cases it may be impossible to do so. Developers must never assume that this Component is the focus owner until this Component receives a FOCUS_GAINED event. If this request is denied because this Component's top-level Window cannot become the focused Window, the request will be remembered and will be granted when the Window is later focused by the user.

This method cannot be used to set the focus owner to no Component at all. Use KeyboardFocusManager.clearGlobalFocusOwner() instead.

Because the focus behavior of this method is platform-dependent, developers are strongly encouraged to use requestFocusInWindow when possible.

Requests that this Component get the input focus, if this Component's top-level ancestor is already the focused Window. This component must be displayable, visible, and focusable for the request to be granted. Every effort will be made to honor the request; however, in some cases it may be impossible to do so. Developers must never assume that this Component is the focus owner until this Component receives a FOCUS_GAINED event.

This method returns a boolean value. If false is returned, the request is guaranteed to fail. If true is returned, the request will succeed unless it is vetoed, or an extraordinary event, such as disposal of the Component's peer, occurs before the request can be granted by the native windowing system. Again, while a return value of true indicates that the request is likely to succeed, developers must never assume that this Component is the focus owner until this Component receives a FOCUS_GAINED event.

This method cannot be used to set the focus owner to no Component at all. Use KeyboardFocusManager.clearGlobalFocusOwner() instead.

The focus behavior of this method can be implemented uniformly across platforms, and thus developers are strongly encouraged to use this method over requestFocus when possible. Code which relies on requestFocus may exhibit different focus behavior on different platforms.

Return
false if the focus change request is guaranteed to fail; true if it is likely to succeed
@since
1.4
@deprecated
As of JDK version 1.1, replaced by setBounds(int, int, int, int).
@deprecated
As of JDK version 1.1, replaced by setSize(Dimension).
@deprecated
As of JDK version 1.1, replaced by setSize(int, int).
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 if alwaysOnTop 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
alwaysOnTopnew value of always-on-top state of the window
Throws
SecurityExceptionif the calling thread does not have permission to set the value of always-on-top property
@since
1.5
Sets the background color of this component.

The background color affects each component differently and the parts of the component that are affected by the background color may differ between operating systems.

Parameters
cthe color to become this component's color; if this parameter is null, then this component will inherit the background color of its parent
@since
JDK1.0
@beaninfo
bound: true
Moves and resizes this component to conform to the new bounding rectangle r. This component's new position is specified by r.x and r.y, and its new size is specified by r.width and r.height
Parameters
rthe new bounding rectangle for this component
@since
JDK1.1
Sets the language-sensitive orientation that is to be used to order the elements or text within this component. Language-sensitive LayoutManager and Component subclasses will use this property to determine how to lay out and draw components.

At construction time, a component's orientation is set to ComponentOrientation.UNKNOWN, indicating that it has not been specified explicitly. The UNKNOWN orientation behaves the same as ComponentOrientation.LEFT_TO_RIGHT.

To set the orientation of a single component, use this method. To set the orientation of an entire component hierarchy, use applyComponentOrientation .

@author
Laura Werner, IBM
@beaninfo
bound: true
Moves the specified component to the specified z-order index in the container. The z-order determines the order that components are painted; the component with the highest z-order paints first and the component with the lowest z-order paints last. Where components overlap, the component with the lower z-order paints over the component with the higher z-order.

If the component is a child of some other container, it is removed from that container before being added to this container. The important difference between this method and java.awt.Container.add(Component, int) is that this method doesn't call removeNotify on the component while removing it from its previous container unless necessary and when allowed by the underlying native windowing system. This way, if the component has the keyboard focus, it maintains the focus when moved to the new position.

This property is guaranteed to apply only to lightweight non-Container components.

Note: Not all platforms support changing the z-order of heavyweight components from one container into another without the call to removeNotify. There is no way to detect whether a platform supports this, so developers shouldn't make any assumptions.

Parameters
compthe component to be moved
indexthe position in the container's list to insert the component, where getComponentCount() appends to the end
Throws
NullPointerExceptionif comp is null
IllegalArgumentExceptionif comp is one of the container's parents
IllegalArgumentExceptionif index is not in the range [0, getComponentCount()] for moving between containers, or not in the range [0, getComponentCount()-1] for moving inside a container
IllegalArgumentExceptionif adding a container to itself
IllegalArgumentExceptionif adding a Window to a container
@since
1.5
Set the cursor image to a specified cursor.
Parameters
cursorOne 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
@deprecated
As of JDK version 1.1, replaced by Component.setCursor(Cursor).
Associate a DropTarget with this component. The Component will receive drops only if it is enabled.
Parameters
dtThe DropTarget
See Also
Enables or disables this component, depending on the value of the parameter b. An enabled component can respond to user input and generate events. Components are enabled initially by default.

Note: Disabling a lightweight component does not prevent it from receiving MouseEvents.

Parameters
bIf true, this component is enabled; otherwise this component is disabled
@since
JDK1.1
Sets the state of this frame. The state is represented as a bitwise mask.
  • NORMAL
    Indicates that no state bits are set.
  • ICONIFIED
  • MAXIMIZED_HORIZ
  • MAXIMIZED_VERT
  • MAXIMIZED_BOTH
    Concatenates MAXIMIZED_HORIZ and MAXIMIZED_VERT.

Note that if the state is not supported on a given platform, nothing will happen. The application may determine if a specific state is available via the java.awt.Toolkit#isFrameStateSupported(int state) method.

Parameters
statea bitwise mask of frame state constants
@since
1.4
Sets the focusable state of this Component to the specified value. This value overrides the Component's default focusability.
Parameters
focusableindicates whether this Component is focusable
@since
1.4
@beaninfo
bound: true
See Also
Sets whether this Window can become the focused Window if it meets the other requirements outlined in isFocusableWindow. If this Window's focusable Window state is set to false, then isFocusableWindow will return false. If this Window's focusable Window state is set to true, then isFocusableWindow may return true or false depending upon the other requirements which must be met in order for a Window to be focusable.

Setting a Window's focusability state to false is the standard mechanism for an application to identify to the AWT a Window which will be used as a floating palette or toolbar, and thus should be a non-focusable Window. 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
focusableWindowStatewhether this Window can be the focused Window
@since
1.4
Does nothing because Windows must always be roots of a focus traversal cycle. The passed-in value is ignored.
Parameters
focusCycleRootthis value is ignored
@since
1.4
Sets the focus traversal keys for a given traversal operation for this Container.

The default values for a Container's focus traversal keys are implementation-dependent. Sun recommends that all implementations for a particular native platform use the same default values. The recommendations for Windows and Unix are listed below. These recommendations are used in the Sun AWT implementations.
Identifier Meaning Default
KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS Normal forward keyboard traversal TAB on KEY_PRESSED, CTRL-TAB on KEY_PRESSED
KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS Normal reverse keyboard traversal SHIFT-TAB on KEY_PRESSED, CTRL-SHIFT-TAB on KEY_PRESSED
KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS Go up one focus traversal cycle none
KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS Go down one focus traversal cycle none
To disable a traversal key, use an empty Set; Collections.EMPTY_SET is recommended.

Using the AWTKeyStroke API, client code can specify on which of two specific KeyEvents, KEY_PRESSED or KEY_RELEASED, the focus traversal operation will occur. Regardless of which KeyEvent is specified, however, all KeyEvents related to the focus traversal key, including the associated KEY_TYPED event, will be consumed, and will not be dispatched to any Container. It is a runtime error to specify a KEY_TYPED event as mapping to a focus traversal operation, or to map the same event to multiple default focus traversal operations.

If a value of null is specified for the Set, this Container inherits the Set from its parent. If all ancestors of this Container have null specified for the Set, then the current KeyboardFocusManager's default Set is used.

Parameters
idone of KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, or KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS
keystrokesthe Set of AWTKeyStroke for the specified operation
Throws
IllegalArgumentExceptionif id is not one of KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, or KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS, or if keystrokes contains null, or if any Object in keystrokes is not an AWTKeyStroke, or if any keystroke represents a KEY_TYPED event, or if any keystroke already maps to another focus traversal operation for this Container
@since
1.4
@beaninfo
bound: true
Sets whether focus traversal keys are enabled for this Component. Components for which focus traversal keys are disabled receive key events for focus traversal keys. Components for which focus traversal keys are enabled do not see these events; instead, the events are automatically converted to traversal operations.
Parameters
focusTraversalKeysEnabledwhether focus traversal keys are enabled for this Component
@since
1.4
@beaninfo
bound: true
Sets the focus traversal policy that will manage keyboard traversal of this Container's children, if this Container is a focus cycle root. If the argument is null, this Container inherits its policy from its focus- cycle-root ancestor. If the argument is non-null, this policy will be inherited by all focus-cycle-root children that have no keyboard- traversal policy of their own (as will, recursively, their focus-cycle- root children).

If this Container is not a focus cycle root, the policy will be remembered, but will not be used or inherited by this or any other Containers until this Container is made a focus cycle root.

Parameters
policythe new focus traversal policy for this Container
@since
1.4
@beaninfo
bound: true
Sets whether this container will be used to provide focus traversal policy. Container with this property as true will be used to acquire focus traversal policy instead of closest focus cycle root ancestor.
Parameters
provideindicates whether this container will be used to provide focus traversal policy
@since
1.5
@beaninfo
bound: true
Sets the font of this container.
Parameters
fThe font to become this container's font.
@since
JDK1.0
Sets the foreground color of this component.
Parameters
cthe color to become this component's foreground color; if this parameter is null then this component will inherit the foreground color of its parent
@since
JDK1.0
Sets the image to be displayed in the minimized icon for this frame. Not all platforms support the concept of minimizing a window.
Parameters
imagethe icon image to be displayed. If this parameter is null then the icon image is set to the default image, which may vary with platform.
See Also
Sets whether or not paint messages received from the operating system should be ignored. This does not affect paint events generated in software by the AWT, unless they are an immediate response to an OS-level paint message.

This is useful, for example, if running under full-screen mode and better performance is desired, or if page-flipping is used as the buffer strategy.

Sets the layout manager for this container.
Parameters
mgrthe specified layout manager
Sets the locale of this component. This is a bound property.
Parameters
lthe locale to become this component's locale
@since
JDK1.1
See Also
Moves this component to a new location. The top-left corner of the new location is specified by the x and y parameters in the coordinate space of this component's parent.
Parameters
xthe x-coordinate of the new location's top-left corner in the parent's coordinate space
ythe y-coordinate of the new location's top-left corner in the parent's coordinate space
@since
JDK1.1
Moves this component to a new location. The top-left corner of the new location is specified by point p. Point p is given in the parent's coordinate space.
Parameters
pthe point defining the top-left corner of the new location, given in the coordinate space of this component's parent
@since
JDK1.1
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. 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 and setBounds 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 and flag 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 be false.
Parameters
locationByPlatformtrue if this Window should appear at the default location, false if at the current location
Throws
IllegalComponentStateExceptionif the window is showing on screen and locationByPlatform is true.
@since
1.5
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
cthe component in relation to which the window's location is determined
@since
1.4
Sets the maximized bounds for this frame.

When a frame is in maximized state the system supplies some defaults bounds. This method allows some or all of those system supplied values to be overridden.

If bounds is null, accept bounds supplied by the system. If non-null you can override some of the system supplied values while accepting others by setting those fields you want to accept from system to Integer.MAX_VALUE.

On some systems only the size portion of the bounds is taken into account.

Parameters
boundsbounds for the maximized state
@since
1.4
Sets the maximum size of this component to a constant value. Subsequent calls to getMaximumSize will always return this value. Setting the maximum size to null restores the default behavior.
Parameters
maximumSizea Dimension containing the desired maximum allowable size
@since
1.5
Sets the menu bar for this frame to the specified menu bar.
Parameters
mbthe menu bar being set. If this parameter is null then any existing menu bar on this frame is removed.
See Also
Sets the minimum size of this component to a constant value. Subsequent calls to getMinimumSize will always return this value. Setting the minimum size to null restores the default behavior.
Parameters
minimumSizethe new minimum size of this component
@since
1.5
Sets the name of the component to the specified string.
Parameters
namethe string that is to be this component's name
@since
JDK1.1
See Also
Sets the preferred size of this component to a constant value. Subsequent calls to getPreferredSize will always return this value. Setting the preferred size to null restores the default behavior.
Parameters
preferredSizeThe new preferred size, or null
@since
1.5
Sets whether this frame is resizable by the user.
Parameters
resizabletrue if this frame is resizable; false otherwise.
Resizes this component so that it has width d.width and height d.height.
Parameters
dthe dimension specifying the new size of this component
@since
JDK1.1
See Also
Resizes this component so that it has width width and height height.
Parameters
widththe new width of this component in pixels
heightthe new height of this component in pixels
@since
JDK1.1
See Also
Sets the state of this frame (obsolete).

In older versions of JDK a frame state could only be NORMAL or ICONIFIED. Since JDK 1.4 set of supported frame states is expanded and frame state is represented as a bitwise mask.

For compatibility with old programs this method still accepts Frame.NORMAL and Frame.ICONIFIED but it only changes the iconic state of the frame, other aspects of frame state are not affected by this method.

Parameters
stateeither Frame.NORMAL or Frame.ICONIFIED.
Sets the title for this frame to the specified string.
Parameters
titlethe title to be displayed in the frame's border. A null value is treated as an empty string, "".
See Also
Disables or enables decorations for this frame. This method can only be called while the frame is not displayable.
Parameters
undecoratedtrue if no frame decorations are to be enabled; false if frame decorations are to be enabled.
Throws
IllegalComponentStateExceptionif the frame is displayable.
@since
1.4
Shows or hides this component depending on the value of parameter b.
Parameters
bif true, shows this component; otherwise, hides this component
@since
JDK1.1
See Also
@deprecated
As of JDK 5, replaced by {@link Component#setVisible(boolean) Component.setVisible(boolean)}.
@deprecated
As of JDK version 1.1, replaced by setVisible(boolean).
@deprecated
As of JDK version 1.1, replaced by getSize().
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
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
Returns a string representation of this component and its values.
Return
a string representation of this component
@since
JDK1.0
Transfers the focus to the next component, as though this Component were the focus owner.
@since
JDK1.1
Transfers the focus down one focus traversal cycle. If this Container is a focus cycle root, then the focus owner is set to this Container's default Component to focus, and the current focus cycle root is set to this Container. If this Container is not a focus cycle root, then no focus traversal operation occurs.
Transfers the focus up one focus traversal cycle. Typically, the focus owner is set to this Component's focus cycle root, and the current focus cycle root is set to the new focus owner's focus cycle root. If, however, this Component's focus cycle root is a Window, then the focus owner is set to the focus cycle root's default Component to focus, and the current focus cycle root is unchanged.
Updates the container. This forwards the update to any lightweight components that are children of this container. If this method is reimplemented, super.update(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, update() will not be forwarded to that child.
Parameters
gthe specified Graphics window
Validates this container and all of its subcomponents.

The validate method is used to cause a container to lay out its subcomponents again. It should be invoked when this container's subcomponents are modified (added to or removed from the container, or layout-related information changed) after the container has been displayed.

Causes current thread to wait until another thread invokes the method or the method for this object. In other words, this method behaves exactly as if it simply performs the call wait(0).

The current thread must own this object's monitor. The thread releases ownership of this monitor and waits until another thread notifies threads waiting on this object's monitor to wake up either through a call to the notify method or the notifyAll method. The thread then waits until it can re-obtain ownership of the monitor and resumes execution.

As in the one argument version, interrupts and spurious wakeups are possible, and this method should always be used in a loop:

     synchronized (obj) {
         while (<condition does not hold>)
             obj.wait();
         ... // Perform action appropriate to condition
     }
 
This method should only be called by a thread that is the owner of this object's monitor. See the notify method for a description of the ways in which a thread can become the owner of a monitor.
Throws
IllegalMonitorStateExceptionif the current thread is not the owner of the object's monitor.
InterruptedExceptionif another thread interrupted the current thread before or while the current thread was waiting for a notification. The interrupted status of the current thread is cleared when this exception is thrown.
Causes current thread to wait until either another thread invokes the method or the method for this object, or a specified amount of time has elapsed.

The current thread must own this object's monitor.

This method causes the current thread (call it T) to place itself in the wait set for this object and then to relinquish any and all synchronization claims on this object. Thread T becomes disabled for thread scheduling purposes and lies dormant until one of four things happens:

  • Some other thread invokes the notify method for this object and thread T happens to be arbitrarily chosen as the thread to be awakened.
  • Some other thread invokes the notifyAll method for this object.
  • Some other thread interrupts thread T.
  • The specified amount of real time has elapsed, more or less. If timeout is zero, however, then real time is not taken into consideration and the thread simply waits until notified.
The thread T is then removed from the wait set for this object and re-enabled for thread scheduling. It then competes in the usual manner with other threads for the right to synchronize on the object; once it has gained control of the object, all its synchronization claims on the object are restored to the status quo ante - that is, to the situation as of the time that the wait method was invoked. Thread T then returns from the invocation of the wait method. Thus, on return from the wait method, the synchronization state of the object and of thread T is exactly as it was when the wait method was invoked.

A thread can also wake up without being notified, interrupted, or timing out, a so-called spurious wakeup. While this will rarely occur in practice, applications must guard against it by testing for the condition that should have caused the thread to be awakened, and continuing to wait if the condition is not satisfied. In other words, waits should always occur in loops, like this one:

     synchronized (obj) {
         while (<condition does not hold>)
             obj.wait(timeout);
         ... // Perform action appropriate to condition
     }
 
(For more information on this topic, see Section 3.2.3 in Doug Lea's "Concurrent Programming in Java (Second Edition)" (Addison-Wesley, 2000), or Item 50 in Joshua Bloch's "Effective Java Programming Language Guide" (Addison-Wesley, 2001).

If the current thread is interrupted by another thread while it is waiting, then an InterruptedException is thrown. This exception is not thrown until the lock status of this object has been restored as described above.

Note that the wait method, as it places the current thread into the wait set for this object, unlocks only this object; any other objects on which the current thread may be synchronized remain locked while the thread waits.

This method should only be called by a thread that is the owner of this object's monitor. See the notify method for a description of the ways in which a thread can become the owner of a monitor.

Parameters
timeoutthe maximum time to wait in milliseconds.
Throws
IllegalArgumentExceptionif the value of timeout is negative.
IllegalMonitorStateExceptionif the current thread is not the owner of the object's monitor.
InterruptedExceptionif another thread interrupted the current thread before or while the current thread was waiting for a notification. The interrupted status of the current thread is cleared when this exception is thrown.
Causes current thread to wait until another thread invokes the method or the method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.

This method is similar to the wait method of one argument, but it allows finer control over the amount of time to wait for a notification before giving up. The amount of real time, measured in nanoseconds, is given by:

 1000000*timeout+nanos

In all other respects, this method does the same thing as the method of one argument. In particular, wait(0, 0) means the same thing as wait(0).

The current thread must own this object's monitor. The thread releases ownership of this monitor and waits until either of the following two conditions has occurred:

  • Another thread notifies threads waiting on this object's monitor to wake up either through a call to the notify method or the notifyAll method.
  • The timeout period, specified by timeout milliseconds plus nanos nanoseconds arguments, has elapsed.

The thread then waits until it can re-obtain ownership of the monitor and resumes execution.

As in the one argument version, interrupts and spurious wakeups are possible, and this method should always be used in a loop:

     synchronized (obj) {
         while (<condition does not hold>)
             obj.wait(timeout, nanos);
         ... // Perform action appropriate to condition
     }
 
This method should only be called by a thread that is the owner of this object's monitor. See the notify method for a description of the ways in which a thread can become the owner of a monitor.
Parameters
timeoutthe maximum time to wait in milliseconds.
nanosadditional time, in nanoseconds range 0-999999.
Throws
IllegalArgumentExceptionif the value of timeout is negative or the value of nanos is not in the range 0-999999.
IllegalMonitorStateExceptionif the current thread is not the owner of this object's monitor.
InterruptedExceptionif another thread interrupted the current thread before or while the current thread was waiting for a notification. The interrupted status of the current thread is cleared when this exception is thrown.