|
JSR-62 (Final) | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.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. 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.
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. |
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. 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. |
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()
|
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)
public abstract Dimension getScreenSize()
public abstract int getScreenResolution()
public abstract ColorModel getColorModel()
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.
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 an implementation-dependent default toolkit is used.
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.
createImage(java.lang.String)
public abstract Image getImage(URL url)
url
- the URL to use in fetching the pixel data.
createImage(java.net.URL)
public abstract Image createImage(String filename)
filename
- the name of a file containing pixel data
in a recognized file format.
getImage(java.lang.String)
public abstract Image createImage(URL url)
url
- the URL to use in fetching the pixel data.
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)
,
ImageObserver
public 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()
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.
Clipboard
,
StringSelection
,
DataFlavor.stringFlavor
,
DataFlavor.plainTextFlavor
,
Reader
,
AWTPermission
public int getMenuShortcutKeyMask()
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.MenuBar
,
MenuShortcut
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.AWTPermission
protected 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.AWTEventListener
,
addAWTEventListener(java.awt.event.AWTEventListener, long)
,
AWTEvent
,
SecurityManager.checkPermission(java.security.Permission)
,
AWTPermission
public 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.AWTEventListener
,
addAWTEventListener(java.awt.event.AWTEventListener, long)
,
AWTEvent
,
SecurityManager.checkPermission(java.security.Permission)
,
AWTPermission
|
JSR-62 (Final) | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |