|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Toolkit
public abstract class Toolkit
Disabled: no SafeJ information.
This class is the abstract superclass of all actual
implementations of the Abstract Window Toolkit. Subclasses of
the 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 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.
Field Summary | |
---|---|
protected Map<String,Object> |
desktopProperties
|
protected PropertyChangeSupport |
desktopPropsSupport
|
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 . |
|
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. |
|
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 ButtonPeer |
createButton(Button target)
Creates this toolkit's implementation of Button using
the specified peer interface. |
|
protected abstract CanvasPeer |
createCanvas(Canvas target)
Creates this toolkit's implementation of Canvas using
the specified peer interface. |
|
protected abstract CheckboxPeer |
createCheckbox(Checkbox target)
Creates this toolkit's implementation of Checkbox using
the specified peer interface. |
|
protected abstract CheckboxMenuItemPeer |
createCheckboxMenuItem(CheckboxMenuItem target)
Creates this toolkit's implementation of CheckboxMenuItem using
the specified peer interface. |
|
protected abstract ChoicePeer |
createChoice(Choice target)
Creates this toolkit's implementation of Choice using
the specified peer interface. |
|
protected 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 DesktopPeer |
createDesktopPeer(Desktop target)
Creates this toolkit's implementation of the Desktop
using the specified peer interface. |
|
protected abstract DialogPeer |
createDialog(Dialog target)
Creates this toolkit's implementation of Dialog using
the specified peer interface. |
|
|
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 DragSourceContextPeer |
createDragSourceContextPeer(DragGestureEvent dge)
Creates the peer for a DragSourceContext. |
|
protected abstract FileDialogPeer |
createFileDialog(FileDialog target)
Creates this toolkit's implementation of FileDialog using
the specified peer interface. |
|
protected abstract 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 LabelPeer |
createLabel(Label target)
Creates this toolkit's implementation of Label using
the specified peer interface. |
|
protected abstract ListPeer |
createList(List target)
Creates this toolkit's implementation of List using
the specified peer interface. |
|
protected abstract MenuPeer |
createMenu(Menu target)
Creates this toolkit's implementation of Menu using
the specified peer interface. |
|
protected abstract MenuBarPeer |
createMenuBar(MenuBar target)
Creates this toolkit's implementation of MenuBar using
the specified peer interface. |
|
protected abstract MenuItemPeer |
createMenuItem(MenuItem target)
Creates this toolkit's implementation of MenuItem using
the specified peer interface. |
|
protected abstract PanelPeer |
createPanel(Panel target)
Creates this toolkit's implementation of Panel using
the specified peer interface. |
|
protected abstract PopupMenuPeer |
createPopupMenu(PopupMenu target)
Creates this toolkit's implementation of PopupMenu using
the specified peer interface. |
|
protected abstract ScrollbarPeer |
createScrollbar(Scrollbar target)
Creates this toolkit's implementation of Scrollbar using
the specified peer interface. |
|
protected abstract ScrollPanePeer |
createScrollPane(ScrollPane target)
Creates this toolkit's implementation of ScrollPane using
the specified peer interface. |
|
protected abstract TextAreaPeer |
createTextArea(TextArea target)
Creates this toolkit's implementation of TextArea using
the specified peer interface. |
|
protected abstract TextFieldPeer |
createTextField(TextField target)
Creates this toolkit's implementation of TextField using
the specified peer interface. |
|
protected abstract WindowPeer |
createWindow(Window target)
Creates this toolkit's implementation of Window using
the specified peer interface. |
|
AWTEventListener[] |
getAWTEventListeners()
Returns an array of all the AWTEventListener s
registered on this toolkit. |
|
AWTEventListener[] |
getAWTEventListeners(long eventMask)
Returns an array of all the AWTEventListener s
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()
Deprecated. see GraphicsEnvironment.getAvailableFontFamilyNames() |
|
abstract FontMetrics |
getFontMetrics(Font font)
Deprecated. As of JDK version 1.2, replaced by the Font
method getLineMetrics . |
|
protected abstract 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 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 the PropertyChangeListener s
associated with the named 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 Frame s. |
|
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 |
Field Detail |
---|
protected final Map<String,Object> desktopProperties
protected final PropertyChangeSupport desktopPropsSupport
Constructor Detail |
---|
public Toolkit()
Method Detail |
---|
protected abstract DesktopPeer createDesktopPeer(Desktop target) throws HeadlessException
Desktop
using the specified peer interface.
target
- the desktop to be implemented
Desktop
HeadlessException
- if GraphicsEnvironment.isHeadless()
returns trueGraphicsEnvironment.isHeadless()
,
Desktop
,
DesktopPeer
protected abstract ButtonPeer createButton(Button target) throws HeadlessException
Button
using
the specified peer interface.
target
- the button to be implemented.
Button
.
HeadlessException
- if GraphicsEnvironment.isHeadless()
returns trueGraphicsEnvironment.isHeadless()
,
Button
,
ButtonPeer
protected abstract TextFieldPeer createTextField(TextField target) throws HeadlessException
TextField
using
the specified peer interface.
target
- the text field to be implemented.
TextField
.
HeadlessException
- if GraphicsEnvironment.isHeadless()
returns trueGraphicsEnvironment.isHeadless()
,
TextField
,
TextFieldPeer
protected abstract LabelPeer createLabel(Label target) throws HeadlessException
Label
using
the specified peer interface.
target
- the label to be implemented.
Label
.
HeadlessException
- if GraphicsEnvironment.isHeadless()
returns trueGraphicsEnvironment.isHeadless()
,
Label
,
LabelPeer
protected abstract ListPeer createList(List target) throws HeadlessException
List
using
the specified peer interface.
target
- the list to be implemented.
List
.
HeadlessException
- if GraphicsEnvironment.isHeadless()
returns trueGraphicsEnvironment.isHeadless()
,
List
,
ListPeer
protected abstract CheckboxPeer createCheckbox(Checkbox target) throws HeadlessException
Checkbox
using
the specified peer interface.
target
- the check box to be implemented.
Checkbox
.
HeadlessException
- if GraphicsEnvironment.isHeadless()
returns trueGraphicsEnvironment.isHeadless()
,
Checkbox
,
CheckboxPeer
protected abstract ScrollbarPeer createScrollbar(Scrollbar target) throws HeadlessException
Scrollbar
using
the specified peer interface.
target
- the scroll bar to be implemented.
Scrollbar
.
HeadlessException
- if GraphicsEnvironment.isHeadless()
returns trueGraphicsEnvironment.isHeadless()
,
Scrollbar
,
ScrollbarPeer
protected abstract ScrollPanePeer createScrollPane(ScrollPane target) throws HeadlessException
ScrollPane
using
the specified peer interface.
target
- the scroll pane to be implemented.
ScrollPane
.
HeadlessException
- if GraphicsEnvironment.isHeadless()
returns trueGraphicsEnvironment.isHeadless()
,
ScrollPane
,
ScrollPanePeer
protected abstract TextAreaPeer createTextArea(TextArea target) throws HeadlessException
TextArea
using
the specified peer interface.
target
- the text area to be implemented.
TextArea
.
HeadlessException
- if GraphicsEnvironment.isHeadless()
returns trueGraphicsEnvironment.isHeadless()
,
TextArea
,
TextAreaPeer
protected abstract ChoicePeer createChoice(Choice target) throws HeadlessException
Choice
using
the specified peer interface.
target
- the choice to be implemented.
Choice
.
HeadlessException
- if GraphicsEnvironment.isHeadless()
returns trueGraphicsEnvironment.isHeadless()
,
Choice
,
ChoicePeer
protected abstract FramePeer createFrame(Frame target) throws HeadlessException
Frame
using
the specified peer interface.
target
- the frame to be implemented.
Frame
.
HeadlessException
- if GraphicsEnvironment.isHeadless()
returns trueGraphicsEnvironment.isHeadless()
,
Frame
,
FramePeer
protected abstract CanvasPeer createCanvas(Canvas target)
Canvas
using
the specified peer interface.
target
- the canvas to be implemented.
Canvas
.Canvas
,
CanvasPeer
protected abstract PanelPeer createPanel(Panel target)
Panel
using
the specified peer interface.
target
- the panel to be implemented.
Panel
.Panel
,
PanelPeer
protected abstract WindowPeer createWindow(Window target) throws HeadlessException
Window
using
the specified peer interface.
target
- the window to be implemented.
Window
.
HeadlessException
- if GraphicsEnvironment.isHeadless()
returns trueGraphicsEnvironment.isHeadless()
,
Window
,
WindowPeer
protected abstract DialogPeer createDialog(Dialog target) throws HeadlessException
Dialog
using
the specified peer interface.
target
- the dialog to be implemented.
Dialog
.
HeadlessException
- if GraphicsEnvironment.isHeadless()
returns trueGraphicsEnvironment.isHeadless()
,
Dialog
,
DialogPeer
protected abstract MenuBarPeer createMenuBar(MenuBar target) throws HeadlessException
MenuBar
using
the specified peer interface.
target
- the menu bar to be implemented.
MenuBar
.
HeadlessException
- if GraphicsEnvironment.isHeadless()
returns trueGraphicsEnvironment.isHeadless()
,
MenuBar
,
MenuBarPeer
protected abstract MenuPeer createMenu(Menu target) throws HeadlessException
Menu
using
the specified peer interface.
target
- the menu to be implemented.
Menu
.
HeadlessException
- if GraphicsEnvironment.isHeadless()
returns trueGraphicsEnvironment.isHeadless()
,
Menu
,
MenuPeer
protected abstract PopupMenuPeer createPopupMenu(PopupMenu target) throws HeadlessException
PopupMenu
using
the specified peer interface.
target
- the popup menu to be implemented.
PopupMenu
.
HeadlessException
- if GraphicsEnvironment.isHeadless()
returns trueGraphicsEnvironment.isHeadless()
,
PopupMenu
,
PopupMenuPeer
protected abstract MenuItemPeer createMenuItem(MenuItem target) throws HeadlessException
MenuItem
using
the specified peer interface.
target
- the menu item to be implemented.
MenuItem
.
HeadlessException
- if GraphicsEnvironment.isHeadless()
returns trueGraphicsEnvironment.isHeadless()
,
MenuItem
,
MenuItemPeer
protected abstract FileDialogPeer createFileDialog(FileDialog target) throws HeadlessException
FileDialog
using
the specified peer interface.
target
- the file dialog to be implemented.
FileDialog
.
HeadlessException
- if GraphicsEnvironment.isHeadless()
returns trueGraphicsEnvironment.isHeadless()
,
FileDialog
,
FileDialogPeer
protected abstract CheckboxMenuItemPeer createCheckboxMenuItem(CheckboxMenuItem target) throws HeadlessException
CheckboxMenuItem
using
the specified peer interface.
target
- the checkbox menu item to be implemented.
CheckboxMenuItem
.
HeadlessException
- if GraphicsEnvironment.isHeadless()
returns trueGraphicsEnvironment.isHeadless()
,
CheckboxMenuItem
,
CheckboxMenuItemPeer
protected MouseInfoPeer getMouseInfoPeer()
MouseInfo
operations.
MouseInfo
UnsupportedOperationException
- if this operation is not implementedMouseInfoPeer
,
MouseInfo
protected LightweightPeer createComponent(Component target)
target
- The Component to be created.@Deprecated protected abstract FontPeer getFontPeer(String name, int style)
Font
using
the specified peer interface.
name
- the font to be implementedstyle
- the style of the font, such as PLAIN
,
BOLD
, ITALIC
, or a combination
Font
Font
,
FontPeer
,
GraphicsEnvironment.getAllFonts()
protected void loadSystemColors(int[] systemColors) throws HeadlessException
systemColors
- an integer array.
HeadlessException
- if GraphicsEnvironment.isHeadless()
returns trueGraphicsEnvironment.isHeadless()
public void setDynamicLayout(boolean dynamic) throws HeadlessException
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.
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.
HeadlessException
- if GraphicsEnvironment.isHeadless()
returns trueisDynamicLayoutSet()
,
isDynamicLayoutActive()
,
getDesktopProperty(String propertyName)
,
GraphicsEnvironment.isHeadless()
protected boolean isDynamicLayoutSet() throws HeadlessException
HeadlessException
- if GraphicsEnvironment.isHeadless()
returns truesetDynamicLayout(boolean dynamic)
,
isDynamicLayoutActive()
,
getDesktopProperty(String propertyName)
,
GraphicsEnvironment.isHeadless()
public boolean isDynamicLayoutActive() throws HeadlessException
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.
HeadlessException
- if the GraphicsEnvironment.isHeadless()
method returns truesetDynamicLayout(boolean dynamic)
,
isDynamicLayoutSet()
,
getDesktopProperty(String propertyName)
,
GraphicsEnvironment.isHeadless()
public abstract Dimension getScreenSize() throws HeadlessException
GraphicsConfiguration
and
GraphicsDevice
.
HeadlessException
- if GraphicsEnvironment.isHeadless()
returns trueGraphicsConfiguration.getBounds()
,
GraphicsDevice.getDisplayMode()
,
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()
@Deprecated 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()
@Deprecated public abstract FontMetrics getFontMetrics(Font font)
Font
method getLineMetrics
.
font
- a font
LineMetrics
,
Font.getLineMetrics(java.lang.String, java.awt.font.FontRenderContext)
,
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 a system property named "java.awt.headless"
is set
to true
then the headless implementation
of Toolkit
is used.
If there is no "java.awt.headless"
or it is set to
false
and there is a system property named
"awt.toolkit"
,
that property is treated as the name of a class that is a subclass
of Toolkit
;
otherwise the default platform-specific implementation of
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)
Since the mechanism required to facilitate this sharing of
Image
objects may continue to hold onto images
that are no longer in use for an indefinite period of time,
developers are encouraged to implement their own caching of
images by using the createImage
variant wherever available.
If the image data contained in the specified file changes,
the Image
object returned from this method may
still contain stale information which was loaded from the
file after a prior call.
Previously loaded image data can be manually discarded by
calling the flush
method on the
returned Image
.
This method first checks if there is a security manager installed.
If so, the method calls the security manager's
checkRead
method with the file specified to ensure
that the access to the image is allowed.
filename
- the name of a file containing pixel data
in a recognized file format.
SecurityException
- if a security manager exists and its
checkRead method doesn't allow the operation.createImage(java.lang.String)
public abstract Image getImage(URL url)
Since the mechanism required to facilitate this sharing of
Image
objects may continue to hold onto images
that are no longer in use for an indefinite period of time,
developers are encouraged to implement their own caching of
images by using the createImage
variant wherever available.
If the image data stored at the specified URL changes,
the Image
object returned from this method may
still contain stale information which was fetched from the
URL after a prior call.
Previously loaded image data can be manually discarded by
calling the flush
method on the
returned Image
.
This method first checks if there is a security manager installed.
If so, the method calls the security manager's
checkPermission
method with the
url.openConnection().getPermission() permission to ensure
that the access to the image is allowed. For compatibility
with pre-1.2 security managers, if the access is denied with
FilePermission
or SocketPermission
,
the method throws the SecurityException
if the corresponding 1.1-style SecurityManager.checkXXX method
also denies permission.
url
- the URL to use in fetching the pixel data.
SecurityException
- if a security manager exists and its
checkPermission method doesn't allow
the operation.createImage(java.net.URL)
public abstract Image createImage(String filename)
This method first checks if there is a security manager installed.
If so, the method calls the security manager's
checkRead
method with the specified file to ensure
that the image creation is allowed.
filename
- the name of a file containing pixel data
in a recognized file format.
SecurityException
- if a security manager exists and its
checkRead method doesn't allow the operation.getImage(java.lang.String)
public abstract Image createImage(URL url)
This method first checks if there is a security manager installed.
If so, the method calls the security manager's
checkPermission
method with the
url.openConnection().getPermission() permission to ensure
that the image creation is allowed. For compatibility
with pre-1.2 security managers, if the access is denied with
FilePermission
or SocketPermission
,
the method throws SecurityException
if the corresponding 1.1-style SecurityManager.checkXXX method
also denies permission.
url
- the URL to use in fetching the pixel data.
SecurityException
- if a security manager exists and its
checkPermission method doesn't allow
the operation.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 PrintJob getPrintJob(Frame frame, String jobtitle, Properties props)
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.
frame
- the parent of the print dialog. May not be null.jobtitle
- the title of the PrintJob. A null title is equivalent
to "".props
- 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.
PrintJob
object, or null
if the
user cancelled the print job.
NullPointerException
- if frame is null. This exception is
always thrown when GraphicsEnvironment.isHeadless() returns
true.
SecurityException
- if this thread is not allowed to initiate a
print job requestGraphicsEnvironment.isHeadless()
,
PrintJob
,
RuntimePermission
public PrintJob getPrintJob(Frame frame, String jobtitle, JobAttributes jobAttributes, PageAttributes pageAttributes)
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.
frame
- the parent of the print dialog. May be null if and only
if jobAttributes is not null and jobAttributes.getDialog()
returns JobAttributes.DialogType.NONE or
JobAttributes.DialogType.COMMON.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.
PrintJob
object, or null
if the
user cancelled the print job.
NullPointerException
- if frame is null and either jobAttributes
is null or jobAttributes.getDialog() returns
JobAttributes.DialogType.NATIVE.
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.
This exception is always thrown when GraphicsEnvironment.isHeadless() returns true.
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 systemPrintJob
,
GraphicsEnvironment.isHeadless()
,
RuntimePermission
,
JobAttributes
,
PageAttributes
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 Clipboard getSystemSelection() throws HeadlessException
Clipboard
object. This allows an application to read and
modify the current, system-wide selection.
An application is responsible for updating the system selection whenever
the user selects text, using either the mouse or the keyboard.
Typically, this is implemented by installing a
FocusListener
on all Component
s which support
text selection, and, between FOCUS_GAINED
and
FOCUS_LOST
events delivered to that Component
,
updating the system selection Clipboard
when the selection
changes inside the Component
. Properly updating the system
selection ensures that a Java application will interact correctly with
native applications and other Java applications running simultaneously
on the system. Note that java.awt.TextComponent
and
javax.swing.text.JTextComponent
already adhere to this
policy. When using these classes, and their subclasses, developers need
not write any additional code.
Some platforms do not support a system selection Clipboard
.
On those platforms, this method will return null
. In such a
case, an application is absolved from its responsibility to update the
system selection Clipboard
as described above.
Each actual implementation of this method should first check if there
is a SecurityManager
installed. If there is, the method
should call the SecurityManager
's
checkSystemClipboardAccess
method to ensure that client
code has access the system selection. If the default implementation of
checkSystemClipboardAccess
is used (that is, if the method
is not overridden), then this results in a call to the
SecurityManager
's checkPermission
method with
an AWTPermission("accessClipboard")
permission.
Clipboard
, or
null
if the native platform does not support a
system selection Clipboard
HeadlessException
- if GraphicsEnvironment.isHeadless()
returns trueClipboard
,
FocusListener
,
FocusEvent.FOCUS_GAINED
,
FocusEvent.FOCUS_LOST
,
TextComponent
,
JTextComponent
,
AWTPermission
,
GraphicsEnvironment.isHeadless()
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 getLockingKeyState(int keyCode) throws UnsupportedOperationException
VK_CAPS_LOCK
,
VK_NUM_LOCK
,
VK_SCROLL_LOCK
, and
VK_KANA_LOCK
.
IllegalArgumentException
- if keyCode
is not one of the valid key codes
UnsupportedOperationException
- if the host system doesn't
allow getting the state of this key programmatically, or if the keyboard
doesn't have this key
HeadlessException
- if GraphicsEnvironment.isHeadless()
returns trueGraphicsEnvironment.isHeadless()
public void setLockingKeyState(int keyCode, boolean on) throws UnsupportedOperationException
VK_CAPS_LOCK
,
VK_NUM_LOCK
,
VK_SCROLL_LOCK
, and
VK_KANA_LOCK
.
Depending on the platform, setting the state of a locking key may involve event processing and therefore may not be immediately observable through getLockingKeyState.
IllegalArgumentException
- if keyCode
is not one of the valid key codes
UnsupportedOperationException
- if the host system doesn't
allow setting the state of this key programmatically, or if the keyboard
doesn't have this key
HeadlessException
- if GraphicsEnvironment.isHeadless()
returns trueGraphicsEnvironment.isHeadless()
protected static Container getNativeContainer(Component c)
public Cursor createCustomCursor(Image cursor, Point hotSpot, String name) throws IndexOutOfBoundsException, HeadlessException
Note that multi-frame images are invalid and may cause this method to hang.
cursor
- the image to display when the cursor is activedhotSpot
- 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
IndexOutOfBoundsException
- if the hotSpot values are outside
the bounds of the cursor
HeadlessException
- if GraphicsEnvironment.isHeadless()
returns trueGraphicsEnvironment.isHeadless()
public Dimension getBestCursorSize(int preferredWidth, int preferredHeight) throws HeadlessException
Note: if an image is used whose dimensions don't match a supported size (as returned by this method), the Toolkit implementation will attempt to resize the image to a supported size. Since converting low-resolution images is difficult, no guarantees are made as to the quality of a cursor image which isn't a supported size. It is therefore recommended that this method be called and an appropriate image used so no image conversion is made.
preferredWidth
- the preferred cursor width the component would like
to use.preferredHeight
- the preferred cursor height the component would like
to use.
HeadlessException
- if GraphicsEnvironment.isHeadless()
returns trueGraphicsEnvironment.isHeadless()
public int getMaximumCursorColors() throws HeadlessException
Note: if an image is used which has more colors in its palette than the supported maximum, the Toolkit implementation will attempt to flatten the palette to the maximum. Since converting low-resolution images is difficult, no guarantees are made as to the quality of a cursor image which has more colors than the system supports. It is therefore recommended that this method be called and an appropriate image used so no image conversion is made.
HeadlessException
- if GraphicsEnvironment.isHeadless()
returns trueGraphicsEnvironment.isHeadless()
public boolean isFrameStateSupported(int state) throws HeadlessException
Frame
s. This method tells whether the UI
concept of, say, maximization or iconification is
supported. It will always return false for "compound" states
like Frame.ICONIFIED|Frame.MAXIMIZED_VERT
.
In other words, the rule of thumb is that only queries with a
single frame state constant as an argument are meaningful.
Note that supporting a given concept is a platform- dependent feature. Due to native limitations the Toolkit object may report a particular state as supported, however at the same time the Toolkit object will be unable to apply the state to a given frame. This circumstance has two following consequences:
false
for the present
method actually indicates that the given state is not
supported. If the method returns true
the given state
may still be unsupported and/or unavailable for a particular
frame.
WindowEvent.getNewState()
method of the
WindowEvent
received through the WindowStateListener
, rather than assuming
that the state given to the setExtendedState()
method
will be definitely applied. For more information see the
documentation for the Frame.setExtendedState(int)
method.
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
.Window.addWindowStateListener(java.awt.event.WindowStateListener)
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()
EventQueue
instance, without checking access. For security reasons,
this can only be called from a Toolkit
subclass.
EventQueue
objectpublic abstract DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException
InvalidDnDOperationException
GraphicsEnvironment.isHeadless()
public <T extends DragGestureRecognizer> T createDragGestureRecognizer(Class<T> abstractRecognizerClass, DragSource ds, Component c, int srcActions, DragGestureListener dgl)
abstractRecognizerClass
- The abstract class of the required recognizerds
- The DragSourcec
- The Component target for the DragGestureRecognizersrcActions
- The actions permitted for the gesturedgl
- The DragGestureListener
GraphicsEnvironment.isHeadless()
public final Object getDesktopProperty(String propertyName)
protected final void setDesktopProperty(String name, Object newValue)
protected Object lazilyLoadDesktopProperty(String name)
protected void initializeDesktopProperties()
public void addPropertyChangeListener(String name, PropertyChangeListener pcl)
name
- The name of the property to listen forpcl
- The property change listenerpublic void removePropertyChangeListener(String name, PropertyChangeListener pcl)
name
- The name of the property to removepcl
- The property change listenerpublic PropertyChangeListener[] getPropertyChangeListeners()
PropertyChangeListener
s
or an empty array if no property change
listeners are currently registeredpublic PropertyChangeListener[] getPropertyChangeListeners(String propertyName)
PropertyChangeListener
s
associated with the named property.
propertyName
- the named property
PropertyChangeListener
s associated with
the named property or an empty array if no such listeners have
been addedpublic boolean isAlwaysOnTopSupported()
Window.isAlwaysOnTopSupported()
.
true
, if current toolkit supports the always-on-top mode,
otherwise returns false
Window.isAlwaysOnTopSupported()
,
Window.setAlwaysOnTop(boolean)
public abstract boolean isModalityTypeSupported(Dialog.ModalityType modalityType)
Dialog.ModalityType.MODELESS
is used instead.
modalityType
- modality type to be checked for support by this toolkit
true
, if current toolkit supports given modality
type, false
otherwiseDialog.ModalityType
,
Dialog.getModalityType()
,
Dialog.setModalityType(java.awt.Dialog.ModalityType)
public abstract boolean isModalExclusionTypeSupported(Dialog.ModalExclusionType modalExclusionType)
Dialog.ModalExclusionType.NO_EXCLUDE
is used instead.
modalExclusionType
- modal exclusion type to be checked for support by this toolkit
true
, if current toolkit supports given modal exclusion
type, false
otherwiseDialog.ModalExclusionType
,
Window.getModalExclusionType()
,
Window.setModalExclusionType(java.awt.Dialog.ModalExclusionType)
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)
,
getAWTEventListeners()
,
SecurityManager.checkPermission(java.security.Permission)
,
AWTEvent
,
AWTPermission
,
AWTEventListener
,
AWTEventListenerProxy
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.addAWTEventListener(java.awt.event.AWTEventListener, long)
,
getAWTEventListeners()
,
SecurityManager.checkPermission(java.security.Permission)
,
AWTEvent
,
AWTPermission
,
AWTEventListener
,
AWTEventListenerProxy
public AWTEventListener[] getAWTEventListeners()
AWTEventListener
s
registered on this toolkit.
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.
AWTEventListener
s 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
,
AWTEventListenerProxy
public AWTEventListener[] getAWTEventListeners(long eventMask)
AWTEventListener
s
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.
eventMask
- the bitmask of event types to listen for
AWTEventListener
s 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
public abstract Map<TextAttribute,?> mapInputMethodHighlight(InputMethodHighlight highlight) throws HeadlessException
highlight
- input method highlight
null
HeadlessException
- if
GraphicsEnvironment.isHeadless
returns trueGraphicsEnvironment.isHeadless()
public boolean areExtraMouseButtonsEnabled() throws HeadlessException
EventQueue
.
sun.awt.enableExtraMouseButtons
property before the Toolkit
class initialization. This setting could be done on the application
startup by the following command:
java -Dsun.awt.enableExtraMouseButtons=false ApplicationAlternatively, the property could be set in the application by using the following code:
System.setProperty("sun.awt.enableExtraMouseButtons", "true");before the
Toolkit
class initialization.
If not set by the time of the Toolkit
class initialization, this property will be
initialized with true
.
Changing this value after the Toolkit
class initialization will have no effect.
The current value could be queried by using the
System.getProperty("sun.awt.enableExtraMouseButtons")
method.
true
if events from extra mouse buttons are allowed to be processed and posted;
false
otherwise
HeadlessException
- if GraphicsEnvironment.isHeadless() returns trueSystem.getProperty(String propertyName)
,
System.setProperty(String propertyName, String value)
,
EventQueue
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |