|
Java Platform 1.2 Beta 4 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Toolkit
Toolkit
are used to bind the various components
to particular native toolkit implementations.
Most applications should not call any of the methods in this
class directly. The methods defined by Toolkit
are
the "glue" that joins the platform-independent classes in the
java.awt
package with their counterparts in
java.awt.peer
. Some methods defined by
Toolkit
query the native operating system directly.
Field Summary | |
protected Map | desktopProperties
|
protected PropertyChangeSupport | desktopPropsSupport
|
Constructor Summary | |
Toolkit()
|
Method Summary | |
void | addPropertyChangeListener(String name,
PropertyChangeListener pcl)
add the specified property change listener for the named desktop property |
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 java.awt.peer.ButtonPeer | createButton(Button target)
Creates this toolkit's implementation of Button using
the specified peer interface. |
protected abstract java.awt.peer.CanvasPeer | createCanvas(Canvas target)
Creates this toolkit's implementation of Canvas using
the specified peer interface. |
protected abstract java.awt.peer.CheckboxPeer | createCheckbox(Checkbox target)
Creates this toolkit's implementation of Checkbox using
the specified peer interface. |
protected abstract java.awt.peer.CheckboxMenuItemPeer | createCheckboxMenuItem(CheckboxMenuItem target)
Creates this toolkit's implementation of CheckboxMenuItem using
the specified peer interface. |
protected abstract java.awt.peer.ChoicePeer | createChoice(Choice target)
Creates this toolkit's implementation of Choice using
the specified peer interface. |
protected java.awt.peer.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 java.awt.peer.DialogPeer | createDialog(Dialog target)
Creates this toolkit's implementation of Dialog using
the specified peer interface. |
DragGestureRecognizer | createDragGestureRecognizer(Class abstractRecognizerClass,
DragSource ds,
Component c,
int srcActions,
DragGestureListener dgl)
create a concrete, platform dependent, subclass of the abstract DragGestureRecognizer class requested, and associate it with the DragSource, Component and DragGestureListener specified subclasses should override this to provide their own implementation |
abstract java.awt.dnd.peer.DragSourceContextPeer | createDragSourceContextPeer(DragGestureEvent dge)
create the peer for a DragSourceContext |
protected abstract java.awt.peer.FileDialogPeer | createFileDialog(FileDialog target)
Creates this toolkit's implementation of FileDialog using
the specified peer interface. |
protected abstract java.awt.peer.FramePeer | createFrame(Frame target)
Creates this toolkit's implementation of Frame using
the specified peer interface. |
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. |
Image | createImage(byte[] imagedata)
Creates an image which decodes the image stored in the specified byte array. |
abstract Image | createImage(ImageProducer producer)
Creates an image with the specified image producer. |
protected abstract java.awt.peer.LabelPeer | createLabel(Label target)
Creates this toolkit's implementation of Label using
the specified peer interface. |
protected abstract java.awt.peer.ListPeer | createList(List target)
Creates this toolkit's implementation of List using
the specified peer interface. |
protected abstract java.awt.peer.MenuPeer | createMenu(Menu target)
Creates this toolkit's implementation of Menu using
the specified peer interface. |
protected abstract java.awt.peer.MenuBarPeer | createMenuBar(MenuBar target)
Creates this toolkit's implementation of MenuBar using
the specified peer interface. |
protected abstract java.awt.peer.MenuItemPeer | createMenuItem(MenuItem target)
Creates this toolkit's implementation of MenuItem using
the specified peer interface. |
protected abstract java.awt.peer.PanelPeer | createPanel(Panel target)
Creates this toolkit's implementation of Panel using
the specified peer interface. |
protected abstract java.awt.peer.PopupMenuPeer | createPopupMenu(PopupMenu target)
Creates this toolkit's implementation of PopupMenu using
the specified peer interface. |
protected abstract java.awt.peer.ScrollbarPeer | createScrollbar(Scrollbar target)
Creates this toolkit's implementation of Scrollbar using
the specified peer interface. |
protected abstract java.awt.peer.ScrollPanePeer | createScrollPane(ScrollPane target)
Creates this toolkit's implementation of ScrollPane using
the specified peer interface. |
protected abstract java.awt.peer.TextAreaPeer | createTextArea(TextArea target)
Creates this toolkit's implementation of TextArea using
the specified peer interface. |
protected abstract java.awt.peer.TextFieldPeer | createTextField(TextField target)
Creates this toolkit's implementation of TextField using
the specified peer interface. |
protected abstract java.awt.peer.WindowPeer | createWindow(Window target)
Creates this toolkit's implementation of Window using
the specified peer interface. |
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)
obtain a value for the specified desktop property. |
abstract String[] | getFontList()
Deprecated. see java.awt.GraphicsEnvironment#getFontFamilyNames |
abstract FontMetrics | getFontMetrics(Font font)
Deprecated. This returns integer metrics for the default screen. |
protected abstract java.awt.peer.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. |
abstract Image | getImage(URL url)
Returns an image which gets pixel data from the specified URL. |
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 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). |
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. |
abstract int | getScreenResolution()
Returns the screen resolution in dots-per-inch. |
abstract Dimension | getScreenSize()
Gets the size of the screen. |
abstract Clipboard | getSystemClipboard()
Gets an instance of the system clipboard which interfaces with clipboard facilities provided by the native platform. |
EventQueue | getSystemEventQueue()
Get the application's or applet's EventQueue instance. |
protected abstract EventQueue | getSystemEventQueueImpl()
|
protected void | initializeDesktopProperties()
initializeDesktopProperties |
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 boolean | prepareImage(Image image,
int width,
int height,
ImageObserver observer)
Prepares an image for rendering. |
void | removePropertyChangeListener(String name,
PropertyChangeListener pcl)
remove the specified property change listener for the named desktop property |
protected void | setDesktopProperty(String name,
Object newValue)
set the named desktop property to the specified value and fire a property change event to notify any listeners that the value has changed |
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 desktopProperties
protected final PropertyChangeSupport desktopPropsSupport
Constructor Detail |
public Toolkit()
Method Detail |
protected abstract java.awt.peer.ButtonPeer createButton(Button target)
Button
using
the specified peer interface.
target
- the button to be implemented.Button
.Button
,
ButtonPeer
protected abstract java.awt.peer.TextFieldPeer createTextField(TextField target)
TextField
using
the specified peer interface.
target
- the text field to be implemented.TextField
.TextField
,
TextFieldPeer
protected abstract java.awt.peer.LabelPeer createLabel(Label target)
Label
using
the specified peer interface.
target
- the label to be implemented.Label
.Label
,
LabelPeer
protected abstract java.awt.peer.ListPeer createList(List target)
List
using
the specified peer interface.
target
- the list to be implemented.List
.List
,
ListPeer
protected abstract java.awt.peer.CheckboxPeer createCheckbox(Checkbox target)
Checkbox
using
the specified peer interface.
target
- the check box to be implemented.Checkbox
.Checkbox
,
CheckboxPeer
protected abstract java.awt.peer.ScrollbarPeer createScrollbar(Scrollbar target)
Scrollbar
using
the specified peer interface.
target
- the scroll bar to be implemented.Scrollbar
.Scrollbar
,
ScrollbarPeer
protected abstract java.awt.peer.ScrollPanePeer createScrollPane(ScrollPane target)
ScrollPane
using
the specified peer interface.
target
- the scroll pane to be implemented.ScrollPane
.ScrollPane
,
ScrollPanePeer
protected abstract java.awt.peer.TextAreaPeer createTextArea(TextArea target)
TextArea
using
the specified peer interface.
target
- the text area to be implemented.TextArea
.TextArea
,
TextAreaPeer
protected abstract java.awt.peer.ChoicePeer createChoice(Choice target)
Choice
using
the specified peer interface.
target
- the choice to be implemented.Choice
.Choice
,
ChoicePeer
protected abstract java.awt.peer.FramePeer createFrame(Frame target)
Frame
using
the specified peer interface.
target
- the frame to be implemented.Frame
.Frame
,
FramePeer
protected abstract java.awt.peer.CanvasPeer createCanvas(Canvas target)
Canvas
using
the specified peer interface.
target
- the canvas to be implemented.Canvas
.Canvas
,
CanvasPeer
protected abstract java.awt.peer.PanelPeer createPanel(Panel target)
Panel
using
the specified peer interface.
target
- the panel to be implemented.Panel
.Panel
,
PanelPeer
protected abstract java.awt.peer.WindowPeer createWindow(Window target)
Window
using
the specified peer interface.
target
- the window to be implemented.Window
.Window
,
WindowPeer
protected abstract java.awt.peer.DialogPeer createDialog(Dialog target)
Dialog
using
the specified peer interface.
target
- the dialog to be implemented.Dialog
.Dialog
,
DialogPeer
protected abstract java.awt.peer.MenuBarPeer createMenuBar(MenuBar target)
MenuBar
using
the specified peer interface.
target
- the menu bar to be implemented.MenuBar
.MenuBar
,
MenuBarPeer
protected abstract java.awt.peer.MenuPeer createMenu(Menu target)
Menu
using
the specified peer interface.
target
- the menu to be implemented.Menu
.Menu
,
MenuPeer
protected abstract java.awt.peer.PopupMenuPeer createPopupMenu(PopupMenu target)
PopupMenu
using
the specified peer interface.
target
- the popup menu to be implemented.PopupMenu
.PopupMenu
,
PopupMenuPeer
protected abstract java.awt.peer.MenuItemPeer createMenuItem(MenuItem target)
MenuItem
using
the specified peer interface.
target
- the menu item to be implemented.MenuItem
.MenuItem
,
MenuItemPeer
protected abstract java.awt.peer.FileDialogPeer createFileDialog(FileDialog target)
FileDialog
using
the specified peer interface.
target
- the file dialog to be implemented.FileDialog
.FileDialog
,
FileDialogPeer
protected abstract java.awt.peer.CheckboxMenuItemPeer createCheckboxMenuItem(CheckboxMenuItem target)
CheckboxMenuItem
using
the specified peer interface.
target
- the checkbox menu item to be implemented.CheckboxMenuItem
.CheckboxMenuItem
,
CheckboxMenuItemPeer
protected java.awt.peer.LightweightPeer createComponent(Component target)
target
- The Component to be created.protected abstract java.awt.peer.FontPeer getFontPeer(String name, int style)
Font
using
the specified peer interface.
target
- the font to be implemented.Font
.Font
,
FontPeer
,
GraphicsEnvironment.getAllFonts()
protected void loadSystemColors(int[] systemColors)
This method is called by the method updateSystemColors
in the SystemColor
class.
an
- integer array.java.awt.SystemColor#updateSystemColors
public abstract Dimension getScreenSize()
public abstract int getScreenResolution()
public abstract ColorModel getColorModel()
ColorModel
is an abstract class that
encapsulates the ability to translate between the
pixel values of an image and its red, green, blue,
and alpha components.
This toolkit method is called by the
getColorModel
method
of the Component
class.
ColorModel
,
Component.getColorModel()
public abstract String[] getFontList()
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.
java.awt.GraphicsEnvironment#getFontFamilyNames
public abstract FontMetrics getFontMetrics(Font font)
font
- a font.java.awt.Font#LineMetrics
,
java.awt.Font#retreiveLineMetrics
,
public abstract void sync()
This method ensures that the display is up-to-date. It is useful for animation.
public static Toolkit getDefaultToolkit()
If there is a system property named "awt.toolkit"
,
that property is treated as the name of a class that is a subclass
of Toolkit
.
If the system property does not exist, then the default toolkit
used is the class named "sun.awt.motif.MToolkit"
,
which is a motif implementation of the Abstract Window Toolkit.
Also loads additional classes into the VM using the property 'AWT.assistive_technologies' specified in the 'awt.properties' file. The form is "AWT.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.
public abstract Image getImage(String filename)
filename
- the name of a file containing pixel data
in a recognized file format.public abstract Image getImage(URL url)
url
- the URL to use in fetching the pixel data.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.PrintJob
object, or
null
if the user
cancelled the print job.PrintJob
public abstract void beep()
public abstract Clipboard getSystemClipboard()
This clipboard enables data transfer between Java programs and native applications which use native clipboard facilities.
Clipboard
public int getMenuShortcutKeyMask()
Menu shortcuts, which are embodied in the
MenuShortcut
class, are handled by the
MenuBar
class.
By default, this method returns Event.CTRL_MASK
.
Toolkit implementations should override this method if the
Control key isn't the correct key for accelerators.
Event
class
that is used for menu shortcuts on this toolkit.MenuBar
,
MenuShortcut
protected static Container getNativeContainer(Component c)
public Cursor createCustomCursor(Image cursor, Point hotSpot, String name) throws IndexOutOfBoundsException
image
- the image to display when the cursor is active.
hotSpot
- 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.public Dimension getBestCursorSize(int preferredWidth, int preferredHeight)
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.
desiredWidth
- the preferred cursor width the component would like
to use.
desiredHeight
- the preferred cursor height the component would like
to use.public int getMaximumCursorColors()
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.
public static String getProperty(String key, String defaultValue)
public final EventQueue getSystemEventQueue()
protected abstract EventQueue getSystemEventQueueImpl()
public abstract java.awt.dnd.peer.DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException
public DragGestureRecognizer createDragGestureRecognizer(Class abstractRecognizerClass, DragSource ds, Component c, int srcActions, DragGestureListener dgl)
abstractRecognizerClass
- The abstract class of the required recognizer
ds
- The DragSource
c
- The Component target for the DragGestureRecognizer
srcActions
- The actions permitted for the gesture
dgl
- The DragGestureListenerpublic 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)
public void removePropertyChangeListener(String name, PropertyChangeListener pcl)
|
Java Platform 1.2 Beta 4 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |