FileDocCategorySizeDatePackage
Toolkit.javaAPI DocJava SE 5 API93578Fri Aug 26 14:56:46 BST 2005java.awt

Toolkit

public abstract class Toolkit extends Object
This class is the abstract superclass of all actual implementations of the Abstract Window Toolkit. Subclasses of Toolkit are used to bind the various components to particular native toolkit implementations.

Many GUI operations may be performed asynchronously. This means that if you set the state of a component, and then immediately query the state, the returned value may not yet reflect the requested change. This includes, but is not limited to:

  • Scrolling to a specified position.
    For example, calling ScrollPane.setScrollPosition and then getScrollPosition may return an incorrect value if the original request has not yet been processed.

  • Moving the focus from one component to another.
    For more information, see Timing Focus Transfers, a section in The Swing Tutorial.

  • Making a top-level container visible.
    Calling setVisible(true) on a Window, Frame or Dialog may occur asynchronously.

  • Setting the size or location of a top-level container.
    Calls to 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 {@link java.awt.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.

version
1.203, 12/19/03
author
Sami Shaio
author
Arthur van Hoff
author
Fred Ecks
since
JDK1.0

Fields Summary
private static LightweightPeer
lightweightMarker
private static Toolkit
toolkit
The default toolkit.
private static String
atNames
Used internally by the assistive technologies functions; set at init time and used at load time
private static ResourceBundle
resources
Support for I18N: any visible strings should be stored in sun.awt.resources.awt.properties. The ResourceBundle is stored here, so that only one copy is maintained.
private static boolean
loaded
WARNING: This is a temporary workaround for a problem in the way the AWT loads native libraries. A number of classes in the AWT package have a native method, initIDs(), which initializes the JNI field and method ids used in the native portion of their implementation. Since the use and storage of these ids is done by the implementation libraries, the implementation of these method is provided by the particular AWT implementations (for example, "Toolkit"s/Peer), such as Motif, Microsoft Windows, or Tiny. The problem is that this means that the native libraries must be loaded by the java.* classes, which do not necessarily know the names of the libraries to load. A better way of doing this would be to provide a separate library which defines java.awt.* initIDs, and exports the relevant symbols out to the implementation libraries. For now, we know it's done by the implementation, and we assume that the name of the library is "awt". -br. If you change loadLibraries(), please add the change to java.awt.image.ColorModel.loadLibraries(). Unfortunately, classes can be loaded in java.awt.image that depend on libawt and there is no way to call Toolkit.loadLibraries() directly. -hung
protected final Map
desktopProperties
protected final PropertyChangeSupport
desktopPropsSupport
private static final sun.awt.DebugHelper
dbg
private static final int
LONG_BITS
private int[]
calls
private static volatile long
enabledOnToolkitMask
private AWTEventListener
eventListener
private WeakHashMap
listener2SelectiveListener
Constructors Summary
Methods Summary
public voidaddAWTEventListener(java.awt.event.AWTEventListener listener, long eventMask)
Adds an AWTEventListener to receive all AWTEvents dispatched system-wide that conform to the given eventMask.

First, if there is a security manager, its checkPermission method is called with an AWTPermission("listenToAllAWTEvents") permission. This may result in a SecurityException.

eventMask is a bitmask of event types to receive. It is constructed by bitwise OR-ing together the event masks defined in AWTEvent.

Note: event listener use is not recommended for normal application use, but are intended solely to support special purpose facilities including support for accessibility, event record/playback, and diagnostic tracing. If listener is null, no exception is thrown and no action is performed.

param
listener the event listener.
param
eventMask the bitmask of event types to receive
throws
SecurityException if a security manager exists and its checkPermission method doesn't allow the operation.
see
#removeAWTEventListener
see
#getAWTEventListeners
see
SecurityManager#checkPermission
see
java.awt.AWTEvent
see
java.awt.AWTPermission
see
java.awt.event.AWTEventListener
see
java.awt.event.AWTEventListenerProxy
since
1.2

        AWTEventListener localL = deProxyAWTEventListener(listener); 

        if (localL == null) {
            return;
        }
        SecurityManager security = System.getSecurityManager();
        if (security != null) {
          security.checkPermission(SecurityConstants.ALL_AWT_EVENTS_PERMISSION);
        }
        synchronized (this) {
            SelectiveAWTEventListener selectiveListener =
            (SelectiveAWTEventListener)listener2SelectiveListener.get(localL);

            if (selectiveListener == null) {
                // Create a new selectiveListener.
                selectiveListener = new SelectiveAWTEventListener(localL,
                                                                 eventMask); 
                listener2SelectiveListener.put(localL, selectiveListener);
                eventListener = ToolkitEventMulticaster.add(eventListener,
                                                            selectiveListener);
            }
            // OR the eventMask into the selectiveListener's event mask.
            selectiveListener.orEventMasks(eventMask);
            
            enabledOnToolkitMask |= eventMask;
            
            long mask = eventMask;
            for (int i=0; i<LONG_BITS; i++) {
                // If no bits are set, break out of loop.
                if (mask == 0) {
                    break;
                }
                if ((mask & 1L) != 0) {  // Always test bit 0.
                    calls[i]++;
                }
                mask >>>= 1;  // Right shift, fill with zeros on left.
            }
        }
    
public synchronized voidaddPropertyChangeListener(java.lang.String name, java.beans.PropertyChangeListener pcl)
Adds the specified property change listener for the named desktop property. If pcl is null, no exception is thrown and no action is performed.

param
name The name of the property to listen for
param
pcl The property change listener
since
1.2

	if (pcl == null) {
	    return;
	}
	desktopPropsSupport.addPropertyChangeListener(name, pcl);
    
public abstract voidbeep()
Emits an audio beep.

since
JDK1.1

public abstract intcheckImage(java.awt.Image image, int width, int height, java.awt.image.ImageObserver observer)
Indicates the construction status of a specified image that is being prepared for display.

If the values of the width and height arguments are both -1, this method returns the construction status of a screen representation of the specified image in this toolkit. Otherwise, this method returns the construction status of a scaled representation of the image at the specified width and height.

This method does not cause the image to begin loading. An application must call prepareImage to force the loading of an image.

This method is called by the component's checkImage methods.

Information on the flags returned by this method can be found with the definition of the ImageObserver interface.

param
image the image whose status is being checked.
param
width the width of the scaled version whose status is being checked, or -1.
param
height the height of the scaled version whose status is being checked, or -1.
param
observer the ImageObserver object to be notified as the image is being prepared.
return
the bitwise inclusive OR of the ImageObserver flags for the image data that is currently available.
see
java.awt.Toolkit#prepareImage(java.awt.Image, int, int, java.awt.image.ImageObserver)
see
java.awt.Component#checkImage(java.awt.Image, java.awt.image.ImageObserver)
see
java.awt.Component#checkImage(java.awt.Image, int, int, java.awt.image.ImageObserver)
see
java.awt.image.ImageObserver

synchronized intcountAWTEventListeners(long eventMask)

        if (dbg.on) {
            dbg.assertion(eventMask != 0);
        }

        int ci = 0;
        for (; eventMask != 0; eventMask >>>= 1, ci++) {
        }
        ci--;
        return calls[ci];
    
protected abstract java.awt.peer.ButtonPeercreateButton(java.awt.Button target)
Creates this toolkit's implementation of Button using the specified peer interface.

param
target the button to be implemented.
return
this toolkit's implementation of Button.
exception
HeadlessException if GraphicsEnvironment.isHeadless() returns true
see
java.awt.GraphicsEnvironment#isHeadless
see
java.awt.Button
see
java.awt.peer.ButtonPeer

protected abstract java.awt.peer.CanvasPeercreateCanvas(java.awt.Canvas target)
Creates this toolkit's implementation of Canvas using the specified peer interface.

param
target the canvas to be implemented.
return
this toolkit's implementation of Canvas.
see
java.awt.Canvas
see
java.awt.peer.CanvasPeer

protected abstract java.awt.peer.CheckboxPeercreateCheckbox(java.awt.Checkbox target)
Creates this toolkit's implementation of Checkbox using the specified peer interface.

param
target the check box to be implemented.
return
this toolkit's implementation of Checkbox.
exception
HeadlessException if GraphicsEnvironment.isHeadless() returns true
see
java.awt.GraphicsEnvironment#isHeadless
see
java.awt.Checkbox
see
java.awt.peer.CheckboxPeer

protected abstract java.awt.peer.CheckboxMenuItemPeercreateCheckboxMenuItem(java.awt.CheckboxMenuItem target)
Creates this toolkit's implementation of CheckboxMenuItem using the specified peer interface.

param
target the checkbox menu item to be implemented.
return
this toolkit's implementation of CheckboxMenuItem.
exception
HeadlessException if GraphicsEnvironment.isHeadless() returns true
see
java.awt.GraphicsEnvironment#isHeadless
see
java.awt.CheckboxMenuItem
see
java.awt.peer.CheckboxMenuItemPeer

protected abstract java.awt.peer.ChoicePeercreateChoice(java.awt.Choice target)
Creates this toolkit's implementation of Choice using the specified peer interface.

param
target the choice to be implemented.
return
this toolkit's implementation of Choice.
exception
HeadlessException if GraphicsEnvironment.isHeadless() returns true
see
java.awt.GraphicsEnvironment#isHeadless
see
java.awt.Choice
see
java.awt.peer.ChoicePeer

protected java.awt.peer.LightweightPeercreateComponent(java.awt.Component target)
Creates a peer for a component or container. This peer is windowless and allows the Component and Container classes to be extended directly to create windowless components that are defined entirely in java.

param
target The Component to be created.

        if (lightweightMarker == null) {
            lightweightMarker = new NullComponentPeer();
        }
        return lightweightMarker;
    
public java.awt.CursorcreateCustomCursor(java.awt.Image cursor, java.awt.Point hotSpot, java.lang.String name)
Creates a new custom cursor object. If the image to display is invalid, the cursor will be hidden (made completely transparent), and the hotspot will be set to (0, 0).

Note that multi-frame images are invalid and may cause this method to hang.

param
cursor the image to display when the cursor is actived
param
hotSpot the X and Y of the large cursor's hot spot; the hotSpot values must be less than the Dimension returned by getBestCursorSize
param
name a localized description of the cursor, for Java Accessibility use
exception
IndexOutOfBoundsException if the hotSpot values are outside the bounds of the cursor
exception
HeadlessException if GraphicsEnvironment.isHeadless() returns true
see
java.awt.GraphicsEnvironment#isHeadless
since
1.2

        // Override to implement custom cursor support.
        if (this != Toolkit.getDefaultToolkit()) {
	    return Toolkit.getDefaultToolkit().
	        createCustomCursor(cursor, hotSpot, name);
	} else {
	    return new Cursor(Cursor.DEFAULT_CURSOR);
	}
    
protected abstract java.awt.peer.DialogPeercreateDialog(java.awt.Dialog target)
Creates this toolkit's implementation of Dialog using the specified peer interface.

param
target the dialog to be implemented.
return
this toolkit's implementation of Dialog.
exception
HeadlessException if GraphicsEnvironment.isHeadless() returns true
see
java.awt.GraphicsEnvironment#isHeadless
see
java.awt.Dialog
see
java.awt.peer.DialogPeer

public TcreateDragGestureRecognizer(java.lang.Class abstractRecognizerClass, java.awt.dnd.DragSource ds, java.awt.Component c, int srcActions, java.awt.dnd.DragGestureListener dgl)
Creates a concrete, platform dependent, subclass of the abstract DragGestureRecognizer class requested, and associates it with the DragSource, Component and DragGestureListener specified. subclasses should override this to provide their own implementation

param
abstractRecognizerClass The abstract class of the required recognizer
param
ds The DragSource
param
c The Component target for the DragGestureRecognizer
param
srcActions The actions permitted for the gesture
param
dgl The DragGestureListener
return
the new object or null. Always returns null if GraphicsEnvironment.isHeadless() returns true.
see
java.awt.GraphicsEnvironment#isHeadless

	return null;
    
public abstract java.awt.dnd.peer.DragSourceContextPeercreateDragSourceContextPeer(java.awt.dnd.DragGestureEvent dge)
Creates the peer for a DragSourceContext. Always throws InvalidDndOperationException if GraphicsEnvironment.isHeadless() returns true.

see
java.awt.GraphicsEnvironment#isHeadless

protected abstract java.awt.peer.FileDialogPeercreateFileDialog(java.awt.FileDialog target)
Creates this toolkit's implementation of FileDialog using the specified peer interface.

param
target the file dialog to be implemented.
return
this toolkit's implementation of FileDialog.
exception
HeadlessException if GraphicsEnvironment.isHeadless() returns true
see
java.awt.GraphicsEnvironment#isHeadless
see
java.awt.FileDialog
see
java.awt.peer.FileDialogPeer

protected abstract java.awt.peer.FramePeercreateFrame(java.awt.Frame target)
Creates this toolkit's implementation of Frame using the specified peer interface.

param
target the frame to be implemented.
return
this toolkit's implementation of Frame.
exception
HeadlessException if GraphicsEnvironment.isHeadless() returns true
see
java.awt.GraphicsEnvironment#isHeadless
see
java.awt.Frame
see
java.awt.peer.FramePeer

public abstract java.awt.ImagecreateImage(java.lang.String filename)
Returns an image which gets pixel data from the specified file. The returned Image is a new object which will not be shared with any other caller of this method or its getImage variant.

param
filename the name of a file containing pixel data in a recognized file format.
return
an image which gets its pixel data from the specified file.
see
#getImage(java.lang.String)

public abstract java.awt.ImagecreateImage(java.net.URL url)
Returns an image which gets pixel data from the specified URL. The returned Image is a new object which will not be shared with any other caller of this method or its getImage variant.

param
url the URL to use in fetching the pixel data.
return
an image which gets its pixel data from the specified URL.
see
#getImage(java.net.URL)

public abstract java.awt.ImagecreateImage(java.awt.image.ImageProducer producer)
Creates an image with the specified image producer.

param
producer the image producer to be used.
return
an image with the specified image producer.
see
java.awt.Image
see
java.awt.image.ImageProducer
see
java.awt.Component#createImage(java.awt.image.ImageProducer)

public java.awt.ImagecreateImage(byte[] imagedata)
Creates an image which decodes the image stored in the specified byte array.

The data must be in some image format, such as GIF or JPEG, that is supported by this toolkit.

param
imagedata an array of bytes, representing image data in a supported image format.
return
an image.
since
JDK1.1

	return createImage(imagedata, 0, imagedata.length);
    
public abstract java.awt.ImagecreateImage(byte[] imagedata, int imageoffset, int imagelength)
Creates an image which decodes the image stored in the specified byte array, and at the specified offset and length. The data must be in some image format, such as GIF or JPEG, that is supported by this toolkit.

param
imagedata an array of bytes, representing image data in a supported image format.
param
imageoffset the offset of the beginning of the data in the array.
param
imagelength the length of the data in the array.
return
an image.
since
JDK1.1

protected abstract java.awt.peer.LabelPeercreateLabel(java.awt.Label target)
Creates this toolkit's implementation of Label using the specified peer interface.

param
target the label to be implemented.
return
this toolkit's implementation of Label.
exception
HeadlessException if GraphicsEnvironment.isHeadless() returns true
see
java.awt.GraphicsEnvironment#isHeadless
see
java.awt.Label
see
java.awt.peer.LabelPeer

protected abstract java.awt.peer.ListPeercreateList(java.awt.List target)
Creates this toolkit's implementation of List using the specified peer interface.

param
target the list to be implemented.
return
this toolkit's implementation of List.
exception
HeadlessException if GraphicsEnvironment.isHeadless() returns true
see
java.awt.GraphicsEnvironment#isHeadless
see
java.awt.List
see
java.awt.peer.ListPeer

protected abstract java.awt.peer.MenuPeercreateMenu(java.awt.Menu target)
Creates this toolkit's implementation of Menu using the specified peer interface.

param
target the menu to be implemented.
return
this toolkit's implementation of Menu.
exception
HeadlessException if GraphicsEnvironment.isHeadless() returns true
see
java.awt.GraphicsEnvironment#isHeadless
see
java.awt.Menu
see
java.awt.peer.MenuPeer

protected abstract java.awt.peer.MenuBarPeercreateMenuBar(java.awt.MenuBar target)
Creates this toolkit's implementation of MenuBar using the specified peer interface.

param
target the menu bar to be implemented.
return
this toolkit's implementation of MenuBar.
exception
HeadlessException if GraphicsEnvironment.isHeadless() returns true
see
java.awt.GraphicsEnvironment#isHeadless
see
java.awt.MenuBar
see
java.awt.peer.MenuBarPeer

protected abstract java.awt.peer.MenuItemPeercreateMenuItem(java.awt.MenuItem target)
Creates this toolkit's implementation of MenuItem using the specified peer interface.

param
target the menu item to be implemented.
return
this toolkit's implementation of MenuItem.
exception
HeadlessException if GraphicsEnvironment.isHeadless() returns true
see
java.awt.GraphicsEnvironment#isHeadless
see
java.awt.MenuItem
see
java.awt.peer.MenuItemPeer

protected abstract java.awt.peer.PanelPeercreatePanel(java.awt.Panel target)
Creates this toolkit's implementation of Panel using the specified peer interface.

param
target the panel to be implemented.
return
this toolkit's implementation of Panel.
see
java.awt.Panel
see
java.awt.peer.PanelPeer

protected abstract java.awt.peer.PopupMenuPeercreatePopupMenu(java.awt.PopupMenu target)
Creates this toolkit's implementation of PopupMenu using the specified peer interface.

param
target the popup menu to be implemented.
return
this toolkit's implementation of PopupMenu.
exception
HeadlessException if GraphicsEnvironment.isHeadless() returns true
see
java.awt.GraphicsEnvironment#isHeadless
see
java.awt.PopupMenu
see
java.awt.peer.PopupMenuPeer
since
JDK1.1

protected abstract java.awt.peer.ScrollPanePeercreateScrollPane(java.awt.ScrollPane target)
Creates this toolkit's implementation of ScrollPane using the specified peer interface.

param
target the scroll pane to be implemented.
return
this toolkit's implementation of ScrollPane.
exception
HeadlessException if GraphicsEnvironment.isHeadless() returns true
see
java.awt.GraphicsEnvironment#isHeadless
see
java.awt.ScrollPane
see
java.awt.peer.ScrollPanePeer
since
JDK1.1

protected abstract java.awt.peer.ScrollbarPeercreateScrollbar(java.awt.Scrollbar target)
Creates this toolkit's implementation of Scrollbar using the specified peer interface.

param
target the scroll bar to be implemented.
return
this toolkit's implementation of Scrollbar.
exception
HeadlessException if GraphicsEnvironment.isHeadless() returns true
see
java.awt.GraphicsEnvironment#isHeadless
see
java.awt.Scrollbar
see
java.awt.peer.ScrollbarPeer

protected abstract java.awt.peer.TextAreaPeercreateTextArea(java.awt.TextArea target)
Creates this toolkit's implementation of TextArea using the specified peer interface.

param
target the text area to be implemented.
return
this toolkit's implementation of TextArea.
exception
HeadlessException if GraphicsEnvironment.isHeadless() returns true
see
java.awt.GraphicsEnvironment#isHeadless
see
java.awt.TextArea
see
java.awt.peer.TextAreaPeer

protected abstract java.awt.peer.TextFieldPeercreateTextField(java.awt.TextField target)
Creates this toolkit's implementation of TextField using the specified peer interface.

param
target the text field to be implemented.
return
this toolkit's implementation of TextField.
exception
HeadlessException if GraphicsEnvironment.isHeadless() returns true
see
java.awt.GraphicsEnvironment#isHeadless
see
java.awt.TextField
see
java.awt.peer.TextFieldPeer

protected abstract java.awt.peer.WindowPeercreateWindow(java.awt.Window target)
Creates this toolkit's implementation of Window using the specified peer interface.

param
target the window to be implemented.
return
this toolkit's implementation of Window.
exception
HeadlessException if GraphicsEnvironment.isHeadless() returns true
see
java.awt.GraphicsEnvironment#isHeadless
see
java.awt.Window
see
java.awt.peer.WindowPeer

private static java.awt.event.AWTEventListenerdeProxyAWTEventListener(java.awt.event.AWTEventListener l)


    /*
     * Extracts a "pure" AWTEventListener from a AWTEventListenerProxy,
     * if the listener is proxied.
     */
         
    
        AWTEventListener localL = l;

        if (localL == null) {
            return null;
        }
        // if user passed in a AWTEventListenerProxy object, extract
        // the listener
        if (l instanceof AWTEventListenerProxy) {
            localL = (AWTEventListener)((AWTEventListenerProxy)l).getListener();
        }
        return localL;
    
static booleanenabledOnToolkit(long eventMask)

        return (enabledOnToolkitMask & eventMask) != 0;
        
public java.awt.event.AWTEventListener[]getAWTEventListeners()
Returns an array of all the AWTEventListeners registered on this toolkit. 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.

return
all of the AWTEventListeners or an empty array if no listeners are currently registered
throws
SecurityException if a security manager exists and its checkPermission method doesn't allow the operation.
see
#addAWTEventListener
see
#removeAWTEventListener
see
SecurityManager#checkPermission
see
java.awt.AWTEvent
see
java.awt.AWTPermission
see
java.awt.event.AWTEventListener
see
java.awt.event.AWTEventListenerProxy
since
1.4

        SecurityManager security = System.getSecurityManager();
        if (security != null) {
	    security.checkPermission(SecurityConstants.ALL_AWT_EVENTS_PERMISSION);
        }
        synchronized (this) {
            EventListener[] la = ToolkitEventMulticaster.getListeners(eventListener,AWTEventListener.class); 

            AWTEventListener[] ret = new AWTEventListener[la.length];
            for (int i = 0; i < la.length; i++) { 
                SelectiveAWTEventListener sael = (SelectiveAWTEventListener)la[i]; 
                AWTEventListener tempL = sael.getListener(); 
                //assert tempL is not an AWTEventListenerProxy - we should 
                // have weeded them all out 
                // don't want to wrap a proxy inside a proxy 
                ret[i] = new AWTEventListenerProxy(sael.getEventMask(), tempL); 
            } 
            return ret; 
        }
    
public java.awt.event.AWTEventListener[]getAWTEventListeners(long eventMask)
Returns an array of all the AWTEventListeners registered on this toolkit which listen to all of the event types indicates in the eventMask argument. 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.

param
eventMask the bitmask of event types to listen for
return
all of the AWTEventListeners registered on this toolkit for the specified event types, or an empty array if no such listeners are currently registered
throws
SecurityException if a security manager exists and its checkPermission method doesn't allow the operation.
see
#addAWTEventListener
see
#removeAWTEventListener
see
SecurityManager#checkPermission
see
java.awt.AWTEvent
see
java.awt.AWTPermission
see
java.awt.event.AWTEventListener
see
java.awt.event.AWTEventListenerProxy
since
1.4

        SecurityManager security = System.getSecurityManager();
        if (security != null) {
	    security.checkPermission(SecurityConstants.ALL_AWT_EVENTS_PERMISSION);
        }
        synchronized (this) {
            EventListener[] la = ToolkitEventMulticaster.getListeners(eventListener,AWTEventListener.class);

            java.util.List list = new ArrayList(la.length);

            for (int i = 0; i < la.length; i++) {
                SelectiveAWTEventListener sael = (SelectiveAWTEventListener)la[i];
                if ((sael.getEventMask() & eventMask) == eventMask) {
                    //AWTEventListener tempL = sael.getListener();
                    list.add(new AWTEventListenerProxy(sael.getEventMask(),
                                                       sael.getListener()));
                }
            }
            return (AWTEventListener[])list.toArray(new AWTEventListener[0]);
        }
    
public java.awt.DimensiongetBestCursorSize(int preferredWidth, int preferredHeight)
Returns the supported cursor dimension which is closest to the desired sizes. Systems which only support a single cursor size will return that size regardless of the desired sizes. Systems which don't support custom cursors will return a dimension of 0, 0.

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.

param
preferredWidth the preferred cursor width the component would like to use.
param
preferredHeight the preferred cursor height the component would like to use.
return
the closest matching supported cursor size, or a dimension of 0,0 if the Toolkit implementation doesn't support custom cursors.
exception
HeadlessException if GraphicsEnvironment.isHeadless() returns true
see
java.awt.GraphicsEnvironment#isHeadless
since
1.2

        // Override to implement custom cursor support.
        if (this != Toolkit.getDefaultToolkit()) {
	    return Toolkit.getDefaultToolkit().
	        getBestCursorSize(preferredWidth, preferredHeight);
	} else {
	    return new Dimension(0, 0);
	}
    
public abstract java.awt.image.ColorModelgetColorModel()
Determines the color model of this toolkit's screen.

ColorModel is an abstract class that encapsulates the ability to translate between the pixel values of an image and its red, green, blue, and alpha components.

This toolkit method is called by the getColorModel method of the Component class.

return
the color model of this toolkit's screen.
exception
HeadlessException if GraphicsEnvironment.isHeadless() returns true
see
java.awt.GraphicsEnvironment#isHeadless
see
java.awt.image.ColorModel
see
java.awt.Component#getColorModel

public static synchronized java.awt.ToolkitgetDefaultToolkit()
Gets the default toolkit.

If there is a system property named "awt.toolkit", that property is treated as the name of a class that is a subclass of Toolkit.

If the system property does not exist, then the default toolkit used is 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 '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.

return
the default toolkit.
exception
AWTError if a toolkit could not be found, or if one could not be accessed or instantiated.

	if (toolkit == null) {
	    try {
		// We disable the JIT during toolkit initialization.  This
		// tends to touch lots of classes that aren't needed again
		// later and therefore JITing is counter-productiive.
		java.lang.Compiler.disable();
		
	        java.security.AccessController.doPrivileged(
			new java.security.PrivilegedAction() {
		    public Object run() {
		        String nm = null;
			Class cls = null;
		        try {
                            String defaultToolkit;

                            if (System.getProperty("os.name").equals("Linux")) { 
                                defaultToolkit = "sun.awt.X11.XToolkit";
                            }
                            else { 
                                defaultToolkit = "sun.awt.motif.MToolkit";
                            }
			    nm = System.getProperty("awt.toolkit",
						defaultToolkit);
			    try {
			    	cls = Class.forName(nm);
		            } catch (ClassNotFoundException e) {
			    	ClassLoader cl = ClassLoader.getSystemClassLoader();
                                if (cl != null) {
			    	    try {
                                        cls = cl.loadClass(nm);
		            	    } catch (ClassNotFoundException ee) {
			    		throw new AWTError("Toolkit not found: " + nm);
				    }
                                }
	                    }
                            if (cls != null) {
				toolkit = (Toolkit)cls.newInstance();
                                if (GraphicsEnvironment.isHeadless()) {
                                    toolkit = new HeadlessToolkit(toolkit);
                                }
			    }
		        } catch (InstantiationException e) {
			    throw new AWTError("Could not instantiate Toolkit: " +
					   nm);
		        } catch (IllegalAccessException e) {
			    throw new AWTError("Could not access Toolkit: " + nm);
		        }
		        return null;
		    }
	        });
	        loadAssistiveTechnologies();
	    } finally {
		// Make sure to always re-enable the JIT.
		java.lang.Compiler.enable();
	    }
	}
	return toolkit;
    
public final synchronized java.lang.ObjectgetDesktopProperty(java.lang.String propertyName)
Obtains a value for the specified desktop property. A desktop property is a uniquely named value for a resource that is Toolkit global in nature. Usually it also is an abstract representation for an underlying platform dependent desktop setting.

        // This is a workaround for headless toolkits.  It would be
        // better to override this method but it is declared final.
        // "this instanceof" syntax defeats polymorphism.
        // --mm, 03/03/00
        if (this instanceof HeadlessToolkit) {
            return ((HeadlessToolkit)this).getUnderlyingToolkit()
                .getDesktopProperty(propertyName);
        }

	if (desktopProperties.isEmpty()) {
	    initializeDesktopProperties();
	}

        Object value;

        // This property should never be cached
        if (propertyName.equals("awt.dynamicLayoutSupported")) {
            value = lazilyLoadDesktopProperty(propertyName);
            return value;
        }

	value = desktopProperties.get(propertyName);

	if (value == null) {
	    value = lazilyLoadDesktopProperty(propertyName);

	    if (value != null) {
		setDesktopProperty(propertyName, value);
	    }
	}

	return value;
    
static java.awt.EventQueuegetEventQueue()

        return getDefaultToolkit().getSystemEventQueueImpl();
    
public abstract java.lang.String[]getFontList()
Returns the names of the available fonts in this toolkit.

For 1.1, the following font names are deprecated (the replacement name follows):

  • TimesRoman (use Serif)
  • Helvetica (use SansSerif)
  • Courier (use Monospaced)

The ZapfDingbats 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.

return
the names of the available fonts in this toolkit.
deprecated
see {@link java.awt.GraphicsEnvironment#getAvailableFontFamilyNames()}
see
java.awt.GraphicsEnvironment#getAvailableFontFamilyNames()

public abstract java.awt.FontMetricsgetFontMetrics(java.awt.Font font)
Gets the screen device metrics for rendering of the font.

param
font a font
return
the screen metrics of the specified font in this toolkit
deprecated
As of JDK version 1.2, replaced by the Font method getLineMetrics.
see
java.awt.font.LineMetrics
see
java.awt.Font#getLineMetrics
see
java.awt.GraphicsEnvironment#getScreenDevices

protected abstract java.awt.peer.FontPeergetFontPeer(java.lang.String name, int style)
Creates this toolkit's implementation of Font using the specified peer interface.

param
name the font to be implemented
param
style the style of the font, such as PLAIN, BOLD, ITALIC, or a combination
return
this toolkit's implementation of Font
see
java.awt.Font
see
java.awt.peer.FontPeer
see
java.awt.GraphicsEnvironment#getAllFonts
deprecated
see java.awt.GraphicsEnvironment#getAllFonts

public abstract java.awt.ImagegetImage(java.lang.String filename)
Returns an image which gets pixel data from the specified file, whose format can be either GIF, JPEG or PNG. The underlying toolkit attempts to resolve multiple requests with the same filename to the same returned Image. Since the mechanism required to facilitate this sharing of Image objects may continue to hold onto images that are no longer of use for an indefinite period of time, developers are encouraged to implement their own caching of images by using the createImage variant wherever available.

param
filename the name of a file containing pixel data in a recognized file format.
return
an image which gets its pixel data from the specified file.
see
#createImage(java.lang.String)

public abstract java.awt.ImagegetImage(java.net.URL url)
Returns an image which gets pixel data from the specified URL. The pixel data referenced by the specified URL must be in one of the following formats: GIF, JPEG or PNG. The underlying toolkit attempts to resolve multiple requests with the same URL to the same returned Image. Since the mechanism required to facilitate this sharing of Image objects may continue to hold onto images that are no longer of use for an indefinite period of time, developers are encouraged to implement their own caching of images by using the createImage variant wherever available.

param
url the URL to use in fetching the pixel data.
return
an image which gets its pixel data from the specified URL.
see
#createImage(java.net.URL)

public booleangetLockingKeyState(int keyCode)
Returns whether the given locking key on the keyboard is currently in its "on" state. Valid key codes are {@link java.awt.event.KeyEvent#VK_CAPS_LOCK VK_CAPS_LOCK}, {@link java.awt.event.KeyEvent#VK_NUM_LOCK VK_NUM_LOCK}, {@link java.awt.event.KeyEvent#VK_SCROLL_LOCK VK_SCROLL_LOCK}, and {@link java.awt.event.KeyEvent#VK_KANA_LOCK VK_KANA_LOCK}.

exception
java.lang.IllegalArgumentException if keyCode is not one of the valid key codes
exception
java.lang.UnsupportedOperationException if the host system doesn't allow getting the state of this key programmatically, or if the keyboard doesn't have this key
exception
HeadlessException if GraphicsEnvironment.isHeadless() returns true
see
java.awt.GraphicsEnvironment#isHeadless
since
1.3

        if (! (keyCode == KeyEvent.VK_CAPS_LOCK || keyCode == KeyEvent.VK_NUM_LOCK ||
               keyCode == KeyEvent.VK_SCROLL_LOCK || keyCode == KeyEvent.VK_KANA_LOCK)) {
            throw new IllegalArgumentException("invalid key for Toolkit.getLockingKeyState");
        }
        throw new UnsupportedOperationException("Toolkit.getLockingKeyState");
    
public intgetMaximumCursorColors()
Returns the maximum number of colors the Toolkit supports in a custom cursor palette.

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.

return
the maximum number of colors, or zero if custom cursors are not supported by this Toolkit implementation.
exception
HeadlessException if GraphicsEnvironment.isHeadless() returns true
see
java.awt.GraphicsEnvironment#isHeadless
since
1.2

        // Override to implement custom cursor support.
        if (this != Toolkit.getDefaultToolkit()) {
	    return Toolkit.getDefaultToolkit().getMaximumCursorColors();
	} else {
	    return 0;
	}
    
public intgetMenuShortcutKeyMask()
Determines which modifier key is the appropriate accelerator key for menu shortcuts.

Menu shortcuts, which are embodied in the MenuShortcut class, are handled by the MenuBar class.

By default, this method returns Event.CTRL_MASK. Toolkit implementations should override this method if the Control key isn't the correct key for accelerators.

return
the modifier mask on the Event class that is used for menu shortcuts on this toolkit.
exception
HeadlessException if GraphicsEnvironment.isHeadless() returns true
see
java.awt.GraphicsEnvironment#isHeadless
see
java.awt.MenuBar
see
java.awt.MenuShortcut
since
JDK1.1

        return Event.CTRL_MASK;
    
protected java.awt.peer.MouseInfoPeergetMouseInfoPeer()
Obtains this toolkit's implementation of helper class for MouseInfo operations.

return
this toolkit's implementation of helper for MouseInfo
throws
UnsupportedOperationException if this operation is not implemented
see
java.awt.peer.MouseInfoPeer
see
java.awt.MouseInfo

        throw new UnsupportedOperationException("Not implemented");
    
protected static java.awt.ContainergetNativeContainer(java.awt.Component c)
Give native peers the ability to query the native container given a native component (eg the direct parent may be lightweight).

	return c.getNativeContainer();
    
public abstract java.awt.PrintJobgetPrintJob(java.awt.Frame frame, java.lang.String jobtitle, java.util.Properties props)
Gets a 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.

param
frame the parent of the print dialog. May not be null.
param
jobtitle the title of the PrintJob. A null title is equivalent to "".
param
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.
return
a PrintJob object, or null if the user cancelled the print job.
throws
NullPointerException if frame is null. This exception is always thrown when GraphicsEnvironment.isHeadless() returns true.
throws
SecurityException if this thread is not allowed to initiate a print job request
see
java.awt.GraphicsEnvironment#isHeadless
see
java.awt.PrintJob
see
java.lang.RuntimePermission
since
JDK1.1

public java.awt.PrintJobgetPrintJob(java.awt.Frame frame, java.lang.String jobtitle, java.awt.JobAttributes jobAttributes, java.awt.PageAttributes pageAttributes)
Gets a 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.

param
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.
param
jobtitle the title of the PrintJob. A null title is equivalent to "".
param
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.
param
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.
return
a PrintJob object, or null if the user cancelled the print job.
throws
NullPointerException if frame is null and either jobAttributes is null or jobAttributes.getDialog() returns JobAttributes.DialogType.NATIVE.
throws
IllegalArgumentException if pageAttributes specifies differing cross feed and feed resolutions. This exception is always thrown when GraphicsEnvironment.isHeadless() returns true.
throws
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 system
see
java.awt.PrintJob
see
java.awt.GraphicsEnvironment#isHeadless
see
java.lang.RuntimePermission
see
java.awt.JobAttributes
see
java.awt.PageAttributes
since
1.3

        // Override to add printing support with new job/page control classes

        if (GraphicsEnvironment.isHeadless()) {
            throw new IllegalArgumentException();
        }

	if (this != Toolkit.getDefaultToolkit()) {
	    return Toolkit.getDefaultToolkit().getPrintJob(frame, jobtitle,
							   jobAttributes,
							   pageAttributes);
	} else {
	    return getPrintJob(frame, jobtitle, null);
	}
    
public static java.lang.StringgetProperty(java.lang.String key, java.lang.String defaultValue)
Gets a property with the specified key and default. This method returns defaultValue if the property is not found.

	java.security.AccessController.doPrivileged(
				 new java.security.PrivilegedAction() {
	    public Object run() {
		try {
		    resources =
			ResourceBundle.getBundle("sun.awt.resources.awt");
		} catch (MissingResourceException e) {
		    // No resource file; defaults will be used.
		}
		return null;
	    }
	});

	// ensure that the proper libraries are loaded
        loadLibraries();
	initAssistiveTechnologies();
        if (!GraphicsEnvironment.isHeadless()) {
            initIDs();
        }
    
        if (resources != null) {
	    try {
	        return resources.getString(key);
	    }
	    catch (MissingResourceException e) {}
        }

	return defaultValue;
    
public java.beans.PropertyChangeListener[]getPropertyChangeListeners()
Returns an array of all the property change listeners registered on this toolkit.

return
all of this toolkit's PropertyChangeListeners or an empty array if no property change listeners are currently registered
since
1.4

        return desktopPropsSupport.getPropertyChangeListeners();
    
public synchronized java.beans.PropertyChangeListener[]getPropertyChangeListeners(java.lang.String propertyName)
Returns an array of all the PropertyChangeListeners associated with the named property.

param
propertyName the named property
return
all of the PropertyChangeListeners associated with the named property or an empty array if no such listeners have been added
since
1.4

        return desktopPropsSupport.getPropertyChangeListeners(propertyName);
    
public java.awt.InsetsgetScreenInsets(java.awt.GraphicsConfiguration gc)
Gets the insets of the screen.

param
gc a GraphicsConfiguration
return
the insets of this toolkit's screen, in pixels.
exception
HeadlessException if GraphicsEnvironment.isHeadless() returns true
see
java.awt.GraphicsEnvironment#isHeadless
since
1.4

        if (this != Toolkit.getDefaultToolkit()) {
            return Toolkit.getDefaultToolkit().getScreenInsets(gc);
        } else {
            return new Insets(0, 0, 0, 0);
        }
    
public abstract intgetScreenResolution()
Returns the screen resolution in dots-per-inch.

return
this toolkit's screen resolution, in dots-per-inch.
exception
HeadlessException if GraphicsEnvironment.isHeadless() returns true
see
java.awt.GraphicsEnvironment#isHeadless

public abstract java.awt.DimensiongetScreenSize()
Gets the size of the screen. On systems with multiple displays, the primary display is used. Multi-screen aware display dimensions are available from GraphicsConfiguration and GraphicsDevice.

return
the size of this toolkit's screen, in pixels.
exception
HeadlessException if GraphicsEnvironment.isHeadless() returns true
see
java.awt.GraphicsConfiguration#getBounds
see
java.awt.GraphicsDevice#getDisplayMode
see
java.awt.GraphicsEnvironment#isHeadless

public abstract java.awt.datatransfer.ClipboardgetSystemClipboard()
Gets the singleton instance of the system Clipboard which interfaces with clipboard facilities provided by the native platform. This clipboard enables data transfer between Java programs and native applications which use native clipboard facilities.

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:

  • DataFlavor.stringFlavor
  • DataFlavor.plainTextFlavor (deprecated)
As with 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.

return
the system Clipboard
exception
HeadlessException if GraphicsEnvironment.isHeadless() returns true
see
java.awt.GraphicsEnvironment#isHeadless
see
java.awt.datatransfer.Clipboard
see
java.awt.datatransfer.StringSelection
see
java.awt.datatransfer.DataFlavor#stringFlavor
see
java.awt.datatransfer.DataFlavor#plainTextFlavor
see
java.io.Reader
see
java.awt.AWTPermission
since
JDK1.1

public final java.awt.EventQueuegetSystemEventQueue()
Get the application's or applet's EventQueue instance. Depending on the Toolkit implementation, different EventQueues may be returned for different applets. Applets should therefore not assume that the EventQueue instance returned by this method will be shared by other applets or the system.

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.

return
the EventQueue object
throws
SecurityException if a security manager exists and its {@link java.lang.SecurityManager#checkAwtEventQueueAccess} method denies access to the EventQueue
see
java.awt.AWTPermission

        SecurityManager security = System.getSecurityManager();
        if (security != null) {
	  security.checkAwtEventQueueAccess();
        }
        return getSystemEventQueueImpl();
    
protected abstract java.awt.EventQueuegetSystemEventQueueImpl()
Gets the application's or applet's EventQueue instance, without checking access. For security reasons, this can only be called from a Toolkit subclass.

return
the EventQueue object

public java.awt.datatransfer.ClipboardgetSystemSelection()
Gets the singleton instance of the system selection as a 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 Components 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.

return
the system selection as a Clipboard, or null if the native platform does not support a system selection Clipboard
exception
HeadlessException if GraphicsEnvironment.isHeadless() returns true
see
java.awt.datatransfer.Clipboard
see
java.awt.event.FocusListener
see
java.awt.event.FocusEvent#FOCUS_GAINED
see
java.awt.event.FocusEvent#FOCUS_LOST
see
TextComponent
see
javax.swing.text.JTextComponent
see
AWTPermission
see
GraphicsEnvironment#isHeadless
since
1.4

        if (this != Toolkit.getDefaultToolkit()) {
            return Toolkit.getDefaultToolkit().getSystemSelection();
        } else {
            GraphicsEnvironment.checkHeadless();
            return null;
        }
    
private static voidinitAssistiveTechnologies()
Initializes properties related to assistive technologies. These properties are used both in the loadAssistiveProperties() function below, as well as other classes in the jdk that depend on the properties (such as the use of the screen_magnifier_present property in Java2D hardware acceleration initialization). The initialization of the properties must be done before the platform- specific Toolkit class is instantiated so that all necessary properties are set up properly before any classes dependent upon them are initialized.


	// Get accessibility properties 
        final String sep = File.separator;
        final Properties properties = new Properties();


	atNames = (String)java.security.AccessController.doPrivileged(
	    new java.security.PrivilegedAction() {
	    public Object run() {

		// Try loading the per-user accessibility properties file.
		try {
		    File propsFile = new File(
		      System.getProperty("user.home") +
		      sep + ".accessibility.properties");
		    FileInputStream in =
			new FileInputStream(propsFile);

                    // Inputstream has been buffered in Properties class
		    properties.load(in);
		    in.close();
		} catch (Exception e) {
		    // Per-user accessibility properties file does not exist
		}

		// Try loading the system-wide accessibility properties
		// file only if a per-user accessibility properties
		// file does not exist or is empty.
		if (properties.size() == 0) {
		    try {
			File propsFile = new File(
			    System.getProperty("java.home") + sep + "lib" +
			    sep + "accessibility.properties");
			FileInputStream in =
			    new FileInputStream(propsFile);
			
			// Inputstream has been buffered in Properties class
			properties.load(in);
			in.close();
		    } catch (Exception e) {
			// System-wide accessibility properties file does 
			// not exist;
		    }
		}
		
		// Get whether a screen magnifier is present.  First check
		// the system property and then check the properties file.
		String magPresent = System.getProperty("javax.accessibility.screen_magnifier_present");
		if (magPresent == null) {
		    magPresent = properties.getProperty("screen_magnifier_present", null);
		    if (magPresent != null) {
			System.setProperty("javax.accessibility.screen_magnifier_present", magPresent);
		    }
		}

		// Get the names of any assistive technolgies to load.  First 
		// check the system property and then check the properties 
		// file.
		String classNames = System.getProperty("javax.accessibility.assistive_technologies");
		if (classNames == null) {
		    classNames = properties.getProperty("assistive_technologies", null);
		    if (classNames != null) {
			System.setProperty("javax.accessibility.assistive_technologies", classNames);
		    }
		}
		return classNames;
	    }
	});
    
private static native voidinitIDs()
Initialize JNI field and method ids

protected voidinitializeDesktopProperties()
initializeDesktopProperties

    
public booleanisDynamicLayoutActive()
Returns whether dynamic layout of Containers on resize is currently active (both set programmatically, and supported by the underlying operating system and/or window manager). The OS/WM support can be queried using getDesktopProperty("awt.dynamicLayoutSupported").

return
true if dynamic layout of Containers on resize is currently active, false otherwise.
exception
HeadlessException if GraphicsEnvironment.isHeadless() returns true
see
#setDynamicLayout(boolean dynamic)
see
#isDynamicLayoutSet()
see
#getDesktopProperty(String propertyName)
see
java.awt.GraphicsEnvironment#isHeadless
since
1.4

        if (this != Toolkit.getDefaultToolkit()) {
            return Toolkit.getDefaultToolkit().isDynamicLayoutActive();
        } else {
            return false;
        }
    
protected booleanisDynamicLayoutSet()
Returns whether the layout of Containers is validated dynamically during resizing, or statically, after resizing is complete. Note: this method returns the value that was set programmatically; it does not reflect support at the level of the operating system or window manager for dynamic layout on resizing, or the current operating system or window manager settings. The OS/WM support can be queried using getDesktopProperty("awt.dynamicLayoutSupported").

return
true if validation of Containers is done dynamically, false if validation is done after resizing is finished.
exception
HeadlessException if GraphicsEnvironment.isHeadless() returns true
see
#setDynamicLayout(boolean dynamic)
see
#isDynamicLayoutActive()
see
#getDesktopProperty(String propertyName)
see
java.awt.GraphicsEnvironment#isHeadless
since
1.4

        if (this != Toolkit.getDefaultToolkit()) {
            return Toolkit.getDefaultToolkit().isDynamicLayoutSet();
        } else {
            return false;
        }
    
public booleanisFrameStateSupported(int state)
Returns whether Toolkit supports this state for Frames. 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.

param
state one of named frame state constants.
return
true is this frame state is supported by this Toolkit implementation, false otherwise.
exception
HeadlessException if GraphicsEnvironment.isHeadless() returns true.
see
java.awt.Frame#setExtendedState
since
1.4

        if (this != Toolkit.getDefaultToolkit()) {
	    return Toolkit.getDefaultToolkit().
		isFrameStateSupported(state);
	} else {
	    return (state == Frame.NORMAL); // others are not guaranteed
	}
    
protected java.lang.ObjectlazilyLoadDesktopProperty(java.lang.String name)
an opportunity to lazily evaluate desktop property values.

	return null;
    
private static voidloadAssistiveTechnologies()
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(). All errors are handled via an AWTError exception.

The assumption is made that assistive technology classes are supplied as part of INSTALLED (as opposed to: BUNDLED) extensions or specified on the class path (and therefore can be loaded using the class loader returned by a call to ClassLoader.getSystemClassLoader, whose delegation parent is the extension class loader for installed extensions).

	// Load any assistive technologies
        if (atNames != null) {
	    ClassLoader cl = ClassLoader.getSystemClassLoader();
            StringTokenizer parser = new StringTokenizer(atNames," ,");
	    String atName;
            while (parser.hasMoreTokens()) {
		atName = parser.nextToken();
                try {
		    Class clazz;
		    if (cl != null) {
			clazz = cl.loadClass(atName);
		    } else {
			clazz = Class.forName(atName);
		    }
		    clazz.newInstance();
                } catch (ClassNotFoundException e) {
                    throw new AWTError("Assistive Technology not found: "
			    + atName);
                } catch (InstantiationException e) {
                    throw new AWTError("Could not instantiate Assistive"
			    + " Technology: " + atName);
                } catch (IllegalAccessException e) {
                    throw new AWTError("Could not access Assistive"
			    + " Technology: " + atName);
                } catch (Exception e) {
                    throw new AWTError("Error trying to install Assistive"
			    + " Technology: " + atName + " " + e);
                }
            }
        }
    
static voidloadLibraries()

       
	if (!loaded) {
	    java.security.AccessController.doPrivileged(
			  new sun.security.action.LoadLibraryAction("awt"));
	    loaded = true;
        }
    
protected voidloadSystemColors(int[] systemColors)
Fills in the integer array that is supplied as an argument with the current system color values.

param
systemColors an integer array.
exception
HeadlessException if GraphicsEnvironment.isHeadless() returns true
see
java.awt.GraphicsEnvironment#isHeadless
since
JDK1.1

    
public abstract java.util.MapmapInputMethodHighlight(java.awt.im.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. The style field of the input method highlight is ignored. The map returned is unmodifiable.

param
highlight input method highlight
return
style attribute map, or null
exception
HeadlessException if GraphicsEnvironment.isHeadless returns true
see
java.awt.GraphicsEnvironment#isHeadless
since
1.3

voidnotifyAWTEventListeners(java.awt.AWTEvent theEvent)

        // This is a workaround for headless toolkits.  It would be
        // better to override this method but it is declared package private.
        // "this instanceof" syntax defeats polymorphism.
        // --mm, 03/03/00
        if (this instanceof HeadlessToolkit) {
            ((HeadlessToolkit)this).getUnderlyingToolkit()
                .notifyAWTEventListeners(theEvent);
            return;
        }

	AWTEventListener eventListener = this.eventListener;
        if (eventListener != null) {
	    eventListener.eventDispatched(theEvent);
        }
    
public abstract booleanprepareImage(java.awt.Image image, int width, int height, java.awt.image.ImageObserver observer)
Prepares an image for rendering.

If the values of the width and height arguments are both -1, this method prepares the image for rendering on the default screen; otherwise, this method prepares an image for rendering on the default screen at the specified width and height.

The image data is downloaded asynchronously in another thread, and an appropriately scaled screen representation of the image is generated.

This method is called by components prepareImage methods.

Information on the flags returned by this method can be found with the definition of the ImageObserver interface.

param
image the image for which to prepare a screen representation.
param
width the width of the desired screen representation, or -1.
param
height the height of the desired screen representation, or -1.
param
observer the ImageObserver object to be notified as the image is being prepared.
return
true if the image has already been fully prepared; false otherwise.
see
java.awt.Component#prepareImage(java.awt.Image, java.awt.image.ImageObserver)
see
java.awt.Component#prepareImage(java.awt.Image, int, int, java.awt.image.ImageObserver)
see
java.awt.image.ImageObserver

public voidremoveAWTEventListener(java.awt.event.AWTEventListener listener)
Removes an AWTEventListener from receiving dispatched AWTEvents.

First, if there is a security manager, its checkPermission method is called with an AWTPermission("listenToAllAWTEvents") permission. This may result in a SecurityException.

Note: event listener use is not recommended for normal application use, but are intended solely to support special purpose facilities including support for accessibility, event record/playback, and diagnostic tracing. If listener is null, no exception is thrown and no action is performed.

param
listener the event listener.
throws
SecurityException if a security manager exists and its checkPermission method doesn't allow the operation.
see
#addAWTEventListener
see
#getAWTEventListeners
see
SecurityManager#checkPermission
see
java.awt.AWTEvent
see
java.awt.AWTPermission
see
java.awt.event.AWTEventListener
see
java.awt.event.AWTEventListenerProxy
since
1.2

        AWTEventListener localL = deProxyAWTEventListener(listener);

        if (listener == null) {
            return;
        }
        SecurityManager security = System.getSecurityManager();
        if (security != null) {
            security.checkPermission(SecurityConstants.ALL_AWT_EVENTS_PERMISSION);
        }

        synchronized (this) {
            SelectiveAWTEventListener selectiveListener =
            (SelectiveAWTEventListener)listener2SelectiveListener.get(localL);

            if (selectiveListener != null) {
                listener2SelectiveListener.remove(localL);
                int[] listenerCalls = selectiveListener.getCalls();
                for (int i=0; i<LONG_BITS; i++) {
                    calls[i] -= listenerCalls[i];
                    assert calls[i] >= 0: "Negative Listeners count";
                    
                    if (calls[i] == 0) {
                        enabledOnToolkitMask &= ~(1L<<i);
                    }
                }
            }
            eventListener = ToolkitEventMulticaster.remove(eventListener,
            (selectiveListener == null) ? localL : selectiveListener);
        }
    
public synchronized voidremovePropertyChangeListener(java.lang.String name, java.beans.PropertyChangeListener pcl)
Removes the specified property change listener for the named desktop property. If pcl is null, no exception is thrown and no action is performed.

param
name The name of the property to remove
param
pcl The property change listener
since
1.2

	if (pcl == null) {
	    return;
	}
	desktopPropsSupport.removePropertyChangeListener(name, pcl);
    
protected final voidsetDesktopProperty(java.lang.String name, java.lang.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.

        // This is a workaround for headless toolkits.  It would be
        // better to override this method but it is declared final.
        // "this instanceof" syntax defeats polymorphism.
        // --mm, 03/03/00
        if (this instanceof HeadlessToolkit) {
            ((HeadlessToolkit)this).getUnderlyingToolkit()
                .setDesktopProperty(name, newValue);
            return;
        }
        Object oldValue;

        synchronized (this) {
            oldValue = desktopProperties.get(name);
            desktopProperties.put(name, newValue);
        }

        desktopPropsSupport.firePropertyChange(name, oldValue, newValue);
    
public voidsetDynamicLayout(boolean dynamic)
Controls whether the layout of Containers is validated dynamically during resizing, or statically, after resizing is complete. Note that this feature is not supported on all platforms, and conversely, that this feature cannot be turned off on some platforms. On platforms where dynamic layout during resize 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 the underlying operating system or window manager support or settings. The OS/WM support can be queried using getDesktopProperty("awt.dynamicLayoutSupported").

param
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 finished.
exception
HeadlessException if GraphicsEnvironment.isHeadless() returns true
see
#isDynamicLayoutSet()
see
#isDynamicLayoutActive()
see
#getDesktopProperty(String propertyName)
see
java.awt.GraphicsEnvironment#isHeadless
since
1.4

    
public voidsetLockingKeyState(int keyCode, boolean on)
Sets the state of the given locking key on the keyboard. Valid key codes are {@link java.awt.event.KeyEvent#VK_CAPS_LOCK VK_CAPS_LOCK}, {@link java.awt.event.KeyEvent#VK_NUM_LOCK VK_NUM_LOCK}, {@link java.awt.event.KeyEvent#VK_SCROLL_LOCK VK_SCROLL_LOCK}, and {@link java.awt.event.KeyEvent#VK_KANA_LOCK 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.

exception
java.lang.IllegalArgumentException if keyCode is not one of the valid key codes
exception
java.lang.UnsupportedOperationException if the host system doesn't allow setting the state of this key programmatically, or if the keyboard doesn't have this key
exception
HeadlessException if GraphicsEnvironment.isHeadless() returns true
see
java.awt.GraphicsEnvironment#isHeadless
since
1.3

        if (! (keyCode == KeyEvent.VK_CAPS_LOCK || keyCode == KeyEvent.VK_NUM_LOCK ||
               keyCode == KeyEvent.VK_SCROLL_LOCK || keyCode == KeyEvent.VK_KANA_LOCK)) {
            throw new IllegalArgumentException("invalid key for Toolkit.setLockingKeyState");
        }
        throw new UnsupportedOperationException("Toolkit.setLockingKeyState");
    
public abstract voidsync()
Synchronizes this toolkit's graphics state. Some window systems may do buffering of graphics events.

This method ensures that the display is up-to-date. It is useful for animation.