| java.lang.Object java.awt.Toolkit
All known Subclasses: java.awt.X11Toolkit, java.awt.MWToolkit, sun.awt.SunToolkit,
Toolkit | abstract public class Toolkit (Code) | | 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.
version: 1.102, 08/19/02 author: Sami Shaio author: Arthur van Hoff author: Fred Ecks since: JDK1.0 |
Method Summary | |
public void | addAWTEventListener(AWTEventListener listener, long eventMask) Adds an AWTEventListener to receive all AWTEvents dispatched
system-wide that conform to the given eventMask . | abstract public void | beep() Emits an audio beep. | abstract public int | checkImage(Image image, int width, int height, ImageObserver observer) 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: image - the image whose status is being checked. Parameters: width - the width of the scaled version whose status isbeing checked, or -1 . Parameters: height - the height of the scaled version whose statusis being checked, or -1 . Parameters: observer - the ImageObserver object to benotified as the image is being prepared. | abstract public Image | createImage(String filename) 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: filename - the name of a file containing pixel datain a recognized file format. | abstract public Image | createImage(URL url) 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.
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
java.io.FilePermission or a
java.net.SocketPermission , then the 1.1-style
SecurityManager.checkXXX methods are called instead of
SecurityManager.checkPermission .
throws: SecurityException - If the caller does not have permission toaccess this URL. Parameters: url - the URL to use in fetching the pixel data. | abstract public Image | createImage(ImageProducer producer) Creates an image with the specified image producer.
Parameters: producer - the image producer to be used. | public Image | createImage(byte[] imagedata) 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: imagedata - an array of bytes, representingimage data in a supported image format. | abstract public 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, representingimage data in a supported image format. Parameters: imageoffset - the offset of the beginningof the data in the array. Parameters: imagelength - the length of the data in the array. | public AWTEventListener[] | getAWTEventListeners() Returns an array of all the AWTEventListener s
registered on this toolkit. | public AWTEventListener[] | getAWTEventListeners(long eventMask) Returns an array of all the AWTEventListener s
registered on this toolkit which listen to all of the event
types indicates in the eventMask argument. | abstract public ColorModel | getColorModel() Determines the color model of this toolkit's screen. | public static Toolkit | getDefaultToolkit() 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 "sun.awt.motif.MToolkit" for Solaris, and
"sun.awt.gtk.GToolkit" for Linux. | static EventQueue | getEventQueue() | abstract public String[] | getFontList() 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 font is also deprecated in 1.1, but only as a
separate fontname. | abstract public FontMetrics | getFontMetrics(Font font) Gets the screen metrics of the font.
Parameters: font - a font. | Graphics | getGraphics(Window window) Gets a Graphics object for the supplied Window. | abstract public Image | getImage(String filename) 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 indefinate period of time, developers
are encouraged to implement their own caching of images by
using the createImage variant wherever available.
Parameters: filename - the name of a file containing pixel datain a recognized file format. | abstract public Image | getImage(URL url) 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 indefinate period of time, developers
are encouraged to implement their own caching of images by
using the createImage variant wherever available.
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
java.io.FilePermission or a
java.net.SocketPermission , then the 1.1-style
SecurityManager.checkXXX methods are called instead of
SecurityManager.checkPermission .
throws: SecurityException - If the caller does not have permission toaccess this URL. Parameters: url - the URL to use in fetching the pixel data. | GraphicsEnvironment | getLocalGraphicsEnvironment() Gets the GraphicsEnvironment for this toolkit. | public int | getMenuShortcutKeyMask() Determines which modifier key is the appropriate accelerator
key for menu shortcuts. | public static String | getProperty(String key, String defaultValue) Gets a property with the specified key and default. | public Insets | getScreenInsets(GraphicsConfiguration gc) Gets the insets of the screen. | abstract public int | getScreenResolution() Returns the screen resolution in dots-per-inch. | abstract public Dimension | getScreenSize() Gets the size of the screen. | abstract public Clipboard | getSystemClipboard() Gets an instance of the system clipboard which interfaces
with clipboard facilities provided by the native platform. | final public EventQueue | getSystemEventQueue() Get the application's or applet's EventQueue instance.
Depending on the Toolkit implementation, different EventQueues
may be returned for different applets. | abstract protected EventQueue | getSystemEventQueueImpl() | public boolean | isFrameStateSupported(int state) Returns whether Toolkit supports this state for
Frame s. | protected void | loadSystemColors(int[] systemColors) Fills in the integer array that is supplied as an argument
with the current system color values. | void | notifyAWTEventListeners(AWTEvent theEvent) | abstract public boolean | prepareImage(Image image, int width, int height, ImageObserver observer) 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: image - the image for which to prepare ascreen representation. Parameters: width - the width of the desired screenrepresentation, or -1 . Parameters: height - the height of the desired screenrepresentation, or -1 . Parameters: observer - the ImageObserver object to be notified as theimage is being prepared. | public void | removeAWTEventListener(AWTEventListener listener) Removes an AWTEventListener from receiving dispatched AWTEvents. | abstract public void | sync() Synchronizes this toolkit's graphics state. |
addAWTEventListener | public void addAWTEventListener(AWTEventListener listener, long eventMask)(Code) | | 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: listener - the event listener. Parameters: eventMask - the bitmask of event types to receive throws: SecurityException - if a security manager exists and itscheckPermission method doesn't allow the operation. See Also: java.awt.event.AWTEventListener See Also: java.awt.Toolkit.addAWTEventListener See Also: java.awt.AWTEvent See Also: SecurityManager.checkPermission See Also: java.awt.AWTPermission since: 1.2 |
beep | abstract public void beep()(Code) | | Emits an audio beep.
since: JDK1.1 |
checkImage | abstract public int checkImage(Image image, int width, int height, ImageObserver observer)(Code) | | 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: image - the image whose status is being checked. Parameters: width - the width of the scaled version whose status isbeing checked, or -1 . Parameters: height - the height of the scaled version whose statusis being checked, or -1 . Parameters: observer - the ImageObserver object to benotified as the image is being prepared. the bitwise inclusive OR of theImageObserver flags for theimage data that is currently available. See Also: java.awt.Toolkit.prepareImage(java.awt.Imageintintjava.awt.image.ImageObserver) See Also: java.awt.Component.checkImage(java.awt.Imagejava.awt.image.ImageObserver) See Also: java.awt.Component.checkImage(java.awt.Imageintintjava.awt.image.ImageObserver) See Also: java.awt.image.ImageObserver since: JDK1.0 |
createImage | abstract public Image createImage(String filename)(Code) | | 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: filename - the name of a file containing pixel datain a recognized file format. an image which gets its pixel data fromthe specified file. See Also: java.awt.Toolkit.getImage(java.lang.String) |
createImage | abstract public Image createImage(URL url)(Code) | | 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.
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
java.io.FilePermission or a
java.net.SocketPermission , then the 1.1-style
SecurityManager.checkXXX methods are called instead of
SecurityManager.checkPermission .
throws: SecurityException - If the caller does not have permission toaccess this URL. Parameters: url - the URL to use in fetching the pixel data. an image which gets its pixel data fromthe specified URL. See Also: java.awt.Toolkit.getImage(java.net.URL) |
createImage | public Image createImage(byte[] imagedata)(Code) | | 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: imagedata - an array of bytes, representingimage data in a supported image format. an image. since: JDK1.1 |
createImage | abstract public Image createImage(byte[] imagedata, int imageoffset, int imagelength)(Code) | | 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, representingimage data in a supported image format. Parameters: imageoffset - the offset of the beginningof the data in the array. Parameters: imagelength - the length of the data in the array. an image. since: JDK1.1 |
getColorModel | abstract public ColorModel getColorModel()(Code) | | 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.
the color model of this toolkit's screen. See Also: java.awt.image.ColorModel See Also: java.awt.Component.getColorModel since: JDK1.0 |
getDefaultToolkit | public static Toolkit getDefaultToolkit()(Code) | | 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 "sun.awt.motif.MToolkit" for Solaris, and
"sun.awt.gtk.GToolkit" for Linux. Both of which are
implementations of Abstract Window Toolkits.
the default toolkit. exception: AWTError - if a toolkit could not be found, orif one could not be accessed or instantiated. since: JDK1.0 |
getFontList | abstract public String[] getFontList()(Code) | | 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 font is also deprecated in 1.1, but only as a
separate fontname. Unicode defines the ZapfDingbat characters
starting at \u2700, and as of 1.1 Java supports those characters.
the names of the available fonts in this toolkit. since: JDK1.0 |
getFontMetrics | abstract public FontMetrics getFontMetrics(Font font)(Code) | | Gets the screen metrics of the font.
Parameters: font - a font. the screen metrics of the specified font in this toolkit. since: JDK1.0 |
getGraphics | Graphics getGraphics(Window window)(Code) | | Gets a Graphics object for the supplied Window. The graphics object
should be initialised with the foreground, background and font of
the window and should draw to the GraphicsDevice the Window's
GraphicsConfiguration belongs to. This method is package protected so
as to be spec compatiable. It should be abstract but this would cause
spec issues.
|
getImage | abstract public Image getImage(String filename)(Code) | | 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 indefinate period of time, developers
are encouraged to implement their own caching of images by
using the createImage variant wherever available.
Parameters: filename - the name of a file containing pixel datain a recognized file format. an image which gets its pixel data fromthe specified file. See Also: Toolkit.createImage(java.lang.String) |
getImage | abstract public Image getImage(URL url)(Code) | | 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 indefinate period of time, developers
are encouraged to implement their own caching of images by
using the createImage variant wherever available.
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
java.io.FilePermission or a
java.net.SocketPermission , then the 1.1-style
SecurityManager.checkXXX methods are called instead of
SecurityManager.checkPermission .
throws: SecurityException - If the caller does not have permission toaccess this URL. Parameters: url - the URL to use in fetching the pixel data. an image which gets its pixel data fromthe specified URL. See Also: Toolkit.createImage(java.net.URL) |
getLocalGraphicsEnvironment | GraphicsEnvironment getLocalGraphicsEnvironment()(Code) | | Gets the GraphicsEnvironment for this toolkit. This is called from
GraphicsEnvironment.getLocalGraphicsEnvironment.
|
getMenuShortcutKeyMask | public int getMenuShortcutKeyMask()(Code) | | 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.
the modifier mask on the Event classthat is used for menu shortcuts on this toolkit. See Also: java.awt.MenuBar See Also: java.awt.MenuShortcut since: JDK1.1 |
getProperty | public static String getProperty(String key, String defaultValue)(Code) | | Gets a property with the specified key and default.
This method returns defaultValue if the property is not found.
|
getScreenResolution | abstract public int getScreenResolution()(Code) | | Returns the screen resolution in dots-per-inch.
this toolkit's screen resolution, in dots-per-inch. since: JDK1.0 |
getScreenSize | abstract public Dimension getScreenSize()(Code) | | Gets the size of the screen.
the size of this toolkit's screen, in pixels. since: JDK1.0 |
getSystemClipboard | abstract public Clipboard getSystemClipboard()(Code) | | Gets an 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.
an instance of the system clipboard. See Also: java.awt.datatransfer.Clipboard since: JDK1.1 |
getSystemEventQueue | final public EventQueue getSystemEventQueue()(Code) | | 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.
|
getSystemEventQueueImpl | abstract protected EventQueue getSystemEventQueueImpl()(Code) | | |
isFrameStateSupported | public boolean isFrameStateSupported(int state) throws HeadlessException(Code) | | Returns whether Toolkit supports this state for
Frame s. This method tells whether the UI
concept of iconification is
supported. It will always return false for any state other than
like Frame.NORMAL or Frame.ICONIFIED .
Parameters: state - one of named frame state constants. true is this frame state is supported bythis Toolkit implementation, false otherwise. exception: HeadlessException - if GraphicsEnvironment.isHeadless() returns true . |
loadSystemColors | protected void loadSystemColors(int[] systemColors)(Code) | | Fills in the integer array that is supplied as an argument
with the current system color values.
This method is called by the method updateSystemColors
in the SystemColor class.
Parameters: systemColors - an integer array. since: JDK1.1 |
notifyAWTEventListeners | void notifyAWTEventListeners(AWTEvent theEvent)(Code) | | |
prepareImage | abstract public boolean prepareImage(Image image, int width, int height, ImageObserver observer)(Code) | | 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: image - the image for which to prepare ascreen representation. Parameters: width - the width of the desired screenrepresentation, or -1 . Parameters: height - the height of the desired screenrepresentation, or -1 . Parameters: observer - the ImageObserver object to be notified as theimage is being prepared. true if the image has already beenfully prepared; false otherwise. See Also: java.awt.Component.prepareImage(java.awt.Imagejava.awt.image.ImageObserver) See Also: java.awt.Component.prepareImage(java.awt.Imageintintjava.awt.image.ImageObserver) See Also: java.awt.image.ImageObserver since: JDK1.0 |
removeAWTEventListener | public void removeAWTEventListener(AWTEventListener listener)(Code) | | 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: listener - the event listener. throws: SecurityException - if a security manager exists and itscheckPermission method doesn't allow the operation. See Also: java.awt.event.AWTEventListener See Also: java.awt.Toolkit.addAWTEventListener See Also: java.awt.AWTEvent See Also: SecurityManager.checkPermission See Also: java.awt.AWTPermission since: 1.2 |
sync | abstract public void sync()(Code) | | 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.
since: JDK1.0 |
|
|