|
JSR 216 (Maintenance Release) | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectjava.awt.Toolkit
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.
Most applications should not call any of the methods in this
class directly. Some methods defined by
Toolkit query the native operating system directly.
| Constructor Summary | |
Toolkit()
|
|
| Method Summary | |
void |
addAWTEventListener(AWTEventListener listener,
long eventMask)
Adds an AWTEventListener to receive all AWTEvents dispatched system-wide that conform to the given eventMask. |
abstract void |
beep()
Emits an audio beep. |
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. |
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. |
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 indicates in the eventMask argument. |
abstract ColorModel |
getColorModel()
Determines the color model of this toolkit's screen. |
static Toolkit |
getDefaultToolkit()
Gets the default toolkit. |
abstract String[] |
getFontList()
Deprecated. see GraphicsEnvironment.getAvailableFontFamilyNames() |
abstract FontMetrics |
getFontMetrics(Font font)
Deprecated. Deprecated. This returns integer metrics for the default screen. |
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. |
int |
getMenuShortcutKeyMask()
Determines which modifier key is the appropriate accelerator key for menu shortcuts. |
static String |
getProperty(String key,
String defaultValue)
Gets a property with the specified key and default. |
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()
|
boolean |
isFrameStateSupported(int state)
Returns whether Toolkit supports this state for Frames. |
protected void |
loadSystemColors(int[] systemColors)
Fills in the integer array that is supplied as an argument with the current system color values. |
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. |
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 |
| Constructor Detail |
public Toolkit()
| Method Detail |
protected void loadSystemColors(int[] systemColors)
throws HeadlessException
systemColors array is implementation-dependent.
systemColors - an integer array.
HeadlessException - if GraphicsEnvironment.isHeadless()
returns trueGraphicsEnvironment.isHeadless()
public abstract Dimension getScreenSize()
throws HeadlessException
GraphicsConfiguration and
GraphicsDevice.
HeadlessException - if GraphicsEnvironment.isHeadless()
returns trueGraphicsConfiguration.getBounds(),
GraphicsEnvironment.isHeadless()
public abstract int getScreenResolution()
throws HeadlessException
HeadlessException - if GraphicsEnvironment.isHeadless()
returns trueGraphicsEnvironment.isHeadless()
public Insets getScreenInsets(GraphicsConfiguration gc)
throws HeadlessException
gc - a GraphicsConfiguration
HeadlessException - if GraphicsEnvironment.isHeadless()
returns trueGraphicsEnvironment.isHeadless()
public abstract ColorModel getColorModel()
throws HeadlessException
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.
HeadlessException - if GraphicsEnvironment.isHeadless()
returns trueGraphicsEnvironment.isHeadless(),
ColorModel,
Component.getColorModel()public abstract String[] getFontList()
GraphicsEnvironment.getAvailableFontFamilyNames()
For 1.1, the following font names are deprecated (the replacement name follows):
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.
GraphicsEnvironment.getAvailableFontFamilyNames()public abstract FontMetrics getFontMetrics(Font font)
font - a font
GraphicsEnvironment.getScreenDevices()public abstract void sync()
This method ensures that the display is up-to-date. It is useful for animation.
public static Toolkit getDefaultToolkit()
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.
AWTError - if a toolkit could not be found, or
if one could not be accessed or instantiated.public abstract Image getImage(String filename)
filename - the name of a file containing pixel data
in a recognized file format.
SecurityException - if a security manager exists and its
checkRead method denies read access to the filename.createImage(java.lang.String),
SecurityManager.checkRead(java.lang.String)public abstract Image getImage(URL url)
This method will throw SecurityException if the
caller does not have the permission obtained from
url.openConnection.getPermission().
For compatibility with pre-1.2 security managers, if the permission
is a FilePermission or a
SocketPermission, then the 1.1-style
SecurityManager.checkXXX methods are called instead of
SecurityManager.checkPermission(java.security.Permission).
url - the URL to use in fetching the pixel data.
SecurityException - If the caller does not have permission to
access this URL.createImage(java.net.URL)public abstract Image createImage(String filename)
filename - the name of a file containing pixel data
in a recognized file format.
SecurityException - if a security manager exists and its
checkRead method denies read access to the filename.getImage(java.lang.String),
SecurityManager.checkRead(java.lang.String)public abstract Image createImage(URL url)
This method will throw SecurityException if the
caller does not have the permission obtained from
url.openConnection.getPermission().
For compatibility with pre-1.2 security managers, if the permission
is a FilePermission or a
SocketPermission, then the 1.1-style
SecurityManager.checkXXX methods are called instead of
SecurityManager.checkPermission(java.security.Permission).
url - the URL to use in fetching the pixel data.
SecurityException - If the caller does not have permission to
access this URL.getImage(java.net.URL)
public abstract boolean prepareImage(Image image,
int width,
int height,
ImageObserver observer)
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.
image - the image for which to prepare a
screen representation.width - the width of the desired screen
representation, or -1.height - the height of the desired screen
representation, or -1.observer - the ImageObserver
object to be notified as the
image is being prepared.
true if the image has already been
fully prepared; false otherwise.Component.prepareImage(java.awt.Image,
java.awt.image.ImageObserver),
Component.prepareImage(java.awt.Image,
int, int, java.awt.image.ImageObserver),
ImageObserver
public abstract int checkImage(Image image,
int width,
int height,
ImageObserver observer)
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.
image - the image whose status is being checked.width - the width of the scaled version whose status is
being checked, or -1.height - the height of the scaled version whose status
is being checked, or -1.observer - the ImageObserver object to be
notified as the image is being prepared.
ImageObserver flags for the
image data that is currently available.prepareImage(java.awt.Image,
int, int, java.awt.image.ImageObserver),
Component.checkImage(java.awt.Image,
java.awt.image.ImageObserver),
Component.checkImage(java.awt.Image,
int, int, java.awt.image.ImageObserver),
ImageObserverpublic abstract Image createImage(ImageProducer producer)
producer - the image producer to be used.
Image,
ImageProducer,
Component.createImage(java.awt.image.ImageProducer)public Image createImage(byte[] imagedata)
The data must be in some image format, such as GIF or JPEG, that is supported by this toolkit.
imagedata - an array of bytes, representing
image data in a supported image format.
public abstract Image createImage(byte[] imagedata,
int imageoffset,
int imagelength)
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.
public abstract void beep()
public abstract Clipboard getSystemClipboard()
throws HeadlessException
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:
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.
HeadlessException - if GraphicsEnvironment.isHeadless()
returns trueGraphicsEnvironment.isHeadless(),
Clipboard,
StringSelection,
DataFlavor.stringFlavor,
DataFlavor.plainTextFlavor,
Reader,
AWTPermission
public int getMenuShortcutKeyMask()
throws HeadlessException
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.
Event class
that is used for menu shortcuts on this toolkit.
HeadlessException - if GraphicsEnvironment.isHeadless()
returns trueGraphicsEnvironment.isHeadless(),
MenuBar,
MenuShortcut
public boolean isFrameStateSupported(int state)
throws HeadlessException
Frames. This method tells whether the UI
concept of, say, iconification is
supported.
state - one of named frame state constants.
true is this frame state is supported by
this Toolkit implementation, false otherwise.
HeadlessException - if GraphicsEnvironment.isHeadless()
returns true.
public static String getProperty(String key,
String defaultValue)
public final EventQueue getSystemEventQueue()
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.
EventQueue object.
SecurityException - if a security manager exists and its SecurityManager.checkAwtEventQueueAccess() method denies
access to the EventQueue.AWTPermissionprotected abstract EventQueue getSystemEventQueueImpl()
public void addAWTEventListener(AWTEventListener listener,
long eventMask)
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.
listener - the event listener.eventMask - the bitmask of event types to receive
SecurityException - if a security manager exists and its
checkPermission method doesn't allow the operation.removeAWTEventListener(java.awt.event.AWTEventListener),
SecurityManager.checkPermission(java.security.Permission),
AWTEvent,
AWTPermission,
AWTEventListener,
AWTEventListenerProxypublic void removeAWTEventListener(AWTEventListener listener)
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.
listener - the event listener.
SecurityException - if a security manager exists and its
checkPermission method doesn't allow the operation.addAWTEventListener(java.awt.event.AWTEventListener, long),
SecurityManager.checkPermission(java.security.Permission),
AWTEvent,
AWTPermission,
AWTEventListener,
AWTEventListenerProxypublic AWTEventListener[] getAWTEventListeners()
AWTEventListeners
registered on this toolkit.
First, 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.
AWTEventListeners or an empty
array if no listeners are currently registered
SecurityException - if a security manager exists and its
checkPermission method doesn't allow the operation.addAWTEventListener(java.awt.event.AWTEventListener, long),
removeAWTEventListener(java.awt.event.AWTEventListener),
SecurityManager.checkPermission(java.security.Permission),
AWTEvent,
AWTPermission,
AWTEventListener,
AWTEventListenerProxypublic AWTEventListener[] getAWTEventListeners(long eventMask)
AWTEventListeners
registered on this toolkit which listen to all of the event
types indicates in the eventMask argument.
First, 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.
eventMask - the bitmask of event types to listen for
AWTEventListeners registered
on this toolkit for the specified
event types, or an empty array if no such listeners
are currently registered
SecurityException - if a security manager exists and its
checkPermission method doesn't allow the operation.addAWTEventListener(java.awt.event.AWTEventListener, long),
removeAWTEventListener(java.awt.event.AWTEventListener),
SecurityManager.checkPermission(java.security.Permission),
AWTEvent,
AWTPermission,
AWTEventListener,
AWTEventListenerProxy
|
JSR 216 (Maintenance Release) | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||