GeezerVison is showing docs.oracle.com — Toolkit (Java Platform SE 8 )
Java™ Platform Standard Ed. 8
-
-
Constructor Summary
Constructors
| Constructor |
Description |
Toolkit() |
|
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods
| Modifier and Type |
Method |
Description |
void |
addAWTEventListener(AWTEventListener listener,
long eventMask) |
Adds an AWTEventListener to receive all AWTEvents dispatched
system-wide that conform to the given eventMask.
|
void |
addPropertyChangeListener(String name,
PropertyChangeListener pcl) |
Adds the specified property change listener for the named desktop
property.
|
boolean |
areExtraMouseButtonsEnabled() |
Reports whether events from extra mouse buttons are allowed to be processed and posted into
EventQueue.
|
abstract void |
beep() |
Emits an audio beep depending on native system settings and hardware
capabilities.
|
abstract int |
checkImage(Image image,
int width,
int height,
ImageObserver observer) |
Indicates the construction status of a specified image that is
being prepared for display.
|
protected abstract java.awt.peer.ButtonPeer |
createButton(Button target) |
Creates this toolkit's implementation of Button using
the specified peer interface.
|
protected abstract java.awt.peer.CanvasPeer |
createCanvas(Canvas target) |
Creates this toolkit's implementation of Canvas using
the specified peer interface.
|
protected abstract java.awt.peer.CheckboxPeer |
createCheckbox(Checkbox target) |
Creates this toolkit's implementation of Checkbox using
the specified peer interface.
|
protected abstract java.awt.peer.CheckboxMenuItemPeer |
createCheckboxMenuItem(CheckboxMenuItem target) |
Creates this toolkit's implementation of CheckboxMenuItem using
the specified peer interface.
|
protected abstract java.awt.peer.ChoicePeer |
createChoice(Choice target) |
Creates this toolkit's implementation of Choice using
the specified peer interface.
|
protected java.awt.peer.LightweightPeer |
createComponent(Component target) |
Creates a peer for a component or container.
|
Cursor |
createCustomCursor(Image cursor,
Point hotSpot,
String name) |
Creates a new custom cursor object.
|
protected abstract java.awt.peer.DesktopPeer |
createDesktopPeer(Desktop target) |
Creates this toolkit's implementation of the Desktop
using the specified peer interface.
|
protected abstract java.awt.peer.DialogPeer |
createDialog(Dialog target) |
Creates this toolkit's implementation of Dialog using
the specified peer interface.
|
<T extends DragGestureRecognizer> T |
createDragGestureRecognizer(Class<T> abstractRecognizerClass,
DragSource ds,
Component c,
int srcActions,
DragGestureListener dgl) |
Creates a concrete, platform dependent, subclass of the abstract
DragGestureRecognizer class requested, and associates it with the
DragSource, Component and DragGestureListener specified.
|
abstract java.awt.dnd.peer.DragSourceContextPeer |
createDragSourceContextPeer(DragGestureEvent dge) |
Creates the peer for a DragSourceContext.
|
protected abstract java.awt.peer.FileDialogPeer |
createFileDialog(FileDialog target) |
Creates this toolkit's implementation of FileDialog using
the specified peer interface.
|
protected abstract java.awt.peer.FramePeer |
createFrame(Frame target) |
Creates this toolkit's implementation of Frame using
the specified peer interface.
|
Image |
createImage(byte[] imagedata) |
Creates an image which decodes the image stored in the specified
byte array.
|
abstract Image |
createImage(byte[] imagedata,
int imageoffset,
int imagelength) |
Creates an image which decodes the image stored in the specified
byte array, and at the specified offset and length.
|
abstract Image |
createImage(ImageProducer producer) |
Creates an image with the specified image producer.
|
abstract Image |
createImage(String filename) |
Returns an image which gets pixel data from the specified file.
|
abstract Image |
createImage(URL url) |
Returns an image which gets pixel data from the specified URL.
|
protected abstract java.awt.peer.LabelPeer |
createLabel(Label target) |
Creates this toolkit's implementation of Label using
the specified peer interface.
|
protected abstract java.awt.peer.ListPeer |
createList(List target) |
Creates this toolkit's implementation of List using
the specified peer interface.
|
protected abstract java.awt.peer.MenuPeer |
createMenu(Menu target) |
Creates this toolkit's implementation of Menu using
the specified peer interface.
|
protected abstract java.awt.peer.MenuBarPeer |
createMenuBar(MenuBar target) |
Creates this toolkit's implementation of MenuBar using
the specified peer interface.
|
protected abstract java.awt.peer.MenuItemPeer |
createMenuItem(MenuItem target) |
Creates this toolkit's implementation of MenuItem using
the specified peer interface.
|
protected abstract java.awt.peer.PanelPeer |
createPanel(Panel target) |
Creates this toolkit's implementation of Panel using
the specified peer interface.
|
protected abstract java.awt.peer.PopupMenuPeer |
createPopupMenu(PopupMenu target) |
Creates this toolkit's implementation of PopupMenu using
the specified peer interface.
|
protected abstract java.awt.peer.ScrollbarPeer |
createScrollbar(Scrollbar target) |
Creates this toolkit's implementation of Scrollbar using
the specified peer interface.
|
protected abstract java.awt.peer.ScrollPanePeer |
createScrollPane(ScrollPane target) |
Creates this toolkit's implementation of ScrollPane using
the specified peer interface.
|
protected abstract java.awt.peer.TextAreaPeer |
createTextArea(TextArea target) |
Creates this toolkit's implementation of TextArea using
the specified peer interface.
|
protected abstract java.awt.peer.TextFieldPeer |
createTextField(TextField target) |
Creates this toolkit's implementation of TextField using
the specified peer interface.
|
protected abstract java.awt.peer.WindowPeer |
createWindow(Window target) |
Creates this toolkit's implementation of Window using
the specified peer interface.
|
AWTEventListener[] |
getAWTEventListeners() |
Returns an array of all the AWTEventListeners
registered on this toolkit.
|
AWTEventListener[] |
getAWTEventListeners(long eventMask) |
Returns an array of all the AWTEventListeners
registered on this toolkit which listen to all of the event
types specified in the eventMask argument.
|
Dimension |
getBestCursorSize(int preferredWidth,
int preferredHeight) |
Returns the supported cursor dimension which is closest to the desired
sizes.
|
abstract ColorModel |
getColorModel() |
Determines the color model of this toolkit's screen.
|
static Toolkit |
getDefaultToolkit() |
Gets the default toolkit.
|
Object |
getDesktopProperty(String propertyName) |
Obtains a value for the specified desktop property.
|
abstract String[] |
getFontList() |
|
abstract FontMetrics |
getFontMetrics(Font font) |
Deprecated.
As of JDK version 1.2, replaced by the Font
method getLineMetrics.
|
protected abstract java.awt.peer.FontPeer |
getFontPeer(String name,
int style) |
Deprecated.
see java.awt.GraphicsEnvironment#getAllFonts
|
abstract Image |
getImage(String filename) |
Returns an image which gets pixel data from the specified file,
whose format can be either GIF, JPEG or PNG.
|
abstract Image |
getImage(URL url) |
Returns an image which gets pixel data from the specified URL.
|
boolean |
getLockingKeyState(int keyCode) |
Returns whether the given locking key on the keyboard is currently in
its "on" state.
|
int |
getMaximumCursorColors() |
Returns the maximum number of colors the Toolkit supports in a custom cursor
palette.
|
int |
getMenuShortcutKeyMask() |
Determines which modifier key is the appropriate accelerator
key for menu shortcuts.
|
protected java.awt.peer.MouseInfoPeer |
getMouseInfoPeer() |
Obtains this toolkit's implementation of helper class for
MouseInfo operations.
|
protected static Container |
getNativeContainer(Component c) |
Give native peers the ability to query the native container
given a native component (eg the direct parent may be lightweight).
|
PrintJob |
getPrintJob(Frame frame,
String jobtitle,
JobAttributes jobAttributes,
PageAttributes pageAttributes) |
Gets a PrintJob object which is the result of initiating
a print operation on the toolkit's platform.
|
abstract PrintJob |
getPrintJob(Frame frame,
String jobtitle,
Properties props) |
Gets a PrintJob object which is the result of initiating
a print operation on the toolkit's platform.
|
static String |
getProperty(String key,
String defaultValue) |
Gets a property with the specified key and default.
|
PropertyChangeListener[] |
getPropertyChangeListeners() |
Returns an array of all the property change listeners
registered on this toolkit.
|
PropertyChangeListener[] |
getPropertyChangeListeners(String propertyName) |
Returns an array of all property change listeners
associated with the specified name of a desktop property.
|
Insets |
getScreenInsets(GraphicsConfiguration gc) |
Gets the insets of the screen.
|
abstract int |
getScreenResolution() |
Returns the screen resolution in dots-per-inch.
|
abstract Dimension |
getScreenSize() |
Gets the size of the screen.
|
abstract Clipboard |
getSystemClipboard() |
Gets the singleton instance of the system Clipboard which interfaces
with clipboard facilities provided by the native platform.
|
EventQueue |
getSystemEventQueue() |
Get the application's or applet's EventQueue instance.
|
protected abstract EventQueue |
getSystemEventQueueImpl() |
Gets the application's or applet's EventQueue
instance, without checking access.
|
Clipboard |
getSystemSelection() |
Gets the singleton instance of the system selection as a
Clipboard object.
|
protected void |
initializeDesktopProperties() |
initializeDesktopProperties
|
boolean |
isAlwaysOnTopSupported() |
Returns whether the always-on-top mode is supported by this toolkit.
|
boolean |
isDynamicLayoutActive() |
Returns whether dynamic layout of Containers on resize is
currently active (both set in program
( isDynamicLayoutSet() )
, and supported
by the underlying operating system and/or window manager).
|
protected boolean |
isDynamicLayoutSet() |
Returns whether the layout of Containers is validated dynamically
during resizing, or statically, after resizing is complete.
|
boolean |
isFrameStateSupported(int state) |
Returns whether Toolkit supports this state for
Frames.
|
abstract boolean |
isModalExclusionTypeSupported(Dialog.ModalExclusionType modalExclusionType) |
Returns whether the given modal exclusion type is supported by this
toolkit.
|
abstract boolean |
isModalityTypeSupported(Dialog.ModalityType modalityType) |
Returns whether the given modality type is supported by this toolkit.
|
protected Object |
lazilyLoadDesktopProperty(String name) |
an opportunity to lazily evaluate desktop property values.
|
protected void |
loadSystemColors(int[] systemColors) |
Fills in the integer array that is supplied as an argument
with the current system color values.
|
abstract Map<TextAttribute,?> |
mapInputMethodHighlight(InputMethodHighlight 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.
|
abstract boolean |
prepareImage(Image image,
int width,
int height,
ImageObserver observer) |
Prepares an image for rendering.
|
void |
removeAWTEventListener(AWTEventListener listener) |
Removes an AWTEventListener from receiving dispatched AWTEvents.
|
void |
removePropertyChangeListener(String name,
PropertyChangeListener pcl) |
Removes the specified property change listener for the named
desktop property.
|
protected void |
setDesktopProperty(String name,
Object 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.
|
void |
setDynamicLayout(boolean dynamic) |
Controls whether the layout of Containers is validated dynamically
during resizing, or statically, after resizing is complete.
|
void |
setLockingKeyState(int keyCode,
boolean on) |
Sets the state of the given locking key on the keyboard.
|
abstract void |
sync() |
Synchronizes this toolkit's graphics state.
|
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
createCheckboxMenuItem
protected abstract java.awt.peer.CheckboxMenuItemPeer createCheckboxMenuItem(CheckboxMenuItem target)
throws HeadlessException
Creates this toolkit's implementation of CheckboxMenuItem using
the specified peer interface.
- Parameters:
target - the checkbox menu item to be implemented.
- Returns:
- this toolkit's implementation of
CheckboxMenuItem.
- Throws:
HeadlessException - if GraphicsEnvironment.isHeadless()
returns true
- See Also:
GraphicsEnvironment.isHeadless(),
CheckboxMenuItem,
CheckboxMenuItemPeer
-
createComponent
protected java.awt.peer.LightweightPeer createComponent(Component target)
Creates a peer for a component or container. This peer is windowless
and allows the Component and Container classes to be extended directly
to create windowless components that are defined entirely in java.
- Parameters:
target - The Component to be created.
-
getFontPeer
@Deprecated
protected abstract java.awt.peer.FontPeer getFontPeer(String name,
int style)
Deprecated. see java.awt.GraphicsEnvironment#getAllFonts
Creates this toolkit's implementation of Font using
the specified peer interface.
- Parameters:
name - the font to be implemented
style - the style of the font, such as PLAIN,
BOLD, ITALIC, or a combination
- Returns:
- this toolkit's implementation of
Font
- See Also:
Font,
FontPeer,
GraphicsEnvironment.getAllFonts()
-
setDynamicLayout
public void setDynamicLayout(boolean dynamic)
throws HeadlessException
Controls whether the layout of Containers is validated dynamically
during resizing, or statically, after resizing is complete.
Use isDynamicLayoutActive() to detect if this feature enabled
in this program and is supported by this operating system
and/or window manager.
Note that this feature is supported not on all platforms, and
conversely, that this feature cannot be turned off on some platforms.
On these platforms where dynamic layout during resizing 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 support or settings of the underlying
operating system or
window manager. The OS/WM support can be
queried using getDesktopProperty("awt.dynamicLayoutSupported") method.
- Parameters:
dynamic - 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.
- Throws:
HeadlessException - if GraphicsEnvironment.isHeadless()
returns true
- Since:
- 1.4
- See Also:
isDynamicLayoutSet(),
isDynamicLayoutActive(),
getDesktopProperty(String propertyName),
GraphicsEnvironment.isHeadless()
-
isDynamicLayoutSet
protected boolean isDynamicLayoutSet()
throws HeadlessException
Returns whether the layout of Containers is validated dynamically
during resizing, or statically, after resizing is complete.
Note: this method returns the value that was set programmatically;
it does not reflect support at the level of the operating system
or window manager for dynamic layout on resizing, or the current
operating system or window manager settings. The OS/WM support can
be queried using getDesktopProperty("awt.dynamicLayoutSupported").
- Returns:
- true if validation of Containers is done dynamically,
false if validation is done after resizing is finished.
- Throws:
HeadlessException - if GraphicsEnvironment.isHeadless()
returns true
- Since:
- 1.4
- See Also:
setDynamicLayout(boolean dynamic),
isDynamicLayoutActive(),
getDesktopProperty(String propertyName),
GraphicsEnvironment.isHeadless()
-
isDynamicLayoutActive
public boolean isDynamicLayoutActive()
throws HeadlessException
Returns whether dynamic layout of Containers on resize is
currently active (both set in program
( isDynamicLayoutSet() )
, and supported
by the underlying operating system and/or window manager).
If dynamic layout is currently inactive then Containers
re-layout their components when resizing is completed. As a result
the Component.validate() method will be invoked only
once per resize.
If dynamic layout is currently active then Containers
re-layout their components on every native resize event and
the validate() method will be invoked each time.
The OS/WM support can be queried using
the getDesktopProperty("awt.dynamicLayoutSupported") method.
- Returns:
- true if dynamic layout of Containers on resize is
currently active, false otherwise.
- Throws:
HeadlessException - if the GraphicsEnvironment.isHeadless()
method returns true
- Since:
- 1.4
- See Also:
setDynamicLayout(boolean dynamic),
isDynamicLayoutSet(),
getDesktopProperty(String propertyName),
GraphicsEnvironment.isHeadless()
-
createImage
public abstract Image createImage(byte[] imagedata,
int imageoffset,
int imagelength)
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:
imagedata - an array of bytes, representing
image data in a supported image format.
imageoffset - the offset of the beginning
of the data in the array.
imagelength - the length of the data in the array.
- Returns:
- an image.
- Since:
- JDK1.1
-
getPrintJob
public PrintJob getPrintJob(Frame frame,
String jobtitle,
JobAttributes jobAttributes,
PageAttributes pageAttributes)
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:
frame - the parent of the print dialog. May not be null.
jobtitle - the title of the PrintJob. A null title is equivalent
to "".
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.
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.
- Returns:
- a
PrintJob object, or null if the
user cancelled the print job.
- Throws:
NullPointerException - if frame is null
IllegalArgumentException - if pageAttributes specifies differing
cross feed and feed resolutions. Also if this thread has
access to the file system and jobAttributes specifies
print to file, and the specified destination file exists but
is a directory rather than a regular file, does not exist but
cannot be created, or cannot be opened for any other reason.
However in the case of print to file, if a dialog is also
requested to be displayed then the user will be given an
opportunity to select a file and proceed with printing.
The dialog will ensure that the selected output file
is valid before returning from this method.
SecurityException - if 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
- See Also:
PrintJob,
GraphicsEnvironment.isHeadless(),
RuntimePermission,
JobAttributes,
PageAttributes
-
createCustomCursor
public Cursor createCustomCursor(Image cursor,
Point hotSpot,
String name)
throws IndexOutOfBoundsException,
HeadlessException
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:
cursor - the image to display when the cursor is activated
hotSpot - the X and Y of the large cursor's hot spot; the
hotSpot values must be less than the Dimension returned by
getBestCursorSize
name - a localized description of the cursor, for Java Accessibility use
- Throws:
IndexOutOfBoundsException - if the hotSpot values are outside
the bounds of the cursor
HeadlessException - if GraphicsEnvironment.isHeadless()
returns true
- Since:
- 1.2
- See Also:
GraphicsEnvironment.isHeadless()
-
getProperty
public static String getProperty(String key,
String defaultValue)
Gets a property with the specified key and default.
This method returns defaultValue if the property is not found.
-
getSystemEventQueueImpl
protected abstract EventQueue getSystemEventQueueImpl()
Gets the application's or applet's EventQueue
instance, without checking access. For security reasons,
this can only be called from a Toolkit subclass.
- Returns:
- the
EventQueue object
-
createDragGestureRecognizer
public <T extends DragGestureRecognizer> T createDragGestureRecognizer(Class<T> abstractRecognizerClass,
DragSource ds,
Component c,
int srcActions,
DragGestureListener dgl)
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:
abstractRecognizerClass - The abstract class of the required recognizer
ds - The DragSource
c - The Component target for the DragGestureRecognizer
srcActions - The actions permitted for the gesture
dgl - The DragGestureListener
- Returns:
- the new object or null. Always returns null if
GraphicsEnvironment.isHeadless() returns true.
- See Also:
GraphicsEnvironment.isHeadless()
-
setDesktopProperty
protected final void setDesktopProperty(String name,
Object 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.
-
getAWTEventListeners
public AWTEventListener[] getAWTEventListeners(long eventMask)
Returns an array of all the AWTEventListeners
registered on this toolkit which listen to all of the event
types specified in the eventMask argument.
If there is a security manager, its checkPermission
method is called with an
AWTPermission("listenToAllAWTEvents") permission.
This may result in a SecurityException.
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:
eventMask - the bitmask of event types to listen for
- Returns:
- 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
- See Also:
addAWTEventListener(java.awt.event.AWTEventListener, long),
removeAWTEventListener(java.awt.event.AWTEventListener),
SecurityManager.checkPermission(java.security.Permission),
AWTEvent,
AWTPermission,
AWTEventListener,
AWTEventListenerProxy
-
mapInputMethodHighlight
public abstract Map<TextAttribute,?> mapInputMethodHighlight(InputMethodHighlight highlight)
throws HeadlessException
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:
highlight - input method highlight
- Returns:
- style attribute map, or
null
- Throws:
HeadlessException - if
GraphicsEnvironment.isHeadless returns true
- Since:
- 1.3
- See Also:
GraphicsEnvironment.isHeadless()
Java™ Platform Standard Ed. 8
Submit a bug or feature For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. Copyright © 1993, 2026, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
|