This class is the abstract superclass of all actual implementations of the Abstract Window Toolkit. Subclasses of Toolkit are used to bind the various components to particular native toolkit implementations.

Many GUI operations may be performed asynchronously. This means that if you set the state of a component, and then immediately query the state, the returned value may not yet reflect the requested change. This includes, but is not limited to:

Most applications should not call any of the methods in this class directly. The methods defined by Toolkit are the "glue" that joins the platform-independent classes in the java.awt package with their counterparts in java.awt.peer. Some methods defined by Toolkit query the native operating system directly.

@version
1.203, 12/19/03
@author
Sami Shaio
@author
Arthur van Hoff
@author
Fred Ecks
@since
JDK1.0
Adds an AWTEventListener to receive all AWTEvents dispatched system-wide that conform to the given eventMask.

First, if there is a security manager, its checkPermission method is called with an AWTPermission("listenToAllAWTEvents") permission. This may result in a SecurityException.

eventMask is a bitmask of event types to receive. It is constructed by bitwise OR-ing together the event masks defined in AWTEvent.

Note: event listener use is not recommended for normal application use, but are intended solely to support special purpose facilities including support for accessibility, event record/playback, and diagnostic tracing. If listener is null, no exception is thrown and no action is performed.

Parameters
listenerthe event listener.
eventMaskthe bitmask of event types to receive
Throws
SecurityException if a security manager exists and its checkPermission method doesn't allow the operation.
@since
1.2
Adds the specified property change listener for the named desktop property. If pcl is null, no exception is thrown and no action is performed.
Parameters
nameThe name of the property to listen for
pclThe property change listener
@since
1.2
Emits an audio beep.
@since
JDK1.1
Indicates the construction status of a specified image that is being prepared for display.

If the values of the width and height arguments are both -1, this method returns the construction status of a screen representation of the specified image in this toolkit. Otherwise, this method returns the construction status of a scaled representation of the image at the specified width and height.

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

This method is called by the component's checkImage methods.

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

Parameters
imagethe image whose status is being checked.
widththe width of the scaled version whose status is being checked, or -1.
heightthe height of the scaled version whose status is being checked, or -1.
observerthe ImageObserver object to be notified as the image is being prepared.
Return
the bitwise inclusive OR of the ImageObserver flags for the image data that is currently available.
Creates a new custom cursor object. If the image to display is invalid, the cursor will be hidden (made completely transparent), and the hotspot will be set to (0, 0).

Note that multi-frame images are invalid and may cause this method to hang.

Parameters
cursorthe image to display when the cursor is actived
hotSpotthe X and Y of the large cursor's hot spot; the hotSpot values must be less than the Dimension returned by getBestCursorSize
namea localized description of the cursor, for Java Accessibility use
Throws
IndexOutOfBoundsExceptionif the hotSpot values are outside the bounds of the cursor
HeadlessExceptionif GraphicsEnvironment.isHeadless() returns true
@since
1.2
Creates a concrete, platform dependent, subclass of the abstract DragGestureRecognizer class requested, and associates it with the DragSource, Component and DragGestureListener specified. subclasses should override this to provide their own implementation
Parameters
abstractRecognizerClassThe abstract class of the required recognizer
dsThe DragSource
cThe Component target for the DragGestureRecognizer
srcActionsThe actions permitted for the gesture
dglThe DragGestureListener
Return
the new object or null. Always returns null if GraphicsEnvironment.isHeadless() returns true.
Creates the peer for a DragSourceContext. Always throws InvalidDndOperationException if GraphicsEnvironment.isHeadless() returns true.
Creates an image which decodes the image stored in the specified byte array.

The data must be in some image format, such as GIF or JPEG, that is supported by this toolkit.

Parameters
imagedataan array of bytes, representing image data in a supported image format.
Return
an image.
@since
JDK1.1
Creates an image which decodes the image stored in the specified byte array, and at the specified offset and length. The data must be in some image format, such as GIF or JPEG, that is supported by this toolkit.
Parameters
imagedataan array of bytes, representing image data in a supported image format.
imageoffsetthe offset of the beginning of the data in the array.
imagelengththe length of the data in the array.
Return
an image.
@since
JDK1.1
Creates an image with the specified image producer.
Parameters
producerthe image producer to be used.
Return
an image with the specified image producer.
Returns an image which gets pixel data from the specified file. The returned Image is a new object which will not be shared with any other caller of this method or its getImage variant.
Parameters
filenamethe name of a file containing pixel data in a recognized file format.
Return
an image which gets its pixel data from the specified file.
Returns an image which gets pixel data from the specified URL. The returned Image is a new object which will not be shared with any other caller of this method or its getImage variant.
Parameters
urlthe URL to use in fetching the pixel data.
Return
an image which gets its pixel data from the specified URL.
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.
Returns an array of all the AWTEventListeners registered on this toolkit. Listeners can be returned within AWTEventListenerProxy objects, which also contain the event mask for the given listener. Note that listener objects added multiple times appear only once in the returned array.
Return
all of the AWTEventListeners or an empty array if no listeners are currently registered
Throws
SecurityException if a security manager exists and its checkPermission method doesn't allow the operation.
@since
1.4
Returns an array of all the AWTEventListeners registered on this toolkit which listen to all of the event types indicates in the eventMask argument. Listeners can be returned within AWTEventListenerProxy objects, which also contain the event mask for the given listener. Note that listener objects added multiple times appear only once in the returned array.
Parameters
eventMaskthe bitmask of event types to listen for
Return
all of the AWTEventListeners registered on this toolkit for the specified event types, or an empty array if no such listeners are currently registered
Throws
SecurityException if a security manager exists and its checkPermission method doesn't allow the operation.
@since
1.4
Returns the supported cursor dimension which is closest to the desired sizes. Systems which only support a single cursor size will return that size regardless of the desired sizes. Systems which don't support custom cursors will return a dimension of 0, 0.

Note: if an image is used whose dimensions don't match a supported size (as returned by this method), the Toolkit implementation will attempt to resize the image to a supported size. Since converting low-resolution images is difficult, no guarantees are made as to the quality of a cursor image which isn't a supported size. It is therefore recommended that this method be called and an appropriate image used so no image conversion is made.

Parameters
preferredWidththe preferred cursor width the component would like to use.
preferredHeightthe preferred cursor height the component would like to use.
Return
the closest matching supported cursor size, or a dimension of 0,0 if the Toolkit implementation doesn't support custom cursors.
Throws
HeadlessExceptionif GraphicsEnvironment.isHeadless() returns true
@since
1.2
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.
Determines the color model of this toolkit's screen.

ColorModel is an abstract class that encapsulates the ability to translate between the pixel values of an image and its red, green, blue, and alpha components.

This toolkit method is called by the getColorModel method of the Component class.

Return
the color model of this toolkit's screen.
Throws
HeadlessExceptionif GraphicsEnvironment.isHeadless() returns true
Gets the default toolkit.

If there is a system property named "awt.toolkit", that property is treated as the name of a class that is a subclass of Toolkit.

If the system property does not exist, then the default toolkit used is the class named "sun.awt.motif.MToolkit", which is a motif implementation of the Abstract Window Toolkit.

Also loads additional classes into the VM, using the property 'assistive_technologies' specified in the Sun reference implementation by a line in the 'accessibility.properties' file. The form is "assistive_technologies=..." where the "..." is a comma-separated list of assistive technology classes to load. Each class is loaded in the order given and a single instance of each is created using Class.forName(class).newInstance(). This is done just after the AWT toolkit is created. All errors are handled via an AWTError exception.

Return
the default toolkit.
Throws
AWTErrorif a toolkit could not be found, or if one could not be accessed or instantiated.
Obtains a value for the specified desktop property. A desktop property is a uniquely named value for a resource that is Toolkit global in nature. Usually it also is an abstract representation for an underlying platform dependent desktop setting.
Returns the names of the available fonts in this toolkit.

For 1.1, the following font names are deprecated (the replacement name follows):

  • TimesRoman (use Serif)
  • Helvetica (use SansSerif)
  • Courier (use Monospaced)

The ZapfDingbats fontname is also deprecated in 1.1 but the characters are defined in Unicode starting at 0x2700, and as of 1.1 Java supports those characters.

Return
the names of the available fonts in this toolkit.
@deprecated
see {@link java.awt.GraphicsEnvironment#getAvailableFontFamilyNames()}
Gets the screen device metrics for rendering of the font.
Parameters
fonta font
Return
the screen metrics of the specified font in this toolkit
@deprecated
As of JDK version 1.2, replaced by the Font method getLineMetrics.
Returns an image which gets pixel data from the specified file, whose format can be either GIF, JPEG or PNG. The underlying toolkit attempts to resolve multiple requests with the same filename to the same returned Image. Since the mechanism required to facilitate this sharing of Image objects may continue to hold onto images that are no longer of use for an indefinite period of time, developers are encouraged to implement their own caching of images by using the createImage variant wherever available.
Parameters
filenamethe name of a file containing pixel data in a recognized file format.
Return
an image which gets its pixel data from the specified file.
Returns an image which gets pixel data from the specified URL. The pixel data referenced by the specified URL must be in one of the following formats: GIF, JPEG or PNG. The underlying toolkit attempts to resolve multiple requests with the same URL to the same returned Image. Since the mechanism required to facilitate this sharing of Image objects may continue to hold onto images that are no longer of use for an indefinite period of time, developers are encouraged to implement their own caching of images by using the createImage variant wherever available.
Parameters
urlthe URL to use in fetching the pixel data.
Return
an image which gets its pixel data from the specified URL.
Returns whether the given locking key on the keyboard is currently in its "on" state. Valid key codes are VK_CAPS_LOCK , VK_NUM_LOCK , VK_SCROLL_LOCK , and VK_KANA_LOCK .
Throws
java.lang.IllegalArgumentExceptionif keyCode is not one of the valid key codes
java.lang.UnsupportedOperationExceptionif the host system doesn't allow getting the state of this key programmatically, or if the keyboard doesn't have this key
HeadlessExceptionif GraphicsEnvironment.isHeadless() returns true
@since
1.3
Returns the maximum number of colors the Toolkit supports in a custom cursor palette.

Note: if an image is used which has more colors in its palette than the supported maximum, the Toolkit implementation will attempt to flatten the palette to the maximum. Since converting low-resolution images is difficult, no guarantees are made as to the quality of a cursor image which has more colors than the system supports. It is therefore recommended that this method be called and an appropriate image used so no image conversion is made.

Return
the maximum number of colors, or zero if custom cursors are not supported by this Toolkit implementation.
Throws
HeadlessExceptionif GraphicsEnvironment.isHeadless() returns true
@since
1.2
Determines which modifier key is the appropriate accelerator key for menu shortcuts.

Menu shortcuts, which are embodied in the MenuShortcut class, are handled by the MenuBar class.

By default, this method returns Event.CTRL_MASK. Toolkit implementations should override this method if the Control key isn't the correct key for accelerators.

Return
the modifier mask on the Event class that is used for menu shortcuts on this toolkit.
Throws
HeadlessExceptionif GraphicsEnvironment.isHeadless() returns true
@since
JDK1.1
Gets a PrintJob object which is the result of initiating a print operation on the toolkit's platform.

Each actual implementation of this method should first check if there is a security manager installed. If there is, the method should call the security manager's checkPrintJobAccess method to ensure initiation of a print operation is allowed. If the default implementation of checkPrintJobAccess is used (that is, that method is not overriden), then this results in a call to the security manager's checkPermission method with a RuntimePermission("queuePrintJob") permission.

Parameters
framethe parent of the print dialog. May be null if and only if jobAttributes is not null and jobAttributes.getDialog() returns JobAttributes.DialogType.NONE or JobAttributes.DialogType.COMMON.
jobtitlethe title of the PrintJob. A null title is equivalent to "".
jobAttributesa set of job attributes which will control the PrintJob. The attributes will be updated to reflect the user's choices as outlined in the JobAttributes documentation. May be null.
pageAttributesa set of page attributes which will control the PrintJob. The attributes will be applied to every page in the job. The attributes will be updated to reflect the user's choices as outlined in the PageAttributes documentation. May be null.
Return
a PrintJob object, or null if the user cancelled the print job.
Throws
NullPointerExceptionif frame is null and either jobAttributes is null or jobAttributes.getDialog() returns JobAttributes.DialogType.NATIVE.
IllegalArgumentExceptionif pageAttributes specifies differing cross feed and feed resolutions. This exception is always thrown when GraphicsEnvironment.isHeadless() returns true.
SecurityExceptionif this thread is not allowed to initiate a print job request, or if jobAttributes specifies print to file, and this thread is not allowed to access the file system
@since
1.3
Gets a PrintJob object which is the result of initiating a print operation on the toolkit's platform.

Each actual implementation of this method should first check if there is a security manager installed. If there is, the method should call the security manager's checkPrintJobAccess method to ensure initiation of a print operation is allowed. If the default implementation of checkPrintJobAccess is used (that is, that method is not overriden), then this results in a call to the security manager's checkPermission method with a RuntimePermission("queuePrintJob") permission.

Parameters
framethe parent of the print dialog. May not be null.
jobtitlethe title of the PrintJob. A null title is equivalent to "".
propsa Properties object containing zero or more properties. Properties are not standardized and are not consistent across implementations. Because of this, PrintJobs which require job and page control should use the version of this function which takes JobAttributes and PageAttributes objects. This object may be updated to reflect the user's job choices on exit. May be null.
Return
a PrintJob object, or null if the user cancelled the print job.
Throws
NullPointerExceptionif frame is null. This exception is always thrown when GraphicsEnvironment.isHeadless() returns true.
SecurityExceptionif this thread is not allowed to initiate a print job request
@since
JDK1.1
Gets a property with the specified key and default. This method returns defaultValue if the property is not found.
Returns an array of all the property change listeners registered on this toolkit.
Return
all of this toolkit's PropertyChangeListeners or an empty array if no property change listeners are currently registered
@since
1.4
Returns an array of all the PropertyChangeListeners associated with the named property.
Parameters
propertyNamethe named property
Return
all of the PropertyChangeListeners associated with the named property or an empty array if no such listeners have been added
@since
1.4
Gets the insets of the screen.
Parameters
gca GraphicsConfiguration
Return
the insets of this toolkit's screen, in pixels.
Throws
HeadlessExceptionif GraphicsEnvironment.isHeadless() returns true
@since
1.4
Returns the screen resolution in dots-per-inch.
Return
this toolkit's screen resolution, in dots-per-inch.
Throws
HeadlessExceptionif GraphicsEnvironment.isHeadless() returns true
Gets the size of the screen. On systems with multiple displays, the primary display is used. Multi-screen aware display dimensions are available from GraphicsConfiguration and GraphicsDevice.
Return
the size of this toolkit's screen, in pixels.
Throws
HeadlessExceptionif GraphicsEnvironment.isHeadless() returns true
Gets the singleton instance of the system Clipboard which interfaces with clipboard facilities provided by the native platform. This clipboard enables data transfer between Java programs and native applications which use native clipboard facilities.

In addition to any and all formats specified in the flavormap.properties file, or other file specified by the AWT.DnD.flavorMapFileURL Toolkit property, text returned by the system Clipboard's getTransferData() method is available in the following flavors:

  • DataFlavor.stringFlavor
  • DataFlavor.plainTextFlavor (deprecated)
As with java.awt.datatransfer.StringSelection, if the requested flavor is DataFlavor.plainTextFlavor, or an equivalent flavor, a Reader is returned. Note: The behavior of the system Clipboard's getTransferData() method for DataFlavor.plainTextFlavor, and equivalent DataFlavors, is inconsistent with the definition of DataFlavor.plainTextFlavor . Because of this, support for DataFlavor.plainTextFlavor, and equivalent flavors, is deprecated.

Each actual implementation of this method should first check if there is a security manager installed. If there is, the method should call the security manager's checkSystemClipboardAccess method to ensure it's ok to to access the system clipboard. If the default implementation of checkSystemClipboardAccess is used (that is, that method is not overriden), then this results in a call to the security manager's checkPermission method with an AWTPermission("accessClipboard") permission.

Get the application's or applet's EventQueue instance. Depending on the Toolkit implementation, different EventQueues may be returned for different applets. Applets should therefore not assume that the EventQueue instance returned by this method will be shared by other applets or the system.

First, if there is a security manager, its checkAwtEventQueueAccess method is called. If the default implementation of checkAwtEventQueueAccess is used (that is, that method is not overriden), then this results in a call to the security manager's checkPermission method with an AWTPermission("accessEventQueue") permission.

Return
the EventQueue object
Throws
SecurityException if a security manager exists and its {@link java.lang.SecurityManager#checkAwtEventQueueAccess} method denies access to the EventQueue
Gets the singleton instance of the system selection as a Clipboard object. This allows an application to read and modify the current, system-wide selection.

An application is responsible for updating the system selection whenever the user selects text, using either the mouse or the keyboard. Typically, this is implemented by installing a FocusListener on all Components which support text selection, and, between FOCUS_GAINED and FOCUS_LOST events delivered to that Component, updating the system selection Clipboard when the selection changes inside the Component. Properly updating the system selection ensures that a Java application will interact correctly with native applications and other Java applications running simultaneously on the system. Note that java.awt.TextComponent and javax.swing.text.JTextComponent already adhere to this policy. When using these classes, and their subclasses, developers need not write any additional code.

Some platforms do not support a system selection Clipboard. On those platforms, this method will return null. In such a case, an application is absolved from its responsibility to update the system selection Clipboard as described above.

Each actual implementation of this method should first check if there is a SecurityManager installed. If there is, the method should call the SecurityManager's checkSystemClipboardAccess method to ensure that client code has access the system selection. If the default implementation of checkSystemClipboardAccess is used (that is, if the method is not overridden), then this results in a call to the SecurityManager's checkPermission method with an AWTPermission("accessClipboard") permission.

Return
the system selection as a Clipboard, or null if the native platform does not support a system selection Clipboard
Throws
HeadlessExceptionif GraphicsEnvironment.isHeadless() returns true
@since
1.4
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.
Returns whether dynamic layout of Containers on resize is currently active (both set programmatically, and supported by the underlying operating system and/or window manager). The OS/WM support can be queried using getDesktopProperty("awt.dynamicLayoutSupported").
Return
true if dynamic layout of Containers on resize is currently active, false otherwise.
Throws
HeadlessExceptionif GraphicsEnvironment.isHeadless() returns true
@since
1.4
Returns whether Toolkit supports this state for Frames. This method tells whether the UI concept of, say, maximization or iconification is supported. It will always return false for "compound" states like Frame.ICONIFIED|Frame.MAXIMIZED_VERT. In other words, the rule of thumb is that only queries with a single frame state constant as an argument are meaningful.
Parameters
stateone of named frame state constants.
Return
true is this frame state is supported by this Toolkit implementation, false otherwise.
Throws
HeadlessException if GraphicsEnvironment.isHeadless() returns true.
@since
1.4
Returns a map of visual attributes for the abstract level description of the given input method highlight, or null if no mapping is found. The style field of the input method highlight is ignored. The map returned is unmodifiable.
Parameters
highlightinput method highlight
Return
style attribute map, or null
Throws
HeadlessExceptionif GraphicsEnvironment.isHeadless returns true
@since
1.3
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.
Prepares an image for rendering.

If the values of the width and height arguments are both -1, this method prepares the image for rendering on the default screen; otherwise, this method prepares an image for rendering on the default screen 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.

This method is called by components prepareImage methods.

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

Parameters
imagethe image for which to prepare a screen representation.
widththe width of the desired screen representation, or -1.
heightthe height of the desired screen representation, or -1.
observerthe ImageObserver object to be notified as the image is being prepared.
Return
true if the image has already been fully prepared; false otherwise.
Removes an AWTEventListener from receiving dispatched AWTEvents.

First, if there is a security manager, its checkPermission method is called with an AWTPermission("listenToAllAWTEvents") permission. This may result in a SecurityException.

Note: event listener use is not recommended for normal application use, but are intended solely to support special purpose facilities including support for accessibility, event record/playback, and diagnostic tracing. If listener is null, no exception is thrown and no action is performed.

Parameters
listenerthe event listener.
Throws
SecurityException if a security manager exists and its checkPermission method doesn't allow the operation.
@since
1.2
Removes the specified property change listener for the named desktop property. If pcl is null, no exception is thrown and no action is performed.
Parameters
nameThe name of the property to remove
pclThe property change listener
@since
1.2
Controls whether the layout of Containers is validated dynamically during resizing, or statically, after resizing is complete. Note that this feature is not supported on all platforms, and conversely, that this feature cannot be turned off on some platforms. On platforms where dynamic layout during resize is not supported (or is always supported), setting this property has no effect. Note that this feature can be set or unset as a property of the operating system or window manager on some platforms. On such platforms, the dynamic resize property must be set at the operating system or window manager level before this method can take effect. This method does not change the underlying operating system or window manager support or settings. The OS/WM support can be queried using getDesktopProperty("awt.dynamicLayoutSupported").
Parameters
dynamicIf true, Containers should re-layout their components as the Container is being resized. If false, the layout will be validated after resizing is finished.
Throws
HeadlessExceptionif GraphicsEnvironment.isHeadless() returns true
@since
1.4
Sets the state of the given locking key on the keyboard. Valid key codes are VK_CAPS_LOCK , VK_NUM_LOCK , VK_SCROLL_LOCK , and VK_KANA_LOCK .

Depending on the platform, setting the state of a locking key may involve event processing and therefore may not be immediately observable through getLockingKeyState.

Throws
java.lang.IllegalArgumentExceptionif keyCode is not one of the valid key codes
java.lang.UnsupportedOperationExceptionif the host system doesn't allow setting the state of this key programmatically, or if the keyboard doesn't have this key
HeadlessExceptionif GraphicsEnvironment.isHeadless() returns true
@since
1.3
Synchronizes this toolkit's graphics state. Some window systems may do buffering of graphics events.

This method ensures that the display is up-to-date. It is useful for animation.

Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 
Return
a string representation of the object.
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.