Class Toolkit
- java.lang.Object
-
- java.awt.Toolkit
-
public abstract class Toolkit extends java.lang.ObjectThis class is the abstract superclass of all actual implementations of the Abstract Window Toolkit. Subclasses of the
Toolkit
class are used to bind the various components to particular native toolkit implementations.Many GUI events may be delivered to user asynchronously, if the opposite is not specified explicitly. As well as many GUI operations may be performed asynchronously. This fact means that if the state of a component is set, and then the state immediately queried, the returned value may not yet reflect the requested change. This behavior includes, but is not limited to:
- Scrolling to a specified position.
For example, callingScrollPane.setScrollPosition
and thengetScrollPosition
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.
CallingsetVisible(true)
on aWindow
,Frame
orDialog
may occur asynchronously. - Setting the size or location of a top-level container.
Calls tosetSize
,setBounds
orsetLocation
on aWindow
,Frame
orDialog
are forwarded to the underlying window management system and may be ignored or modified. SeeWindow
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 thejava.awt
package with their counterparts injava.awt.peer
. Some methods defined byToolkit
query the native operating system directly.- Since:
- JDK1.0
- Scrolling to a specified position.
-
-
Static Methods Modifier and Type Static Method and Description getDefaultToolkit static Toolkit
getDefaultToolkit()Gets the default toolkit.public static Toolkit getDefaultToolkit()-
Gets the default toolkit.
If a system property named
"java.awt.headless"
is set totrue
then the headless implementation ofToolkit
is used.If there is no
"java.awt.headless"
or it is set tofalse
and there is a system property named"awt.toolkit"
, that property is treated as the name of a class that is a subclass ofToolkit
; otherwise the default platform-specific implementation ofToolkit
is used.Also loads additional classes into the VM, using the property 'assistive_technologies' specified in the Sun reference implementation by a line in the 'accessibility.properties' file. The form is "assistive_technologies=..." where the "..." is a comma-separated list of assistive technology classes to load. Each class is loaded in the order given and a single instance of each is created using Class.forName(class).newInstance(). This is done just after the AWT toolkit is created. All errors are handled via an AWTError exception.
- Returns:
- the default toolkit.
- Throws:
AWTError
- if a toolkit could not be found, or if one could not be accessed or instantiated.
getNativeContainer 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).getProperty static java.lang.String
getProperty(java.lang.String key, java.lang.String defaultValue)Gets a property with the specified key and default.public static java.lang.String getProperty(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.
-
-
Methods Modifier and Type Method and Description addAWTEventListener void
addAWTEventListener(AWTEventListener listener, long eventMask)Adds an AWTEventListener to receive all AWTEvents dispatched system-wide that conform to the giveneventMask
.public void addAWTEventListener(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 anAWTPermission("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 inAWTEvent
.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.
- Parameters:
listener
- the event listener.eventMask
- the bitmask of event types to receive- Throws:
java.lang.SecurityException
- if a security manager exists and itscheckPermission
method doesn't allow the operation.- Since:
- 1.2
- See Also:
removeAWTEventListener(java.awt.event.AWTEventListener)
,getAWTEventListeners()
,SecurityManager.checkPermission(java.security.Permission)
,AWTEvent
,AWTPermission
,AWTEventListener
,AWTEventListenerProxy
addPropertyChangeListener void
addPropertyChangeListener(java.lang.String name, java.beans.PropertyChangeListener pcl)Adds the specified property change listener for the named desktop property.public void addPropertyChangeListener(java.lang.String name, java.beans.PropertyChangeListener pcl)-
Adds the specified property change listener for the named desktop property. When a
PropertyChangeListenerProxy
object is added, its property name is ignored, and the wrapped listener is added. Ifname
isnull
orpcl
isnull
, no exception is thrown and no action is performed.- Parameters:
name
- The name of the property to listen forpcl
- The property change listener- Since:
- 1.2
- See Also:
PropertyChangeSupport.addPropertyChangeListener(String, PropertyChangeListener)
areExtraMouseButtonsEnabled boolean
areExtraMouseButtonsEnabled()Reports whether events from extra mouse buttons are allowed to be processed and posted intoEventQueue
.public boolean areExtraMouseButtonsEnabled() throws HeadlessException-
Reports whether events from extra mouse buttons are allowed to be processed and posted into
EventQueue
.
To change the returned value it is necessary to set thesun.awt.enableExtraMouseButtons
property before theToolkit
class initialization. This setting could be done on the application startup by the following command:java -Dsun.awt.enableExtraMouseButtons=false Application
Alternatively, the property could be set in the application by using the following code:System.setProperty("sun.awt.enableExtraMouseButtons", "true");
before theToolkit
class initialization. If not set by the time of theToolkit
class initialization, this property will be initialized withtrue
. Changing this value after theToolkit
class initialization will have no effect.- Returns:
true
if events from extra mouse buttons are allowed to be processed and posted;false
otherwise- Throws:
HeadlessException
- if GraphicsEnvironment.isHeadless() returns true- Since:
- 1.7
- See Also:
System.getProperty(String propertyName)
,System.setProperty(String propertyName, String value)
,EventQueue
beep abstract void
beep()Emits an audio beep.public abstract void beep()-
Emits an audio beep.
- Since:
- JDK1.1
checkImage abstract int
checkImage(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.public abstract int checkImage(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.- Parameters:
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
- theImageObserver
object to be notified as the image is being prepared.- Returns:
- the bitwise inclusive OR of the
ImageObserver
flags for the image data that is currently available. - See Also:
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
createButton protected abstract java.awt.peer.ButtonPeer
createButton(Button target)Creates this toolkit's implementation ofButton
using the specified peer interface.-
Creates this toolkit's implementation of
Button
using the specified peer interface.- Parameters:
target
- the button to be implemented.- Returns:
- this toolkit's implementation of
Button
. - Throws:
HeadlessException
- if GraphicsEnvironment.isHeadless() returns true- See Also:
GraphicsEnvironment.isHeadless()
,Button
,ButtonPeer
createCanvas protected abstract java.awt.peer.CanvasPeer
createCanvas(Canvas target)Creates this toolkit's implementation ofCanvas
using the specified peer interface.createCheckbox protected abstract java.awt.peer.CheckboxPeer
createCheckbox(Checkbox target)Creates this toolkit's implementation ofCheckbox
using the specified peer interface.protected abstract java.awt.peer.CheckboxPeer createCheckbox(Checkbox target) throws HeadlessException-
Creates this toolkit's implementation of
Checkbox
using the specified peer interface.- Parameters:
target
- the check box to be implemented.- Returns:
- this toolkit's implementation of
Checkbox
. - Throws:
HeadlessException
- if GraphicsEnvironment.isHeadless() returns true- See Also:
GraphicsEnvironment.isHeadless()
,Checkbox
,CheckboxPeer
createCheckboxMenuItem protected abstract java.awt.peer.CheckboxMenuItemPeer
createCheckboxMenuItem(CheckboxMenuItem target)Creates this toolkit's implementation ofCheckboxMenuItem
using the specified peer interface.protected abstract java.awt.peer.CheckboxMenuItemPeer createCheckboxMenuItem(CheckboxMenuItem target) throws HeadlessException-
Creates this toolkit's implementation of
CheckboxMenuItem
using the specified peer interface.- Parameters:
target
- the checkbox menu item to be implemented.- Returns:
- this toolkit's implementation of
CheckboxMenuItem
. - Throws:
HeadlessException
- if GraphicsEnvironment.isHeadless() returns true- See Also:
GraphicsEnvironment.isHeadless()
,CheckboxMenuItem
,CheckboxMenuItemPeer
createChoice protected abstract java.awt.peer.ChoicePeer
createChoice(Choice target)Creates this toolkit's implementation ofChoice
using the specified peer interface.-
Creates this toolkit's implementation of
Choice
using the specified peer interface.- Parameters:
target
- the choice to be implemented.- Returns:
- this toolkit's implementation of
Choice
. - Throws:
HeadlessException
- if GraphicsEnvironment.isHeadless() returns true- See Also:
GraphicsEnvironment.isHeadless()
,Choice
,ChoicePeer
createComponent protected java.awt.peer.LightweightPeer
createComponent(Component target)Creates a peer for a component or container.protected java.awt.peer.LightweightPeer createComponent(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.
- Parameters:
target
- The Component to be created.
createCustomCursor Cursor
createCustomCursor(Image cursor, Point hotSpot, java.lang.String name)Creates a new custom cursor object.public Cursor createCustomCursor(Image cursor, Point hotSpot, java.lang.String name) throws java.lang.IndexOutOfBoundsException, HeadlessException-
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.
- Parameters:
cursor
- the image to display when the cursor is activedhotSpot
- the X and Y of the large cursor's hot spot; the hotSpot values must be less than the Dimension returned bygetBestCursorSize
name
- a localized description of the cursor, for Java Accessibility use- Throws:
java.lang.IndexOutOfBoundsException
- if the hotSpot values are outside the bounds of the cursorHeadlessException
- if GraphicsEnvironment.isHeadless() returns true- Since:
- 1.2
- See Also:
GraphicsEnvironment.isHeadless()
createDesktopPeer protected abstract java.awt.peer.DesktopPeer
createDesktopPeer(Desktop target)Creates this toolkit's implementation of theDesktop
using the specified peer interface.protected abstract java.awt.peer.DesktopPeer createDesktopPeer(Desktop target) throws HeadlessException-
Creates this toolkit's implementation of the
Desktop
using the specified peer interface.- Parameters:
target
- the desktop to be implemented- Returns:
- this toolkit's implementation of the
Desktop
- Throws:
HeadlessException
- if GraphicsEnvironment.isHeadless() returns true- Since:
- 1.6
- See Also:
GraphicsEnvironment.isHeadless()
,Desktop
,DesktopPeer
createDialog protected abstract java.awt.peer.DialogPeer
createDialog(Dialog target)Creates this toolkit's implementation ofDialog
using the specified peer interface.-
Creates this toolkit's implementation of
Dialog
using the specified peer interface.- Parameters:
target
- the dialog to be implemented.- Returns:
- this toolkit's implementation of
Dialog
. - Throws:
HeadlessException
- if GraphicsEnvironment.isHeadless() returns true- See Also:
GraphicsEnvironment.isHeadless()
,Dialog
,DialogPeer
createDragGestureRecognizer <T extends java.awt.dnd.DragGestureRecognizer> T
createDragGestureRecognizer(java.lang.Class<T> abstractRecognizerClass, java.awt.dnd.DragSource ds, 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.public <T extends java.awt.dnd.DragGestureRecognizer> T createDragGestureRecognizer(java.lang.Class<T> abstractRecognizerClass, java.awt.dnd.DragSource ds, 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
- Parameters:
abstractRecognizerClass
- The abstract class of the required recognizerds
- The DragSourcec
- The Component target for the DragGestureRecognizersrcActions
- The actions permitted for the gesturedgl
- The DragGestureListener- Returns:
- the new object or null. Always returns null if GraphicsEnvironment.isHeadless() returns true.
- See Also:
GraphicsEnvironment.isHeadless()
createDragSourceContextPeer abstract java.awt.dnd.peer.DragSourceContextPeer
createDragSourceContextPeer(java.awt.dnd.DragGestureEvent dge)Creates the peer for a DragSourceContext.public abstract java.awt.dnd.peer.DragSourceContextPeer createDragSourceContextPeer(java.awt.dnd.DragGestureEvent dge) throws java.awt.dnd.InvalidDnDOperationException-
Creates the peer for a DragSourceContext. Always throws InvalidDndOperationException if GraphicsEnvironment.isHeadless() returns true.
- Throws:
java.awt.dnd.InvalidDnDOperationException
- See Also:
GraphicsEnvironment.isHeadless()
createFileDialog protected abstract java.awt.peer.FileDialogPeer
createFileDialog(FileDialog target)Creates this toolkit's implementation ofFileDialog
using the specified peer interface.protected abstract java.awt.peer.FileDialogPeer createFileDialog(FileDialog target) throws HeadlessException-
Creates this toolkit's implementation of
FileDialog
using the specified peer interface.- Parameters:
target
- the file dialog to be implemented.- Returns:
- this toolkit's implementation of
FileDialog
. - Throws:
HeadlessException
- if GraphicsEnvironment.isHeadless() returns true- See Also:
GraphicsEnvironment.isHeadless()
,FileDialog
,FileDialogPeer
createFrame protected abstract java.awt.peer.FramePeer
createFrame(Frame target)Creates this toolkit's implementation ofFrame
using the specified peer interface.-
Creates this toolkit's implementation of
Frame
using the specified peer interface.- Parameters:
target
- the frame to be implemented.- Returns:
- this toolkit's implementation of
Frame
. - Throws:
HeadlessException
- if GraphicsEnvironment.isHeadless() returns true- See Also:
GraphicsEnvironment.isHeadless()
,Frame
,FramePeer
createImage Image
createImage(byte[] imagedata)Creates an image which decodes the image stored in the specified byte array.public Image createImage(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.
- Parameters:
imagedata
- an array of bytes, representing image data in a supported image format.- Returns:
- an image.
- Since:
- JDK1.1
createImage 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.public 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. The data must be in some image format, such as GIF or JPEG, that is supported by this toolkit.
- Parameters:
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.- Returns:
- an image.
- Since:
- JDK1.1
createImage abstract Image
createImage(java.awt.image.ImageProducer producer)Creates an image with the specified image producer.public abstract Image createImage(java.awt.image.ImageProducer producer)-
Creates an image with the specified image producer.
- Parameters:
producer
- the image producer to be used.- Returns:
- an image with the specified image producer.
- See Also:
Image
,ImageProducer
,Component.createImage(java.awt.image.ImageProducer)
createImage abstract Image
createImage(java.lang.String filename)Returns an image which gets pixel data from the specified file.public abstract Image createImage(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.
This method first checks if there is a security manager installed. If so, the method calls the security manager's
checkRead
method with the specified file to ensure that the image creation is allowed.- Parameters:
filename
- the name of a file containing pixel data in a recognized file format.- Returns:
- an image which gets its pixel data from the specified file.
- Throws:
java.lang.SecurityException
- if a security manager exists and its checkRead method doesn't allow the operation.- See Also:
getImage(java.lang.String)
createImage abstract Image
createImage(java.net.URL url)Returns an image which gets pixel data from the specified URL.public abstract Image createImage(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.
This method first checks if there is a security manager installed. If so, the method calls the security manager's
checkPermission
method with the url.openConnection().getPermission() permission to ensure that the image creation is allowed. For compatibility with pre-1.2 security managers, if the access is denied withFilePermission
orSocketPermission
, the method throwsSecurityException
if the corresponding 1.1-style SecurityManager.checkXXX method also denies permission.- Parameters:
url
- the URL to use in fetching the pixel data.- Returns:
- an image which gets its pixel data from the specified URL.
- Throws:
java.lang.SecurityException
- if a security manager exists and its checkPermission method doesn't allow the operation.- See Also:
getImage(java.net.URL)
createLabel protected abstract java.awt.peer.LabelPeer
createLabel(Label target)Creates this toolkit's implementation ofLabel
using the specified peer interface.-
Creates this toolkit's implementation of
Label
using the specified peer interface.- Parameters:
target
- the label to be implemented.- Returns:
- this toolkit's implementation of
Label
. - Throws:
HeadlessException
- if GraphicsEnvironment.isHeadless() returns true- See Also:
GraphicsEnvironment.isHeadless()
,Label
,LabelPeer
createList protected abstract java.awt.peer.ListPeer
createList(List target)Creates this toolkit's implementation ofList
using the specified peer interface.-
Creates this toolkit's implementation of
List
using the specified peer interface.- Parameters:
target
- the list to be implemented.- Returns:
- this toolkit's implementation of
List
. - Throws:
HeadlessException
- if GraphicsEnvironment.isHeadless() returns true- See Also:
GraphicsEnvironment.isHeadless()
,List
,ListPeer
createMenu protected abstract java.awt.peer.MenuPeer
createMenu(Menu target)Creates this toolkit's implementation ofMenu
using the specified peer interface.-
Creates this toolkit's implementation of
Menu
using the specified peer interface.- Parameters:
target
- the menu to be implemented.- Returns:
- this toolkit's implementation of
Menu
. - Throws:
HeadlessException
- if GraphicsEnvironment.isHeadless() returns true- See Also:
GraphicsEnvironment.isHeadless()
,Menu
,MenuPeer
createMenuBar protected abstract java.awt.peer.MenuBarPeer
createMenuBar(MenuBar target)Creates this toolkit's implementation ofMenuBar
using the specified peer interface.-
Creates this toolkit's implementation of
MenuBar
using the specified peer interface.- Parameters:
target
- the menu bar to be implemented.- Returns:
- this toolkit's implementation of
MenuBar
. - Throws:
HeadlessException
- if GraphicsEnvironment.isHeadless() returns true- See Also:
GraphicsEnvironment.isHeadless()
,MenuBar
,MenuBarPeer
createMenuItem protected abstract java.awt.peer.MenuItemPeer
createMenuItem(MenuItem target)Creates this toolkit's implementation ofMenuItem
using the specified peer interface.protected abstract java.awt.peer.MenuItemPeer createMenuItem(MenuItem target) throws HeadlessException-
Creates this toolkit's implementation of
MenuItem
using the specified peer interface.- Parameters:
target
- the menu item to be implemented.- Returns:
- this toolkit's implementation of
MenuItem
. - Throws:
HeadlessException
- if GraphicsEnvironment.isHeadless() returns true- See Also:
GraphicsEnvironment.isHeadless()
,MenuItem
,MenuItemPeer
createPanel protected abstract java.awt.peer.PanelPeer
createPanel(Panel target)Creates this toolkit's implementation ofPanel
using the specified peer interface.createPopupMenu protected abstract java.awt.peer.PopupMenuPeer
createPopupMenu(PopupMenu target)Creates this toolkit's implementation ofPopupMenu
using the specified peer interface.protected abstract java.awt.peer.PopupMenuPeer createPopupMenu(PopupMenu target) throws HeadlessException-
Creates this toolkit's implementation of
PopupMenu
using the specified peer interface.- Parameters:
target
- the popup menu to be implemented.- Returns:
- this toolkit's implementation of
PopupMenu
. - Throws:
HeadlessException
- if GraphicsEnvironment.isHeadless() returns true- Since:
- JDK1.1
- See Also:
GraphicsEnvironment.isHeadless()
,PopupMenu
,PopupMenuPeer
createScrollbar protected abstract java.awt.peer.ScrollbarPeer
createScrollbar(Scrollbar target)Creates this toolkit's implementation ofScrollbar
using the specified peer interface.protected abstract java.awt.peer.ScrollbarPeer createScrollbar(Scrollbar target) throws HeadlessException-
Creates this toolkit's implementation of
Scrollbar
using the specified peer interface.- Parameters:
target
- the scroll bar to be implemented.- Returns:
- this toolkit's implementation of
Scrollbar
. - Throws:
HeadlessException
- if GraphicsEnvironment.isHeadless() returns true- See Also:
GraphicsEnvironment.isHeadless()
,Scrollbar
,ScrollbarPeer
createScrollPane protected abstract java.awt.peer.ScrollPanePeer
createScrollPane(ScrollPane target)Creates this toolkit's implementation ofScrollPane
using the specified peer interface.protected abstract java.awt.peer.ScrollPanePeer createScrollPane(ScrollPane target) throws HeadlessException-
Creates this toolkit's implementation of
ScrollPane
using the specified peer interface.- Parameters:
target
- the scroll pane to be implemented.- Returns:
- this toolkit's implementation of
ScrollPane
. - Throws:
HeadlessException
- if GraphicsEnvironment.isHeadless() returns true- Since:
- JDK1.1
- See Also:
GraphicsEnvironment.isHeadless()
,ScrollPane
,ScrollPanePeer
createTextArea protected abstract java.awt.peer.TextAreaPeer
createTextArea(TextArea target)Creates this toolkit's implementation ofTextArea
using the specified peer interface.protected abstract java.awt.peer.TextAreaPeer createTextArea(TextArea target) throws HeadlessException-
Creates this toolkit's implementation of
TextArea
using the specified peer interface.- Parameters:
target
- the text area to be implemented.- Returns:
- this toolkit's implementation of
TextArea
. - Throws:
HeadlessException
- if GraphicsEnvironment.isHeadless() returns true- See Also:
GraphicsEnvironment.isHeadless()
,TextArea
,TextAreaPeer
createTextField protected abstract java.awt.peer.TextFieldPeer
createTextField(TextField target)Creates this toolkit's implementation ofTextField
using the specified peer interface.protected abstract java.awt.peer.TextFieldPeer createTextField(TextField target) throws HeadlessException-
Creates this toolkit's implementation of
TextField
using the specified peer interface.- Parameters:
target
- the text field to be implemented.- Returns:
- this toolkit's implementation of
TextField
. - Throws:
HeadlessException
- if GraphicsEnvironment.isHeadless() returns true- See Also:
GraphicsEnvironment.isHeadless()
,TextField
,TextFieldPeer
createWindow protected abstract java.awt.peer.WindowPeer
createWindow(Window target)Creates this toolkit's implementation ofWindow
using the specified peer interface.-
Creates this toolkit's implementation of
Window
using the specified peer interface.- Parameters:
target
- the window to be implemented.- Returns:
- this toolkit's implementation of
Window
. - Throws:
HeadlessException
- if GraphicsEnvironment.isHeadless() returns true- See Also:
GraphicsEnvironment.isHeadless()
,Window
,WindowPeer
getAWTEventListeners AWTEventListener[]
getAWTEventListeners()Returns an array of all theAWTEventListener
s registered on this toolkit.public AWTEventListener[] getAWTEventListeners()-
Returns an array of all the
AWTEventListener
s registered on this toolkit. If there is a security manager, itscheckPermission
method is called with anAWTPermission("listenToAllAWTEvents")
permission. This may result in a SecurityException. Listeners can be returned withinAWTEventListenerProxy
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.- Returns:
- all of the
AWTEventListener
s or an empty array if no listeners are currently registered - Throws:
java.lang.SecurityException
- if a security manager exists and itscheckPermission
method doesn't allow the operation.- Since:
- 1.4
- See Also:
addAWTEventListener(java.awt.event.AWTEventListener, long)
,removeAWTEventListener(java.awt.event.AWTEventListener)
,SecurityManager.checkPermission(java.security.Permission)
,AWTEvent
,AWTPermission
,AWTEventListener
,AWTEventListenerProxy
getAWTEventListeners AWTEventListener[]
getAWTEventListeners(long eventMask)Returns an array of all theAWTEventListener
s registered on this toolkit which listen to all of the event types specified in theeventMask
argument.public AWTEventListener[] getAWTEventListeners(long eventMask)-
Returns an array of all the
AWTEventListener
s registered on this toolkit which listen to all of the event types specified in theeventMask
argument. If there is a security manager, itscheckPermission
method is called with anAWTPermission("listenToAllAWTEvents")
permission. This may result in a SecurityException. Listeners can be returned withinAWTEventListenerProxy
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.- Parameters:
eventMask
- the bitmask of event types to listen for- Returns:
- all of the
AWTEventListener
s registered on this toolkit for the specified event types, or an empty array if no such listeners are currently registered - Throws:
java.lang.SecurityException
- if a security manager exists and itscheckPermission
method doesn't allow the operation.- Since:
- 1.4
- See Also:
addAWTEventListener(java.awt.event.AWTEventListener, long)
,removeAWTEventListener(java.awt.event.AWTEventListener)
,SecurityManager.checkPermission(java.security.Permission)
,AWTEvent
,AWTPermission
,AWTEventListener
,AWTEventListenerProxy
getBestCursorSize Dimension
getBestCursorSize(int preferredWidth, int preferredHeight)Returns the supported cursor dimension which is closest to the desired sizes.public Dimension getBestCursorSize(int preferredWidth, int preferredHeight) throws HeadlessException-
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.
- Parameters:
preferredWidth
- the preferred cursor width the component would like to use.preferredHeight
- the preferred cursor height the component would like to use.- Returns:
- the closest matching supported cursor size, or a dimension of 0,0 if the Toolkit implementation doesn't support custom cursors.
- Throws:
HeadlessException
- if GraphicsEnvironment.isHeadless() returns true- Since:
- 1.2
- See Also:
GraphicsEnvironment.isHeadless()
getColorModel abstract java.awt.image.ColorModel
getColorModel()Determines the color model of this toolkit's screen.public abstract java.awt.image.ColorModel getColorModel() throws HeadlessException-
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 theComponent
class.- Returns:
- the color model of this toolkit's screen.
- Throws:
HeadlessException
- if GraphicsEnvironment.isHeadless() returns true- See Also:
GraphicsEnvironment.isHeadless()
,ColorModel
,Component.getColorModel()
getDesktopProperty java.lang.Object
getDesktopProperty(java.lang.String propertyName)Obtains a value for the specified desktop property.public final java.lang.Object getDesktopProperty(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. For more information on desktop properties supported by the AWT see AWT Desktop Properties.
getFontList abstract java.lang.String[]
getFontList()Deprecated seeGraphicsEnvironment.getAvailableFontFamilyNames()
@Deprecated public abstract java.lang.String[] getFontList()Deprecated seeGraphicsEnvironment.getAvailableFontFamilyNames()
-
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.
- Returns:
- the names of the available fonts in this toolkit.
- See Also:
GraphicsEnvironment.getAvailableFontFamilyNames()
getFontMetrics abstract FontMetrics
getFontMetrics(Font font)Deprecated. As of JDK version 1.2, replaced by theFont
methodgetLineMetrics
.Deprecated. As of JDK version 1.2, replaced by theFont
methodgetLineMetrics
.-
Gets the screen device metrics for rendering of the font.
- Parameters:
font
- a font- Returns:
- the screen metrics of the specified font in this toolkit
- See Also:
LineMetrics
,Font.getLineMetrics(java.lang.String, java.awt.font.FontRenderContext)
,GraphicsEnvironment.getScreenDevices()
getFontPeer protected abstract java.awt.peer.FontPeer
getFontPeer(java.lang.String name, int style)Deprecated see java.awt.GraphicsEnvironment#getAllFonts@Deprecated protected abstract java.awt.peer.FontPeer getFontPeer(java.lang.String name, int style)Deprecated see java.awt.GraphicsEnvironment#getAllFonts-
Creates this toolkit's implementation of
Font
using the specified peer interface.- Parameters:
name
- the font to be implementedstyle
- the style of the font, such asPLAIN
,BOLD
,ITALIC
, or a combination- Returns:
- this toolkit's implementation of
Font
- See Also:
Font
,FontPeer
,GraphicsEnvironment.getAllFonts()
getImage abstract Image
getImage(java.lang.String filename)Returns an image which gets pixel data from the specified file, whose format can be either GIF, JPEG or PNG.public abstract Image getImage(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 in use for an indefinite period of time, developers are encouraged to implement their own caching of images by using thecreateImage
variant wherever available. If the image data contained in the specified file changes, theImage
object returned from this method may still contain stale information which was loaded from the file after a prior call. Previously loaded image data can be manually discarded by calling theflush
method on the returnedImage
.This method first checks if there is a security manager installed. If so, the method calls the security manager's
checkRead
method with the file specified to ensure that the access to the image is allowed.- Parameters:
filename
- the name of a file containing pixel data in a recognized file format.- Returns:
- an image which gets its pixel data from the specified file.
- Throws:
java.lang.SecurityException
- if a security manager exists and its checkRead method doesn't allow the operation.- See Also:
createImage(java.lang.String)
getImage abstract Image
getImage(java.net.URL url)Returns an image which gets pixel data from the specified URL.public abstract Image getImage(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 in use for an indefinite period of time, developers are encouraged to implement their own caching of images by using thecreateImage
variant wherever available. If the image data stored at the specified URL changes, theImage
object returned from this method may still contain stale information which was fetched from the URL after a prior call. Previously loaded image data can be manually discarded by calling theflush
method on the returnedImage
.This method first checks if there is a security manager installed. If so, the method calls the security manager's
checkPermission
method with the url.openConnection().getPermission() permission to ensure that the access to the image is allowed. For compatibility with pre-1.2 security managers, if the access is denied withFilePermission
orSocketPermission
, the method throws theSecurityException
if the corresponding 1.1-style SecurityManager.checkXXX method also denies permission.- Parameters:
url
- the URL to use in fetching the pixel data.- Returns:
- an image which gets its pixel data from the specified URL.
- Throws:
java.lang.SecurityException
- if a security manager exists and its checkPermission method doesn't allow the operation.- See Also:
createImage(java.net.URL)
getLockingKeyState boolean
getLockingKeyState(int keyCode)Returns whether the given locking key on the keyboard is currently in its "on" state.public boolean getLockingKeyState(int keyCode) throws java.lang.UnsupportedOperationException-
Returns whether the given locking key on the keyboard is currently in its "on" state. Valid key codes are
VK_CAPS_LOCK
,VK_NUM_LOCK
,VK_SCROLL_LOCK
, andVK_KANA_LOCK
.- Throws:
java.lang.IllegalArgumentException
- ifkeyCode
is not one of the valid key codesjava.lang.UnsupportedOperationException
- if the host system doesn't allow getting the state of this key programmatically, or if the keyboard doesn't have this keyHeadlessException
- if GraphicsEnvironment.isHeadless() returns true- Since:
- 1.3
- See Also:
GraphicsEnvironment.isHeadless()
getMaximumCursorColors int
getMaximumCursorColors()Returns the maximum number of colors the Toolkit supports in a custom cursor palette.public int getMaximumCursorColors() throws HeadlessException-
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.
- Returns:
- the maximum number of colors, or zero if custom cursors are not supported by this Toolkit implementation.
- Throws:
HeadlessException
- if GraphicsEnvironment.isHeadless() returns true- Since:
- 1.2
- See Also:
GraphicsEnvironment.isHeadless()
getMenuShortcutKeyMask int
getMenuShortcutKeyMask()Determines which modifier key is the appropriate accelerator key for menu shortcuts.public int getMenuShortcutKeyMask() throws HeadlessException-
Determines which modifier key is the appropriate accelerator key for menu shortcuts.
Menu shortcuts, which are embodied in the
MenuShortcut
class, are handled by theMenuBar
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.- Returns:
- the modifier mask on the
Event
class that is used for menu shortcuts on this toolkit. - Throws:
HeadlessException
- if GraphicsEnvironment.isHeadless() returns true- Since:
- JDK1.1
- See Also:
GraphicsEnvironment.isHeadless()
,MenuBar
,MenuShortcut
getMouseInfoPeer protected java.awt.peer.MouseInfoPeer
getMouseInfoPeer()Obtains this toolkit's implementation of helper class forMouseInfo
operations.protected java.awt.peer.MouseInfoPeer getMouseInfoPeer()-
Obtains this toolkit's implementation of helper class for
MouseInfo
operations.- Returns:
- this toolkit's implementation of helper for
MouseInfo
- Throws:
java.lang.UnsupportedOperationException
- if this operation is not implemented- Since:
- 1.5
- See Also:
MouseInfoPeer
,MouseInfo
getPrintJob PrintJob
getPrintJob(Frame frame, java.lang.String jobtitle, JobAttributes jobAttributes, PageAttributes pageAttributes)Gets aPrintJob
object which is the result of initiating a print operation on the toolkit's platform.public PrintJob getPrintJob(Frame frame, java.lang.String jobtitle, JobAttributes jobAttributes, 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 ofcheckPrintJobAccess
is used (that is, that method is not overriden), then this results in a call to the security manager'scheckPermission
method with aRuntimePermission("queuePrintJob")
permission.- Parameters:
frame
- the parent of the print dialog. May not be null.jobtitle
- the title of the PrintJob. A null title is equivalent to "".jobAttributes
- a set of job attributes which will control the PrintJob. The attributes will be updated to reflect the user's choices as outlined in the JobAttributes documentation. May be null.pageAttributes
- a set of page attributes which will control the PrintJob. The attributes will be applied to every page in the job. The attributes will be updated to reflect the user's choices as outlined in the PageAttributes documentation. May be null.- Returns:
- a
PrintJob
object, ornull
if the user cancelled the print job. - Throws:
java.lang.NullPointerException
- if frame is nulljava.lang.IllegalArgumentException
- if pageAttributes specifies differing cross feed and feed resolutions. Also if this thread has access to the file system and jobAttributes specifies print to file, and the specified destination file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason. However in the case of print to file, if a dialog is also requested to be displayed then the user will be given an opportunity to select a file and proceed with printing. The dialog will ensure that the selected output file is valid before returning from this method.java.lang.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- Since:
- 1.3
- See Also:
PrintJob
,GraphicsEnvironment.isHeadless()
,RuntimePermission
,JobAttributes
,PageAttributes
getPrintJob abstract PrintJob
getPrintJob(Frame frame, java.lang.String jobtitle, java.util.Properties props)Gets aPrintJob
object which is the result of initiating a print operation on the toolkit's platform.public abstract PrintJob getPrintJob(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 ofcheckPrintJobAccess
is used (that is, that method is not overriden), then this results in a call to the security manager'scheckPermission
method with aRuntimePermission("queuePrintJob")
permission.- Parameters:
frame
- the parent of the print dialog. May not be null.jobtitle
- the title of the PrintJob. A null title is equivalent to "".props
- a Properties object containing zero or more properties. Properties are not standardized and are not consistent across implementations. Because of this, PrintJobs which require job and page control should use the version of this function which takes JobAttributes and PageAttributes objects. This object may be updated to reflect the user's job choices on exit. May be null.- Returns:
- a
PrintJob
object, ornull
if the user cancelled the print job. - Throws:
java.lang.NullPointerException
- if frame is nulljava.lang.SecurityException
- if this thread is not allowed to initiate a print job request- Since:
- JDK1.1
- See Also:
GraphicsEnvironment.isHeadless()
,PrintJob
,RuntimePermission
getPropertyChangeListeners java.beans.PropertyChangeListener[]
getPropertyChangeListeners()Returns an array of all the property change listeners registered on this toolkit.public java.beans.PropertyChangeListener[] getPropertyChangeListeners()-
Returns an array of all the property change listeners registered on this toolkit. The returned array contains
PropertyChangeListenerProxy
objects that associate listeners with the names of desktop properties.- Returns:
- all of this toolkit's
PropertyChangeListener
objects wrapped injava.beans.PropertyChangeListenerProxy
objects or an empty array if no listeners are added - Since:
- 1.4
- See Also:
PropertyChangeSupport.getPropertyChangeListeners()
getPropertyChangeListeners java.beans.PropertyChangeListener[]
getPropertyChangeListeners(java.lang.String propertyName)Returns an array of all property change listeners associated with the specified name of a desktop property.public java.beans.PropertyChangeListener[] getPropertyChangeListeners(java.lang.String propertyName)-
Returns an array of all property change listeners associated with the specified name of a desktop property.
- Parameters:
propertyName
- the named property- Returns:
- all of the
PropertyChangeListener
objects associated with the specified name of a desktop property or an empty array if no such listeners are added - Since:
- 1.4
- See Also:
PropertyChangeSupport.getPropertyChangeListeners(String)
getScreenInsets Insets
getScreenInsets(GraphicsConfiguration gc)Gets the insets of the screen.-
Gets the insets of the screen.
- Parameters:
gc
- aGraphicsConfiguration
- Returns:
- the insets of this toolkit's screen, in pixels.
- Throws:
HeadlessException
- if GraphicsEnvironment.isHeadless() returns true- Since:
- 1.4
- See Also:
GraphicsEnvironment.isHeadless()
getScreenResolution abstract int
getScreenResolution()Returns the screen resolution in dots-per-inch.public abstract int getScreenResolution() throws HeadlessException-
Returns the screen resolution in dots-per-inch.
- Returns:
- this toolkit's screen resolution, in dots-per-inch.
- Throws:
HeadlessException
- if GraphicsEnvironment.isHeadless() returns true- See Also:
GraphicsEnvironment.isHeadless()
getScreenSize abstract Dimension
getScreenSize()Gets the size of the screen.-
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
andGraphicsDevice
.- Returns:
- the size of this toolkit's screen, in pixels.
- Throws:
HeadlessException
- if GraphicsEnvironment.isHeadless() returns true- See Also:
GraphicsConfiguration.getBounds()
,GraphicsDevice.getDisplayMode()
,GraphicsEnvironment.isHeadless()
getSystemClipboard abstract java.awt.datatransfer.Clipboard
getSystemClipboard()Gets the singleton instance of the system Clipboard which interfaces with clipboard facilities provided by the native platform.public abstract java.awt.datatransfer.Clipboard getSystemClipboard() throws HeadlessException-
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'sgetTransferData()
method is available in the following flavors:- DataFlavor.stringFlavor
- DataFlavor.plainTextFlavor (deprecated)
java.awt.datatransfer.StringSelection
, if the requested flavor isDataFlavor.plainTextFlavor
, or an equivalent flavor, a Reader is returned. Note: The behavior of the system Clipboard'sgetTransferData()
method forDataFlavor.plainTextFlavor
, and equivalent DataFlavors, is inconsistent with the definition ofDataFlavor.plainTextFlavor
. Because of this, support forDataFlavor.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 ofcheckSystemClipboardAccess
is used (that is, that method is not overriden), then this results in a call to the security manager'scheckPermission
method with anAWTPermission("accessClipboard")
permission.- Returns:
- the system Clipboard
- Throws:
HeadlessException
- if GraphicsEnvironment.isHeadless() returns true- Since:
- JDK1.1
- See Also:
GraphicsEnvironment.isHeadless()
,Clipboard
,StringSelection
,DataFlavor.stringFlavor
,DataFlavor.plainTextFlavor
,Reader
,AWTPermission
getSystemEventQueue EventQueue
getSystemEventQueue()Get the application's or applet's EventQueue instance.public final EventQueue getSystemEventQueue()-
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 ofcheckAwtEventQueueAccess
is used (that is, that method is not overriden), then this results in a call to the security manager'scheckPermission
method with anAWTPermission("accessEventQueue")
permission.- Returns:
- the
EventQueue
object - Throws:
java.lang.SecurityException
- if a security manager exists and its
method denies access to theSecurityManager.checkAwtEventQueueAccess()
EventQueue
- See Also:
AWTPermission
getSystemEventQueueImpl protected abstract EventQueue
getSystemEventQueueImpl()Gets the application's or applet'sEventQueue
instance, without checking access.protected abstract EventQueue getSystemEventQueueImpl()-
Gets the application's or applet's
EventQueue
instance, without checking access. For security reasons, this can only be called from aToolkit
subclass.- Returns:
- the
EventQueue
object
getSystemSelection java.awt.datatransfer.Clipboard
getSystemSelection()Gets the singleton instance of the system selection as aClipboard
object.public java.awt.datatransfer.Clipboard getSystemSelection() throws HeadlessException-
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 allComponent
s which support text selection, and, betweenFOCUS_GAINED
andFOCUS_LOST
events delivered to thatComponent
, updating the system selectionClipboard
when the selection changes inside theComponent
. 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 thatjava.awt.TextComponent
andjavax.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 returnnull
. In such a case, an application is absolved from its responsibility to update the system selectionClipboard
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 theSecurityManager
'scheckSystemClipboardAccess
method to ensure that client code has access the system selection. If the default implementation ofcheckSystemClipboardAccess
is used (that is, if the method is not overridden), then this results in a call to theSecurityManager
'scheckPermission
method with anAWTPermission("accessClipboard")
permission.- Returns:
- the system selection as a
Clipboard
, ornull
if the native platform does not support a system selectionClipboard
- Throws:
HeadlessException
- if GraphicsEnvironment.isHeadless() returns true- Since:
- 1.4
- See Also:
Clipboard
,FocusListener
,FocusEvent.FOCUS_GAINED
,FocusEvent.FOCUS_LOST
,TextComponent
,JTextComponent
,AWTPermission
,GraphicsEnvironment.isHeadless()
initializeDesktopProperties protected void
initializeDesktopProperties()initializeDesktopPropertiesprotected void initializeDesktopProperties()-
initializeDesktopProperties
isAlwaysOnTopSupported boolean
isAlwaysOnTopSupported()Returns whether the always-on-top mode is supported by this toolkit.public boolean isAlwaysOnTopSupported()-
Returns whether the always-on-top mode is supported by this toolkit. To detect whether the always-on-top mode is supported for a particular Window, use
Window.isAlwaysOnTopSupported()
.- Returns:
true
, if current toolkit supports the always-on-top mode, otherwise returnsfalse
- Since:
- 1.6
- See Also:
Window.isAlwaysOnTopSupported()
,Window.setAlwaysOnTop(boolean)
isDynamicLayoutActive boolean
isDynamicLayoutActive()Returns whether dynamic layout of Containers on resize is currently active (both set in program (isDynamicLayoutSet()
) , and supported by the underlying operating system and/or window manager).public boolean isDynamicLayoutActive() throws HeadlessException-
Returns whether dynamic layout of Containers on resize is currently active (both set in program (
isDynamicLayoutSet()
) , and supported by the underlying operating system and/or window manager). If dynamic layout is currently inactive then Containers re-layout their components when resizing is completed. As a result theComponent.validate()
method will be invoked only once per resize. If dynamic layout is currently active then Containers re-layout their components on every native resize event and thevalidate()
method will be invoked each time. The OS/WM support can be queried using the getDesktopProperty("awt.dynamicLayoutSupported") method.- Returns:
- true if dynamic layout of Containers on resize is currently active, false otherwise.
- Throws:
HeadlessException
- if the GraphicsEnvironment.isHeadless() method returns true- Since:
- 1.4
- See Also:
setDynamicLayout(boolean dynamic)
,isDynamicLayoutSet()
,getDesktopProperty(String propertyName)
,GraphicsEnvironment.isHeadless()
isDynamicLayoutSet protected boolean
isDynamicLayoutSet()Returns whether the layout of Containers is validated dynamically during resizing, or statically, after resizing is complete.protected boolean isDynamicLayoutSet() throws HeadlessException-
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").
- Returns:
- true if validation of Containers is done dynamically, false if validation is done after resizing is finished.
- Throws:
HeadlessException
- if GraphicsEnvironment.isHeadless() returns true- Since:
- 1.4
- See Also:
setDynamicLayout(boolean dynamic)
,isDynamicLayoutActive()
,getDesktopProperty(String propertyName)
,GraphicsEnvironment.isHeadless()
isFrameStateSupported boolean
isFrameStateSupported(int state)Returns whether Toolkit supports this state forFrame
s.public boolean isFrameStateSupported(int state) throws HeadlessException-
Returns whether Toolkit supports this state for
Frame
s. This method tells whether the UI concept of, say, maximization or iconification is supported. It will always return false for "compound" states likeFrame.ICONIFIED|Frame.MAXIMIZED_VERT
. In other words, the rule of thumb is that only queries with a single frame state constant as an argument are meaningful.Note that supporting a given concept is a platform- dependent feature. Due to native limitations the Toolkit object may report a particular state as supported, however at the same time the Toolkit object will be unable to apply the state to a given frame. This circumstance has two following consequences:
- Only the return value of
false
for the present method actually indicates that the given state is not supported. If the method returnstrue
the given state may still be unsupported and/or unavailable for a particular frame. - The developer should consider examining the value of the
WindowEvent.getNewState()
method of theWindowEvent
received through theWindowStateListener
, rather than assuming that the state given to thesetExtendedState()
method will be definitely applied. For more information see the documentation for theFrame.setExtendedState(int)
method.
- Parameters:
state
- one of named frame state constants.- Returns:
true
is this frame state is supported by this Toolkit implementation,false
otherwise.- Throws:
HeadlessException
- ifGraphicsEnvironment.isHeadless()
returnstrue
.- Since:
- 1.4
- See Also:
Window.addWindowStateListener(java.awt.event.WindowStateListener)
- Only the return value of
isModalExclusionTypeSupported abstract boolean
isModalExclusionTypeSupported(Dialog.ModalExclusionType modalExclusionType)Returns whether the given modal exclusion type is supported by this toolkit.public abstract boolean isModalExclusionTypeSupported(Dialog.ModalExclusionType modalExclusionType)-
Returns whether the given modal exclusion type is supported by this toolkit. If an unsupported modal exclusion type property is set on a window, then
Dialog.ModalExclusionType.NO_EXCLUDE
is used instead.- Parameters:
modalExclusionType
- modal exclusion type to be checked for support by this toolkit- Returns:
true
, if current toolkit supports given modal exclusion type,false
otherwise- Since:
- 1.6
- See Also:
Dialog.ModalExclusionType
,Window.getModalExclusionType()
,Window.setModalExclusionType(java.awt.Dialog.ModalExclusionType)
isModalityTypeSupported abstract boolean
isModalityTypeSupported(Dialog.ModalityType modalityType)Returns whether the given modality type is supported by this toolkit.public abstract boolean isModalityTypeSupported(Dialog.ModalityType modalityType)-
Returns whether the given modality type is supported by this toolkit. If a dialog with unsupported modality type is created, then
Dialog.ModalityType.MODELESS
is used instead.- Parameters:
modalityType
- modality type to be checked for support by this toolkit- Returns:
true
, if current toolkit supports given modality type,false
otherwise- Since:
- 1.6
- See Also:
Dialog.ModalityType
,Dialog.getModalityType()
,Dialog.setModalityType(java.awt.Dialog.ModalityType)
lazilyLoadDesktopProperty protected java.lang.Object
lazilyLoadDesktopProperty(java.lang.String name)an opportunity to lazily evaluate desktop property values.protected java.lang.Object lazilyLoadDesktopProperty(java.lang.String name)-
an opportunity to lazily evaluate desktop property values.
loadSystemColors protected void
loadSystemColors(int[] systemColors)Fills in the integer array that is supplied as an argument with the current system color values.protected void loadSystemColors(int[] systemColors) throws HeadlessException-
Fills in the integer array that is supplied as an argument with the current system color values.
- Parameters:
systemColors
- an integer array.- Throws:
HeadlessException
- if GraphicsEnvironment.isHeadless() returns true- Since:
- JDK1.1
- See Also:
GraphicsEnvironment.isHeadless()
mapInputMethodHighlight abstract java.util.Map<java.awt.font.TextAttribute,?>
mapInputMethodHighlight(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.public abstract java.util.Map<java.awt.font.TextAttribute,?> mapInputMethodHighlight(java.awt.im.InputMethodHighlight highlight) throws HeadlessException-
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.
- Parameters:
highlight
- input method highlight- Returns:
- style attribute map, or
null
- Throws:
HeadlessException
- ifGraphicsEnvironment.isHeadless
returns true- Since:
- 1.3
- See Also:
GraphicsEnvironment.isHeadless()
prepareImage abstract boolean
prepareImage(Image image, int width, int height, java.awt.image.ImageObserver observer)Prepares an image for rendering.public abstract boolean prepareImage(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.- Parameters:
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
- theImageObserver
object to be notified as the image is being prepared.- Returns:
true
if the image has already been fully prepared;false
otherwise.- See Also:
Component.prepareImage(java.awt.Image, java.awt.image.ImageObserver)
,Component.prepareImage(java.awt.Image, int, int, java.awt.image.ImageObserver)
,ImageObserver
removeAWTEventListener void
removeAWTEventListener(AWTEventListener listener)Removes an AWTEventListener from receiving dispatched AWTEvents.public void removeAWTEventListener(AWTEventListener listener)-
Removes an AWTEventListener from receiving dispatched AWTEvents.
First, if there is a security manager, its
checkPermission
method is called with anAWTPermission("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.
- Parameters:
listener
- the event listener.- Throws:
java.lang.SecurityException
- if a security manager exists and itscheckPermission
method doesn't allow the operation.- Since:
- 1.2
- See Also:
addAWTEventListener(java.awt.event.AWTEventListener, long)
,getAWTEventListeners()
,SecurityManager.checkPermission(java.security.Permission)
,AWTEvent
,AWTPermission
,AWTEventListener
,AWTEventListenerProxy
removePropertyChangeListener void
removePropertyChangeListener(java.lang.String name, java.beans.PropertyChangeListener pcl)Removes the specified property change listener for the named desktop property.public void removePropertyChangeListener(java.lang.String name, java.beans.PropertyChangeListener pcl)-
Removes the specified property change listener for the named desktop property. When a
PropertyChangeListenerProxy
object is removed, its property name is ignored, and the wrapped listener is removed. Ifname
isnull
orpcl
isnull
, no exception is thrown and no action is performed.- Parameters:
name
- The name of the property to removepcl
- The property change listener- Since:
- 1.2
- See Also:
PropertyChangeSupport.removePropertyChangeListener(String, PropertyChangeListener)
setDesktopProperty protected void
setDesktopProperty(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.protected final void setDesktopProperty(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.
setDynamicLayout void
setDynamicLayout(boolean dynamic)Controls whether the layout of Containers is validated dynamically during resizing, or statically, after resizing is complete.public void setDynamicLayout(boolean dynamic) throws HeadlessException-
Controls whether the layout of Containers is validated dynamically during resizing, or statically, after resizing is complete. Use
isDynamicLayoutActive()
to detect if this feature enabled in this program and is supported by this operating system and/or window manager. Note that this feature is supported not on all platforms, and conversely, that this feature cannot be turned off on some platforms. On these platforms where dynamic layout during resizing is not supported (or is always supported), setting this property has no effect. Note that this feature can be set or unset as a property of the operating system or window manager on some platforms. On such platforms, the dynamic resize property must be set at the operating system or window manager level before this method can take effect. This method does not change support or settings of the underlying operating system or window manager. The OS/WM support can be queried using getDesktopProperty("awt.dynamicLayoutSupported") method.- Parameters:
dynamic
- If true, Containers should re-layout their components as the Container is being resized. If false, the layout will be validated after resizing is completed.- Throws:
HeadlessException
- if GraphicsEnvironment.isHeadless() returns true- Since:
- 1.4
- See Also:
isDynamicLayoutSet()
,isDynamicLayoutActive()
,getDesktopProperty(String propertyName)
,GraphicsEnvironment.isHeadless()
setLockingKeyState void
setLockingKeyState(int keyCode, boolean on)Sets the state of the given locking key on the keyboard.public void setLockingKeyState(int keyCode, boolean on) throws java.lang.UnsupportedOperationException-
Sets the state of the given locking key on the keyboard. Valid key codes are
VK_CAPS_LOCK
,VK_NUM_LOCK
,VK_SCROLL_LOCK
, andVK_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.
- Throws:
java.lang.IllegalArgumentException
- ifkeyCode
is not one of the valid key codesjava.lang.UnsupportedOperationException
- if the host system doesn't allow setting the state of this key programmatically, or if the keyboard doesn't have this keyHeadlessException
- if GraphicsEnvironment.isHeadless() returns true- Since:
- 1.3
- See Also:
GraphicsEnvironment.isHeadless()
sync abstract void
sync()Synchronizes this toolkit's graphics state.public abstract void sync()-
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.
-