Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.awt

Class Toolkit

java.lang.Object
|
+--java.awt.Toolkit


public abstract class Toolkit

extends 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:

Field Summary

java.util.MapdesktopProperties

java.beans.PropertyChangeSupportdesktopPropsSupport

Constructor Summary

Toolkit()

Default constructor for subclasses.

Method Summary

voidaddAWTEventListener(java.awt.event.AWTEventListener listener, long eventMask)

voidaddPropertyChangeListener(java.lang.String name, java.beans.PropertyChangeListener pcl)

voidbeep()

Causes a "beep" tone to be generated.
intcheckImage(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.
java.awt.peer.ButtonPeercreateButton(java.awt.Button target)

Creates a peer object for the specified Button.
java.awt.peer.CanvasPeercreateCanvas(java.awt.Canvas target)

Creates a peer object for the specified Canvas.
java.awt.peer.CheckboxPeercreateCheckbox(java.awt.Checkbox target)

Creates a peer object for the specified Checkbox.
java.awt.peer.CheckboxMenuItemPeercreateCheckboxMenuItem(java.awt.CheckboxMenuItem target)

Creates a peer object for the specified CheckboxMenuItem.
java.awt.peer.ChoicePeercreateChoice(java.awt.Choice target)

Creates a peer object for the specified Choice.
java.awt.peer.LightweightPeercreateComponent(java.awt.Component target)

Creates a peer object for the specified Component.
java.awt.CursorcreateCustomCursor(java.awt.Image cursor, java.awt.Point hotSpot, java.lang.String name)

java.awt.peer.DialogPeercreateDialog(java.awt.Dialog target)

Creates a peer object for the specified Dialog.
java.awt.dnd.DragGestureRecognizercreateDragGestureRecognizer(java.lang.Class recognizer, java.awt.dnd.DragSource ds, java.awt.Component comp, int actions, java.awt.dnd.DragGestureListener l)

java.awt.dnd.peer.DragSourceContextPeercreateDragSourceContextPeer(java.awt.dnd.DragGestureEvent e)

java.awt.peer.FileDialogPeercreateFileDialog(java.awt.FileDialog target)

Creates a peer object for the specified FileDialog.
java.awt.peer.FramePeercreateFrame(java.awt.Frame target)

Creates a peer object for the specified Frame.
java.awt.ImagecreateImage(java.lang.String filename)

java.awt.ImagecreateImage(java.net.URL url)

java.awt.ImagecreateImage(java.awt.image.ImageProducer producer)

Creates an image using the specified ImageProducer
java.awt.ImagecreateImage(byte[] data)

Creates an image from the specified byte array.
java.awt.ImagecreateImage(byte[] data, int offset, int len)

Creates an image from the specified portion of the byte array passed.
java.awt.peer.LabelPeercreateLabel(java.awt.Label target)

Creates a peer object for the specified Label.
java.awt.peer.ListPeercreateList(java.awt.List target)

Creates a peer object for the specified List.
java.awt.peer.MenuPeercreateMenu(java.awt.Menu target)

Creates a peer object for the specified Menu.
java.awt.peer.MenuBarPeercreateMenuBar(java.awt.MenuBar target)

Creates a peer object for the specified MenuBar.
java.awt.peer.MenuItemPeercreateMenuItem(java.awt.MenuItem target)

Creates a peer object for the specified MenuItem.
java.awt.peer.PanelPeercreatePanel(java.awt.Panel target)

Creates a peer object for the specified Panel.
java.awt.peer.PopupMenuPeercreatePopupMenu(java.awt.PopupMenu target)

Creates a peer object for the specified PopupMenu.
java.awt.peer.ScrollPanePeercreateScrollPane(java.awt.ScrollPane target)

Creates a peer object for the specified ScrollPane.
java.awt.peer.ScrollbarPeercreateScrollbar(java.awt.Scrollbar target)

Creates a peer object for the specified Scrollbar.
java.awt.peer.TextAreaPeercreateTextArea(java.awt.TextArea target)

Creates a peer object for the specified TextArea.
java.awt.peer.TextFieldPeercreateTextField(java.awt.TextField target)

Creates a peer object for the specified TextField.
java.awt.peer.WindowPeercreateWindow(java.awt.Window target)

Creates a peer object for the specified Window.
java.awt.event.AWTEventListener[]getAWTEventListeners()

java.awt.event.AWTEventListener[]getAWTEventListeners(long mask)

java.awt.DimensiongetBestCursorSize(int preferredWidth, int preferredHeight)

java.awt.image.ColorModelgetColorModel()

Returns the color model of the screen.
static java.awt.ToolkitgetDefaultToolkit()

Returns an instance of the default toolkit.
java.lang.ObjectgetDesktopProperty(java.lang.String propertyName)

java.lang.String[]getFontList()

Returns the names of the available fonts.
java.awt.FontMetricsgetFontMetrics(java.awt.Font name)

Return the font metrics for the specified font
java.awt.peer.FontPeergetFontPeer(java.lang.String name, int style)

Creates a peer object for the specified font name.
java.awt.ImagegetImage(java.lang.String name)

Returns an image from the specified file, which must be in a recognized format.
java.awt.ImagegetImage(java.net.URL url)

Returns an image from the specified URL, which must be in a recognized format.
booleangetLockingKeyState(int keyCode)

intgetMaximumCursorColors()

intgetMenuShortcutKeyMask()

Returns the accelerator key mask for menu shortcuts.
static java.awt.ContainergetNativeContainer(java.awt.Component component)

Returns the native container object of the specified component.
java.awt.PrintJobgetPrintJob(java.awt.Frame frame, java.lang.String title, java.util.Properties props)

Returns a instance of PrintJob for the specified arguments.
java.awt.PrintJobgetPrintJob(java.awt.Frame frame, java.lang.String title, java.awt.JobAttributes jobAttr, java.awt.PageAttributes pageAttr)

static java.lang.StringgetProperty(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.
java.beans.PropertyChangeListener[]getPropertyChangeListeners()

java.beans.PropertyChangeListener[]getPropertyChangeListeners(java.lang.String name)

java.awt.InsetsgetScreenInsets(java.awt.GraphicsConfiguration gc)

intgetScreenResolution()

Returns the screen resolution in dots per square inch.
java.awt.DimensiongetScreenSize()

Returns the dimensions of the screen in pixels.
java.awt.datatransfer.ClipboardgetSystemClipboard()

Returns the system clipboard.
java.awt.EventQueuegetSystemEventQueue()

Returns the event queue for the applet.
java.awt.EventQueuegetSystemEventQueueImpl()

// FIXME: What does this do?
java.awt.datatransfer.ClipboardgetSystemSelection()

voidinitializeDesktopProperties()

booleanisDynamicLayoutActive()

booleanisDynamicLayoutSet()

booleanisFrameStateSupported(int state)

java.lang.ObjectlazilyLoadDesktopProperty(java.lang.String name)

voidloadSystemColors(int[] systemColors)

Copies the current system colors into the specified array.
java.util.MapmapInputMethodHighlight(java.awt.im.InputMethodHighlight highlight)

booleanprepareImage(java.awt.Image image, int width, int height, java.awt.image.ImageObserver observer)

Readies an image to be rendered on the screen.
voidremoveAWTEventListener(java.awt.event.AWTEventListener listener)

voidremovePropertyChangeListener(java.lang.String name, java.beans.PropertyChangeListener pcl)

voidsetDesktopProperty(java.lang.String name, java.lang.Object newValue)

voidsetDynamicLayout(boolean dynamic)

voidsetLockingKeyState(int keyCode, boolean on)

voidsync()

Flushes any buffered data to the screen so that it is in sync with what the AWT system has drawn to it.

Field Details

desktopProperties

protected final Map desktopProperties


desktopPropsSupport

protected final PropertyChangeSupport desktopPropsSupport


Constructor Details

Toolkit

public Toolkit()

Default constructor for subclasses.


Method Details

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:


createButton

protected ButtonPeer createButton(java.awt.Button target)

Creates a peer object for the specified Button.

Parameters:

Returns:

Throws:


createCanvas

protected CanvasPeer createCanvas(java.awt.Canvas target)

Creates a peer object for the specified Canvas.

Parameters:

Returns:


createCheckbox

protected CheckboxPeer createCheckbox(java.awt.Checkbox target)

Creates a peer object for the specified Checkbox.

Parameters:

Returns:

Throws:


createCheckboxMenuItem

protected CheckboxMenuItemPeer createCheckboxMenuItem(java.awt.CheckboxMenuItem target)

Creates a peer object for the specified CheckboxMenuItem.

Parameters:

Returns:

Throws:


createChoice

protected ChoicePeer createChoice(java.awt.Choice target)

Creates a peer object for the specified Choice.

Parameters:

Returns:

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:


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:

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:

Throws:


createFrame

protected FramePeer createFrame(java.awt.Frame target)

Creates a peer object for the specified Frame.

Parameters:

Returns:

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:

Throws:


createList

protected ListPeer createList(java.awt.List target)

Creates a peer object for the specified List.

Parameters:

Returns:

Throws:


createMenu

protected MenuPeer createMenu(java.awt.Menu target)

Creates a peer object for the specified Menu.

Parameters:

Returns:

Throws:


createMenuBar

protected MenuBarPeer createMenuBar(java.awt.MenuBar target)

Creates a peer object for the specified MenuBar.

Parameters:

Returns:

Throws:


createMenuItem

protected MenuItemPeer createMenuItem(java.awt.MenuItem target)

Creates a peer object for the specified MenuItem.

Parameters:

Returns:

Throws:


createPanel

protected PanelPeer createPanel(java.awt.Panel target)

Creates a peer object for the specified Panel.

Parameters:

Returns:


createPopupMenu

protected PopupMenuPeer createPopupMenu(java.awt.PopupMenu target)

Creates a peer object for the specified PopupMenu.

Parameters:

Returns:

Throws:


createScrollPane

protected ScrollPanePeer createScrollPane(java.awt.ScrollPane target)

Creates a peer object for the specified ScrollPane.

Parameters:

Returns:

Throws:


createScrollbar

protected ScrollbarPeer createScrollbar(java.awt.Scrollbar target)

Creates a peer object for the specified Scrollbar.

Parameters:

Returns:

Throws:


createTextArea

protected TextAreaPeer createTextArea(java.awt.TextArea target)

Creates a peer object for the specified TextArea.

Parameters:

Returns:

Throws:


createTextField

protected TextFieldPeer createTextField(java.awt.TextField target)

Creates a peer object for the specified TextField.

Parameters:

Returns:

Throws:


createWindow

protected WindowPeer createWindow(java.awt.Window target)

Creates a peer object for the specified Window.

Parameters:

Returns:

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:

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:

Throws:


getDesktopProperty

public final Object getDesktopProperty(java.lang.String propertyName)

Parameters:


getFontList

public String[] getFontList()

Returns the names of the available fonts.

Returns:


getFontMetrics

public FontMetrics getFontMetrics(java.awt.Font name)

Return the font metrics for the specified font

Parameters:

Returns:


getFontPeer

protected FontPeer getFontPeer(java.lang.String name, int style)

Creates a peer object for the specified font name.

Parameters:

Returns:


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:


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:


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:

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:


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:


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:

Throws:


getScreenSize

public Dimension getScreenSize()

Returns the dimensions of the screen in pixels.

Returns:

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:


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:


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.