Toolkit class are used to bind the various components
to particular native toolkit implementations.
Many GUI events may be delivered to user asynchronously, if the opposite is not specified explicitly. As well as many GUI operations may be performed asynchronously. This fact means that if the state of a component is set, and then the state immediately queried, the returned value may not yet reflect the requested change. This behavior includes, but is not limited to:
ScrollPane.setScrollPosition
and then getScrollPosition may return an incorrect
value if the original request has not yet been processed.
setVisible(true) on a Window,
Frame or Dialog may occur
asynchronously.
setSize, setBounds or
setLocation on a Window,
Frame or Dialog are forwarded
to the underlying window management system and may be
ignored or modified. See java.awt.Window for
more information.
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.
| Modifier and Type | Class and Description |
|---|---|
| private static class | Toolkit.
This is a utility class to support desktop properties. |
| private static class | |
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private static String | atNames
Used internally by the assistive technologies functions; set at init time and used at load time |
| private int[] | |
| protected final Map | desktopProperties
The desktop properties. |
| protected final PropertyChangeSupport | desktopPropsSupport
The desktop properties change support. |
| private static volatile long | |
| private AWTEventListener | |
| private final WeakHashMap | |
| private static boolean | loaded
Warning This is a temporary workaround for a problem in the way the AWT loads native libraries. |
| private static final int | |
| private static ResourceBundle | |
| private static ResourceBundle | resources
Support for I18N: any visible strings should be stored in sun.awt.resources.awt.properties. |
| private static Toolkit | toolkit
The default toolkit. |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public void | addAWTEventListener(AWTEventListener
the event listener. listener, long the bitmask of event types to receive eventMask)Adds an AWTEventListener to receive all AWTEvents dispatched
system-wide that conform to the given |
| public void | addPropertyChangeListener(String
The name of the property to listen for name, PropertyChangeListener The property change listener pcl)Adds the specified property change listener for the named desktop property. |
| public boolean | Returns: true if events from extra mouse buttons are allowed to be processed and posted;
false otherwiseReports whether events from extra mouse buttons are allowed to be processed and posted into
|
| public abstract void | |
| public abstract int | Returns: the bitwise inclusive OR of theImageObserver flags for the
image data that is currently available.the image whose status is being checked. image, int the width of the scaled version whose status is
being checked, or width, int -1.the height of the scaled version whose status
is being checked, or height, ImageObserver -1.the observer)ImageObserver object to be
notified as the image is being prepared.Indicates the construction status of a specified image that is being prepared for display. |
| pack-priv synchronized int | |
| public Cursor | Returns: the cursor createdthe image to display when the cursor is activated cursor, Point the X and Y of the large cursor's hot spot; the
hotSpot values must be less than the Dimension returned by
hotSpot, String getBestCursorSizea localized description of the cursor, for Java Accessibility use name)Creates a new custom cursor object. |
| public < the type of DragGestureRecognizer to create T extends DragGestureRecognizer> T | Returns: the new object or null. Always returns null if GraphicsEnvironment.isHeadless() returns true.The abstract class of the required recognizer abstractRecognizerClass, DragSource The DragSource ds, Component The Component target for the DragGestureRecognizer c, int The actions permitted for the gesture srcActions, DragGestureListener The DragGestureListener dgl)Creates a concrete, platform dependent, subclass of the abstract DragGestureRecognizer class requested, and associates it with the DragSource, Component and DragGestureListener specified. |
| public abstract Image | Returns: an image which gets its pixel data from the specified file.the name of a file containing pixel data
in a recognized file format. filename)Returns an image which gets pixel data from the specified file. |
| public abstract Image | Returns: an image which gets its pixel data from the specified URL.the URL to use in fetching the pixel data. url)Returns an image which gets pixel data from the specified URL. |
| public abstract Image | Returns: an image with the specified image producer.the image producer to be used. producer)Creates an image with the specified image producer. |
| public Image | Returns: an image.an array of bytes, representing
image data in a supported image format. imagedata)Creates an image which decodes the image stored in the specified byte array. |
| public abstract Image | Returns: an image.an array of bytes, representing
image data in a supported image format. imagedata, int the offset of the beginning
of the data in the array. imageoffset, int the length of the data in the array. imagelength)Creates an image which decodes the image stored in the specified byte array, and at the specified offset and length. |
| private static PropertyChangeSupport | |
| private static AWTEventListener | |
| pack-priv static boolean | |
| private static void | fallbackToLoadClassForAT(String
the name of the class to be loaded atName)When a service provider for Assistive Technology is not found look for a supporting class on the class path and instantiate it. |
| public AWTEventListener[] | Returns: all of theAWTEventListeners or an empty
array if no listeners are currently registeredReturns an array of all the |
| public AWTEventListener[] | Returns: all of theAWTEventListeners registered
on this toolkit for the specified
event types, or an empty array if no such listeners
are currently registeredthe bitmask of event types to listen for eventMask)Returns an array of all the |
| public Dimension | Returns: the closest matching supported cursor size, or a dimension of 0,0 if the Toolkit implementation doesn't support custom cursors.the preferred cursor width the component would like
to use. preferredWidth, int the preferred cursor height the component would like
to use. preferredHeight)Returns the supported cursor dimension which is closest to the desired sizes. |
| public abstract ColorModel | Returns: the color model of this toolkit's screen.Determines the color model of this toolkit's screen. |
| public static synchronized Toolkit | |
| public final synchronized Object | Returns: the value for the specified desktop propertythe property name propertyName)Obtains a value for the specified desktop property. |
| pack-priv static EventQueue | |
| public abstract String[] | Returns: the names of the available fonts in this toolkit.
Deprecated
see
java.
Returns the names of the available fonts in this toolkit. |
| public abstract FontMetrics | Returns: the screen metrics of the specified font in this toolkita font font)
Deprecated
As of JDK version 1.2, replaced by the
Font
method getLineMetrics.
Gets the screen device metrics for rendering of the font. |
| public abstract Image | |
| public abstract Image | |
| public boolean | Returns: true if the given key is currently in its "on" state;
otherwise falsethe key code keyCode)Returns whether the given locking key on the keyboard is currently in its "on" state. |
| public int | Returns: the maximum number of colors, or zero if custom cursors are not supported by this Toolkit implementation.Returns the maximum number of colors the Toolkit supports in a custom cursor palette. |
| public int | Returns: the modifier mask on theEvent class
that is used for menu shortcuts on this toolkit.
Deprecated
since 10. It is recommended that extended modifier keys and
getMenuShortcutKeyMaskEx() be used instead
Determines which modifier key is the appropriate accelerator key for menu shortcuts. |
| public int | Returns: the modifier mask on theInputEvent class that is used
for menu shortcuts on this toolkitDetermines which extended modifier key is the appropriate accelerator key for menu shortcuts. |
| protected static Container | Returns: the native container object for the componentthe component to fetch the container for c)Give native peers the ability to query the native container given a native component (eg the direct parent may be lightweight). |
| public abstract PrintJob | Returns: aPrintJob object, or null if the
user cancelled the print job.the parent of the print dialog. May not be null. frame, String the title of the PrintJob. A null title is equivalent
to "". jobtitle, Properties a 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. props)Gets a |
| public PrintJob | Returns: aPrintJob object, or null if the
user cancelled the print job.the parent of the print dialog. May not be null. frame, String the title of the PrintJob. A null title is equivalent
to "". jobtitle, JobAttributes a 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. jobAttributes, PageAttributes a 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. pageAttributes)Gets a |
| public static String | Returns: the value of the property or the default value if the property was not foundthe key key, String the default value defaultValue)Gets a property with the specified key and default. |
| public PropertyChangeListener[] | Returns: all of this toolkit'sPropertyChangeListener
objects wrapped in java.beans.PropertyChangeListenerProxy objects
or an empty array if no listeners are addedReturns an array of all the property change listeners registered on this toolkit. |
| public PropertyChangeListener[] | Returns: all of thePropertyChangeListener objects
associated with the specified name of a desktop property
or an empty array if no such listeners are addedthe named property propertyName)Returns an array of all property change listeners associated with the specified name of a desktop property. |
| public Insets | Returns: the insets of this toolkit's screen, in pixels.a gc)GraphicsConfigurationGets the insets of the screen. |
| public abstract int | Returns: this toolkit's screen resolution, in dots-per-inch.Returns the screen resolution in dots-per-inch. |
| public abstract Dimension | |
| public abstract Clipboard | Returns: the system ClipboardGets the singleton instance of the system Clipboard which interfaces with clipboard facilities provided by the native platform. |
| public final EventQueue | Returns: theEventQueue for this applicationReturns the |
| protected abstract EventQueue | Returns: theEventQueue objectA method used by toolkit subclasses to get the |
| public Clipboard | Returns: the system selection as aClipboard, or
null if the native platform does not support a
system selection ClipboardGets the singleton instance of the system selection as a
|
| private static void | |
| protected void | |
| private static native void | |
| private static void | |
| public boolean | Returns: true, if current toolkit supports the always-on-top mode,
otherwise returns falseReturns whether the always-on-top mode is supported by this toolkit. |
| public boolean | Returns: true if dynamic layout of Containers on resize is currently active, false otherwise.Returns whether dynamic layout of Containers on resize is currently enabled on the underlying operating system and/or window manager. |
| protected boolean | Returns: true if validation of Containers is done dynamically, false if validation is done after resizing is finished.Returns whether the layout of Containers is validated dynamically during resizing, or statically, after resizing is complete. |
| public boolean | Returns: true is this frame state is supported by
this Toolkit implementation, false otherwise.one of named frame state constants. state)Returns whether Toolkit supports this state for
|
| public abstract boolean | Returns: true, if current toolkit supports given modal exclusion
type, false otherwisemodal exclusion type to be checked for support by this toolkit modalExclusionTypeReturns whether the given modal exclusion type is supported by this toolkit. |
| public abstract boolean | Returns: true, if current toolkit supports given modality
type, false otherwisemodality type to be checked for support by this toolkit modalityTypeReturns whether the given modality type is supported by this toolkit. |
| protected Object | Returns: the desktop property or nullthe name name)An opportunity to lazily evaluate desktop property values. |
| private static void | |
| pack-priv static void | |
| protected void | loadSystemColors(int[]
an integer array. systemColors)Fills in the integer array that is supplied as an argument with the current system color values. |
| public abstract Map | Returns: style attribute map, ornullinput method highlight highlight)Returns a map of visual attributes for the abstract level description of the given input method highlight, or null if no mapping is found. |
| private static void | newAWTError(Throwable
the original exception e, String the error message s)Rethrow the AWTError but include the cause. |
| pack-priv void | |
| public abstract boolean | Returns: true if the image has already been
fully prepared; false otherwise.the image for which to prepare a
screen representation. image, int the width of the desired screen
representation, or width, int -1.the height of the desired screen
representation, or height, ImageObserver -1.the observer)ImageObserver
object to be notified as the
image is being prepared.Prepares an image for rendering. |
| public void | removeAWTEventListener(AWTEventListener
the event listener. listener)Removes an AWTEventListener from receiving dispatched AWTEvents. |
| public void | removePropertyChangeListener(String
The name of the property to remove name, PropertyChangeListener The property change listener pcl)Removes the specified property change listener for the named desktop property. |
| protected final void | setDesktopProperty(String
the property name name, Object the new property value newValue)Sets the named desktop property to the specified value and fires a property change event to notify any listeners that the value has changed. |
| public void | setDynamicLayout(final boolean
If true, Containers should re-layout their
components as the Container is being resized. If false,
the layout will be validated after resizing is completed. dynamic)Controls whether the layout of Containers is validated dynamically during resizing, or statically, after resizing is complete. |
| public void | setLockingKeyState(int
the key code keyCode, boolean the state of the key on)Sets the state of the given locking key on the keyboard. |
| private static void | |
| public abstract void |