java.awt
Class Toolkit
java.lang.Object
|
+--java.awt.Toolkit
public abstract class
Toolkitextends
Object The AWT system uses a set of native peer objects to implement its
widgets. These peers are provided by a peer toolkit, that is accessed
via a subclass of this superclass. The system toolkit is retrieved
by the static methods getDefaultToolkit
. This method
determines the system toolkit by examining the system property
awt.toolkit
. That property is set to the name of the
Toolkit
subclass for the specified peer set. If the
awt.toolkit
property is not set, then the default
toolkit gnu.java.awt.peer.gtk.GtkToolkit
is used. This
toolkit creates its peers using the GTK+ toolkit.
Author:- Aaron M. Renn <arenn@urbanophile.com>
void | addAWTEventListener(java.awt.event.AWTEventListener listener, long eventMask)
|
void | addPropertyChangeListener(java.lang.String name, java.beans.PropertyChangeListener pcl)
|
void | beep()
|
int | checkImage(java.awt.Image image, int width, int height, java.awt.image.ImageObserver observer)
|
java.awt.peer.ButtonPeer | createButton(java.awt.Button target)
|
java.awt.peer.CanvasPeer | createCanvas(java.awt.Canvas target)
|
java.awt.peer.CheckboxPeer | createCheckbox(java.awt.Checkbox target)
|
java.awt.peer.CheckboxMenuItemPeer | createCheckboxMenuItem(java.awt.CheckboxMenuItem target)
|
java.awt.peer.ChoicePeer | createChoice(java.awt.Choice target)
|
java.awt.peer.LightweightPeer | createComponent(java.awt.Component target)
|
java.awt.Cursor | createCustomCursor(java.awt.Image cursor, java.awt.Point hotSpot, java.lang.String name)
|
java.awt.peer.DialogPeer | createDialog(java.awt.Dialog target)
|
java.awt.dnd.DragGestureRecognizer | createDragGestureRecognizer(java.lang.Class recognizer, java.awt.dnd.DragSource ds, java.awt.Component comp, int actions, java.awt.dnd.DragGestureListener l)
|
java.awt.dnd.peer.DragSourceContextPeer | createDragSourceContextPeer(java.awt.dnd.DragGestureEvent e)
|
java.awt.peer.FileDialogPeer | createFileDialog(java.awt.FileDialog target)
|
java.awt.peer.FramePeer | createFrame(java.awt.Frame target)
|
java.awt.Image | createImage(java.lang.String filename)
|
java.awt.Image | createImage(java.net.URL url)
|
java.awt.Image | createImage(java.awt.image.ImageProducer producer)
|
java.awt.Image | createImage(byte[] data)
|
java.awt.Image | createImage(byte[] data, int offset, int len)
|
java.awt.peer.LabelPeer | createLabel(java.awt.Label target)
|
java.awt.peer.ListPeer | createList(java.awt.List target)
|
java.awt.peer.MenuPeer | createMenu(java.awt.Menu target)
|
java.awt.peer.MenuBarPeer | createMenuBar(java.awt.MenuBar target)
|
java.awt.peer.MenuItemPeer | createMenuItem(java.awt.MenuItem target)
|
java.awt.peer.PanelPeer | createPanel(java.awt.Panel target)
|
java.awt.peer.PopupMenuPeer | createPopupMenu(java.awt.PopupMenu target)
|
java.awt.peer.ScrollPanePeer | createScrollPane(java.awt.ScrollPane target)
|
java.awt.peer.ScrollbarPeer | createScrollbar(java.awt.Scrollbar target)
|
java.awt.peer.TextAreaPeer | createTextArea(java.awt.TextArea target)
|
java.awt.peer.TextFieldPeer | createTextField(java.awt.TextField target)
|
java.awt.peer.WindowPeer | createWindow(java.awt.Window target)
|
java.awt.event.AWTEventListener[] | getAWTEventListeners()
|
java.awt.event.AWTEventListener[] | getAWTEventListeners(long mask)
|
java.awt.Dimension | getBestCursorSize(int preferredWidth, int preferredHeight)
|
java.awt.image.ColorModel | getColorModel()
|
static java.awt.Toolkit | getDefaultToolkit()
|
java.lang.Object | getDesktopProperty(java.lang.String propertyName)
|
java.lang.String[] | getFontList()
|
java.awt.FontMetrics | getFontMetrics(java.awt.Font name)
|
java.awt.peer.FontPeer | getFontPeer(java.lang.String name, int style)
|
java.awt.Image | getImage(java.lang.String name)
|
java.awt.Image | getImage(java.net.URL url)
|
boolean | getLockingKeyState(int keyCode)
|
int | getMaximumCursorColors()
|
int | getMenuShortcutKeyMask()
|
static java.awt.Container | getNativeContainer(java.awt.Component component)
|
java.awt.PrintJob | getPrintJob(java.awt.Frame frame, java.lang.String title, java.util.Properties props)
|
java.awt.PrintJob | getPrintJob(java.awt.Frame frame, java.lang.String title, java.awt.JobAttributes jobAttr, java.awt.PageAttributes pageAttr)
|
static java.lang.String | getProperty(java.lang.String key, java.lang.String def)
|
java.beans.PropertyChangeListener[] | getPropertyChangeListeners()
|
java.beans.PropertyChangeListener[] | getPropertyChangeListeners(java.lang.String name)
|
java.awt.Insets | getScreenInsets(java.awt.GraphicsConfiguration gc)
|
int | getScreenResolution()
|
java.awt.Dimension | getScreenSize()
|
java.awt.datatransfer.Clipboard | getSystemClipboard()
|
java.awt.EventQueue | getSystemEventQueue()
|
java.awt.EventQueue | getSystemEventQueueImpl()
|
java.awt.datatransfer.Clipboard | getSystemSelection()
|
void | initializeDesktopProperties()
|
boolean | isDynamicLayoutActive()
|
boolean | isDynamicLayoutSet()
|
boolean | isFrameStateSupported(int state)
|
java.lang.Object | lazilyLoadDesktopProperty(java.lang.String name)
|
void | loadSystemColors(int[] systemColors)
|
java.util.Map | mapInputMethodHighlight(java.awt.im.InputMethodHighlight highlight)
|
boolean | prepareImage(java.awt.Image image, int width, int height, java.awt.image.ImageObserver observer)
|
void | removeAWTEventListener(java.awt.event.AWTEventListener listener)
|
void | removePropertyChangeListener(java.lang.String name, java.beans.PropertyChangeListener pcl)
|
void | setDesktopProperty(java.lang.String name, java.lang.Object newValue)
|
void | setDynamicLayout(boolean dynamic)
|
void | setLockingKeyState(int keyCode, boolean on)
|
void | sync()
|
desktopProperties
protected final Map desktopProperties
desktopPropsSupport
protected final PropertyChangeSupport desktopPropsSupport
Toolkit
public Toolkit()
Default constructor for subclasses.
addAWTEventListener
public void addAWTEventListener(java.awt.event.AWTEventListener listener, long eventMask)
Parameters:
addPropertyChangeListener
public void addPropertyChangeListener(java.lang.String name, java.beans.PropertyChangeListener pcl)
Parameters:
beep
public void beep()
Causes a "beep" tone to be generated.
checkImage
public int checkImage(java.awt.Image image, int width, int height, java.awt.image.ImageObserver observer)
Checks the status of specified image as it is being readied for
rendering.
Parameters:
Returns:
- A union of the bitmasks from
java.awt.image.ImageObserver
that indicates the current
state of the imaging readying process.
createButton
protected ButtonPeer createButton(java.awt.Button target)
Creates a peer object for the specified Button
.
Parameters:
Returns:
- The peer for the specified
Button
object.
Throws:
createCanvas
protected CanvasPeer createCanvas(java.awt.Canvas target)
Creates a peer object for the specified Canvas
.
Parameters:
Returns:
- The peer for the specified
Canvas
object.
createCheckbox
protected CheckboxPeer createCheckbox(java.awt.Checkbox target)
Creates a peer object for the specified Checkbox
.
Parameters:
Returns:
- The peer for the specified
Checkbox
object.
Throws:
createCheckboxMenuItem
protected CheckboxMenuItemPeer createCheckboxMenuItem(java.awt.CheckboxMenuItem target)
Creates a peer object for the specified CheckboxMenuItem
.
Parameters:
Returns:
- The peer for the specified
CheckboxMenuItem
object.
Throws:
createChoice
protected ChoicePeer createChoice(java.awt.Choice target)
Creates a peer object for the specified Choice
.
Parameters:
Returns:
- The peer for the specified
Choice
object.
Throws:
createComponent
protected LightweightPeer createComponent(java.awt.Component target)
Creates a peer object for the specified Component
. The
peer returned by this method is not a native windowing system peer
with its own native window. Instead, this method allows the component
to draw on its parent window as a "lightweight" widget.
XXX: FIXME
Parameters:
Returns:
- The peer for the specified
Component
object.
createCustomCursor
public Cursor createCustomCursor(java.awt.Image cursor, java.awt.Point hotSpot, java.lang.String name)
Parameters:
createDialog
protected DialogPeer createDialog(java.awt.Dialog target)
Creates a peer object for the specified Dialog
.
Parameters:
Returns:
- The peer for the specified font name.
Throws:
createDragGestureRecognizer
public DragGestureRecognizer createDragGestureRecognizer(java.lang.Class recognizer, java.awt.dnd.DragSource ds, java.awt.Component comp, int actions, java.awt.dnd.DragGestureListener l)
Since:Parameters:
createDragSourceContextPeer
public DragSourceContextPeer createDragSourceContextPeer(java.awt.dnd.DragGestureEvent e)
Since:Parameters:
createFileDialog
protected FileDialogPeer createFileDialog(java.awt.FileDialog target)
Creates a peer object for the specified FileDialog
.
Parameters:
Returns:
- The peer for the specified
FileDialog
object.
Throws:
createFrame
protected FramePeer createFrame(java.awt.Frame target)
Creates a peer object for the specified Frame
.
Parameters:
Returns:
- The peer for the specified
Frame
object.
Throws:
createImage
public Image createImage(byte[] data)
Creates an image from the specified byte array. The array must be in
a recognized format. Supported formats vary from toolkit to toolkit.
Parameters:
Returns:
createImage
public Image createImage(byte[] data, int offset, int len)
Creates an image from the specified portion of the byte array passed.
The array must be in a recognized format. Supported formats vary from
toolkit to toolkit.
Parameters:
Returns:
createImage
public Image createImage(java.awt.image.ImageProducer producer)
Creates an image using the specified ImageProducer
Parameters:
Returns:
createImage
public Image createImage(java.lang.String filename)
Parameters:
createImage
public Image createImage(java.net.URL url)
Parameters:
createLabel
protected LabelPeer createLabel(java.awt.Label target)
Creates a peer object for the specified Label
.
Parameters:
Returns:
- The peer for the specified
Label
object.
Throws:
createList
protected ListPeer createList(java.awt.List target)
Creates a peer object for the specified List
.
Parameters:
Returns:
- The peer for the specified
List
object.
Throws:
createMenu
protected MenuPeer createMenu(java.awt.Menu target)
Creates a peer object for the specified Menu
.
Parameters:
Returns:
- The peer for the specified
Menu
object.
Throws:
createMenuBar
protected MenuBarPeer createMenuBar(java.awt.MenuBar target)
Creates a peer object for the specified MenuBar
.
Parameters:
Returns:
- The peer for the specified
MenuBar
object.
Throws:
createMenuItem
protected MenuItemPeer createMenuItem(java.awt.MenuItem target)
Creates a peer object for the specified MenuItem
.
Parameters:
Returns:
- The peer for the specified
MenuItem
object.
Throws:
createPanel
protected PanelPeer createPanel(java.awt.Panel target)
Creates a peer object for the specified Panel
.
Parameters:
Returns:
- The peer for the specified
Panel
object.
createPopupMenu
protected PopupMenuPeer createPopupMenu(java.awt.PopupMenu target)
Creates a peer object for the specified PopupMenu
.
Parameters:
Returns:
- The peer for the specified
PopupMenu
object.
Throws:
createScrollPane
protected ScrollPanePeer createScrollPane(java.awt.ScrollPane target)
Creates a peer object for the specified ScrollPane
.
Parameters:
Returns:
- The peer for the specified
ScrollPane
object.
Throws:
createScrollbar
protected ScrollbarPeer createScrollbar(java.awt.Scrollbar target)
Creates a peer object for the specified Scrollbar
.
Parameters:
Returns:
- The peer for the specified
Scrollbar
object.
Throws:
createTextArea
protected TextAreaPeer createTextArea(java.awt.TextArea target)
Creates a peer object for the specified TextArea
.
Parameters:
Returns:
- The peer for the specified
TextArea
object.
Throws:
createTextField
protected TextFieldPeer createTextField(java.awt.TextField target)
Creates a peer object for the specified TextField
.
Parameters:
Returns:
- The peer for the specified
TextField
object.
Throws:
createWindow
protected WindowPeer createWindow(java.awt.Window target)
Creates a peer object for the specified Window
.
Parameters:
Returns:
- The peer for the specified
Window
object.
Throws:
getAWTEventListeners
public AWTEventListener[] getAWTEventListeners()
Since:
getAWTEventListeners
public AWTEventListener[] getAWTEventListeners(long mask)
Since:Parameters:
getBestCursorSize
public Dimension getBestCursorSize(int preferredWidth, int preferredHeight)
Parameters:
getColorModel
public ColorModel getColorModel()
Returns the color model of the screen.
Returns:
- The color model of the screen.
Throws:
getDefaultToolkit
public static Toolkit getDefaultToolkit()
Returns an instance of the default toolkit. The default toolkit is
the subclass of Toolkit
specified in the system property
awt.toolkit
, or gnu.java.awt.peer.gtk.GtkToolkit
if the property is not set.
Returns:
- An instance of the system default toolkit.
Throws:
AWTError
- If the toolkit cannot be loaded.
getDesktopProperty
public final Object getDesktopProperty(java.lang.String propertyName)
Parameters:
getFontList
public String[] getFontList()
Returns the names of the available fonts.
Returns:
- The names of the available fonts.
getFontMetrics
public FontMetrics getFontMetrics(java.awt.Font name)
Return the font metrics for the specified font
Parameters:
Returns:
- The requested font metrics.
getFontPeer
protected FontPeer getFontPeer(java.lang.String name, int style)
Creates a peer object for the specified font name.
Parameters:
Returns:
- The peer for the specified font name.
getImage
public Image getImage(java.lang.String name)
Returns an image from the specified file, which must be in a
recognized format. Supported formats vary from toolkit to toolkit.
Parameters:
Returns:
- name The name of the file to read the image from.
getImage
public Image getImage(java.net.URL url)
Returns an image from the specified URL, which must be in a
recognized format. Supported formats vary from toolkit to toolkit.
Parameters:
Returns:
- url The URl to read the image from.
getLockingKeyState
public boolean getLockingKeyState(int keyCode)
Parameters:
getMaximumCursorColors
public int getMaximumCursorColors()
getMenuShortcutKeyMask
public int getMenuShortcutKeyMask()
Returns the accelerator key mask for menu shortcuts. The default is
Event.CTRL_MASK
. A toolkit must override this method
to change the default.
Returns:
- The key mask for the menu accelerator key.
Throws:
getNativeContainer
protected static Container getNativeContainer(java.awt.Component component)
Returns the native container object of the specified component. This
method is necessary because the parent component might be a lightweight
component.
Parameters:
Returns:
- The native container object for this component.
getPrintJob
public PrintJob getPrintJob(java.awt.Frame frame, java.lang.String title, java.awt.JobAttributes jobAttr, java.awt.PageAttributes pageAttr)
Since:Parameters:
getPrintJob
public PrintJob getPrintJob(java.awt.Frame frame, java.lang.String title, java.util.Properties props)
Returns a instance of PrintJob
for the specified
arguments.
Parameters:
Returns:
- The requested print job, or
null
if the job
was cancelled.
getProperty
public static String getProperty(java.lang.String key, java.lang.String def)
Returns the value of the property with the specified name, or the
default value if the property does not exist.
Parameters:
getPropertyChangeListeners
public PropertyChangeListener[] getPropertyChangeListeners()
Since:
getPropertyChangeListeners
public PropertyChangeListener[] getPropertyChangeListeners(java.lang.String name)
Since:Parameters:
getScreenInsets
public Insets getScreenInsets(java.awt.GraphicsConfiguration gc)
Since:Parameters:
Throws:
getScreenResolution
public int getScreenResolution()
Returns the screen resolution in dots per square inch.
Returns:
- The screen resolution in dots per square inch.
Throws:
getScreenSize
public Dimension getScreenSize()
Returns the dimensions of the screen in pixels.
Returns:
- The dimensions of the screen in pixels.
Throws:
getSystemClipboard
public Clipboard getSystemClipboard()
Returns the system clipboard.
Returns:
Throws:
getSystemEventQueue
public final EventQueue getSystemEventQueue()
Returns the event queue for the applet. Despite the word "System"
in the name of this method, there is no guarantee that the same queue
is shared system wide.
Returns:
- The event queue for this applet (or application)
getSystemEventQueueImpl
protected EventQueue getSystemEventQueueImpl()
// FIXME: What does this do?
getSystemSelection
public Clipboard getSystemSelection()
Since:Throws:
initializeDesktopProperties
protected void initializeDesktopProperties()
isDynamicLayoutActive
public boolean isDynamicLayoutActive()
Since:Throws:
isDynamicLayoutSet
protected boolean isDynamicLayoutSet()
Since:Throws:
isFrameStateSupported
public boolean isFrameStateSupported(int state)
Since:Parameters:
lazilyLoadDesktopProperty
protected Object lazilyLoadDesktopProperty(java.lang.String name)
Parameters:
loadSystemColors
protected void loadSystemColors(int[] systemColors)
Copies the current system colors into the specified array. This is
the interface used by the SystemColors
class.
Parameters:
Throws:
mapInputMethodHighlight
public Map mapInputMethodHighlight(java.awt.im.InputMethodHighlight highlight)
Since:Parameters:
prepareImage
public boolean prepareImage(java.awt.Image image, int width, int height, java.awt.image.ImageObserver observer)
Readies an image to be rendered on the screen. The width and height
values can be set to the default sizes for the image by passing -1
in those parameters.
Parameters:
Returns:
true
if the image is already prepared for rendering,
false
otherwise.
removeAWTEventListener
public void removeAWTEventListener(java.awt.event.AWTEventListener listener)
Parameters:
removePropertyChangeListener
public void removePropertyChangeListener(java.lang.String name, java.beans.PropertyChangeListener pcl)
Parameters:
setDesktopProperty
protected final void setDesktopProperty(java.lang.String name, java.lang.Object newValue)
Parameters:
setDynamicLayout
public void setDynamicLayout(boolean dynamic)
Since:Parameters:
Throws:
setLockingKeyState
public void setLockingKeyState(int keyCode, boolean on)
Parameters:
sync
public void sync()
Flushes any buffered data to the screen so that it is in sync with
what the AWT system has drawn to it.
getDefaultToolkit
. This method determines the system toolkit by examining the system propertyawt.toolkit
. That property is set to the name of theToolkit
subclass for the specified peer set. If theawt.toolkit
property is not set, then the default toolkitgnu.java.awt.peer.gtk.GtkToolkit
is used. This toolkit creates its peers using the GTK+ toolkit.