Method from java.awt.Toolkit Detail: |
public void addAWTEventListener(AWTEventListener listener,
long eventMask) {
AWTEventListener localL = deProxyAWTEventListener(listener);
if (localL == null) {
return;
}
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkPermission(SecurityConstants.AWT.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.
}
}
}
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. |
public void addPropertyChangeListener(String name,
PropertyChangeListener pcl) {
desktopPropsSupport.addPropertyChangeListener(name, pcl);
}
Adds the specified property change listener for the named desktop
property. When a java.beans.PropertyChangeListenerProxy object is added,
its property name is ignored, and the wrapped listener is added.
If {@code name} is {@code null} or {@code pcl} is {@code null},
no exception is thrown and no action is performed. |
public boolean areExtraMouseButtonsEnabled() throws HeadlessException {
GraphicsEnvironment.checkHeadless();
return Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled();
}
Reports whether events from extra mouse buttons are allowed to be processed and posted into
{@code EventQueue}.
To change the returned value it is necessary to set the {@code sun.awt.enableExtraMouseButtons}
property before the {@code Toolkit} 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 the {@code Toolkit} class initialization.
If not set by the time of the {@code Toolkit} class initialization, this property will be
initialized with {@code true}.
Changing this value after the {@code Toolkit} class initialization will have no effect.
|
abstract public void beep()
|
abstract public int checkImage(Image image,
int width,
int height,
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. |
synchronized int countAWTEventListeners(long eventMask) {
if (log.isLoggable(PlatformLogger.FINE)) {
if (eventMask == 0) {
log.fine("Assertion (eventMask != 0) failed");
}
}
int ci = 0;
for (; eventMask != 0; eventMask > > >= 1, ci++) {
}
ci--;
return calls[ci];
}
|
abstract protected ButtonPeer createButton(Button target) throws HeadlessException
Creates this toolkit's implementation of Button using
the specified peer interface. |
abstract protected CanvasPeer createCanvas(Canvas target)
Creates this toolkit's implementation of Canvas using
the specified peer interface. |
abstract protected CheckboxPeer createCheckbox(Checkbox target) throws HeadlessException
Creates this toolkit's implementation of Checkbox using
the specified peer interface. |
abstract protected CheckboxMenuItemPeer createCheckboxMenuItem(CheckboxMenuItem target) throws HeadlessException
Creates this toolkit's implementation of CheckboxMenuItem using
the specified peer interface. |
abstract protected ChoicePeer createChoice(Choice target) throws HeadlessException
Creates this toolkit's implementation of Choice using
the specified peer interface. |
protected LightweightPeer createComponent(Component target) {
if (lightweightMarker == null) {
lightweightMarker = new NullComponentPeer();
}
return lightweightMarker;
}
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. |
public Cursor createCustomCursor(Image cursor,
Point hotSpot,
String name) throws IndexOutOfBoundsException, HeadlessException {
// Override to implement custom cursor support.
if (this != Toolkit.getDefaultToolkit()) {
return Toolkit.getDefaultToolkit().
createCustomCursor(cursor, hotSpot, name);
} else {
return new Cursor(Cursor.DEFAULT_CURSOR);
}
}
|
abstract protected DesktopPeer createDesktopPeer(Desktop target) throws HeadlessException
Creates this toolkit's implementation of the Desktop
using the specified peer interface. |
abstract protected DialogPeer createDialog(Dialog target) throws HeadlessException
Creates this toolkit's implementation of Dialog using
the specified peer interface. |
public T createDragGestureRecognizer(Class<T> abstractRecognizerClass,
DragSource ds,
Component c,
int srcActions,
DragGestureListener dgl) {
return null;
}
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 |
abstract public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException
Creates the peer for a DragSourceContext.
Always throws InvalidDndOperationException if
GraphicsEnvironment.isHeadless() returns true. |
abstract protected FileDialogPeer createFileDialog(FileDialog target) throws HeadlessException
Creates this toolkit's implementation of FileDialog using
the specified peer interface. |
abstract protected FramePeer createFrame(Frame target) throws HeadlessException
Creates this toolkit's implementation of Frame using
the specified peer interface. |
abstract public Image createImage(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. |
abstract public Image createImage(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 with
FilePermission or SocketPermission ,
the method throws SecurityException
if the corresponding 1.1-style SecurityManager.checkXXX method
also denies permission. |
abstract public Image createImage(ImageProducer producer)
Creates an image with the specified image producer. |
public Image createImage(byte[] imagedata) {
return createImage(imagedata, 0, imagedata.length);
}
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. |
abstract public 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. |
abstract protected LabelPeer createLabel(Label target) throws HeadlessException
Creates this toolkit's implementation of Label using
the specified peer interface. |
abstract protected ListPeer createList(List target) throws HeadlessException
Creates this toolkit's implementation of List using
the specified peer interface. |
abstract protected MenuPeer createMenu(Menu target) throws HeadlessException
Creates this toolkit's implementation of Menu using
the specified peer interface. |
abstract protected MenuBarPeer createMenuBar(MenuBar target) throws HeadlessException
Creates this toolkit's implementation of MenuBar using
the specified peer interface. |
abstract protected MenuItemPeer createMenuItem(MenuItem target) throws HeadlessException
Creates this toolkit's implementation of MenuItem using
the specified peer interface. |
abstract protected PanelPeer createPanel(Panel target)
Creates this toolkit's implementation of Panel using
the specified peer interface. |
abstract protected PopupMenuPeer createPopupMenu(PopupMenu target) throws HeadlessException
Creates this toolkit's implementation of PopupMenu using
the specified peer interface. |
abstract protected ScrollPanePeer createScrollPane(ScrollPane target) throws HeadlessException
Creates this toolkit's implementation of ScrollPane using
the specified peer interface. |
abstract protected ScrollbarPeer createScrollbar(Scrollbar target) throws HeadlessException
Creates this toolkit's implementation of Scrollbar using
the specified peer interface. |
abstract protected TextAreaPeer createTextArea(TextArea target) throws HeadlessException
Creates this toolkit's implementation of TextArea using
the specified peer interface. |
abstract protected TextFieldPeer createTextField(TextField target) throws HeadlessException
Creates this toolkit's implementation of TextField using
the specified peer interface. |
abstract protected WindowPeer createWindow(Window target) throws HeadlessException
Creates this toolkit's implementation of Window using
the specified peer interface. |
static boolean enabledOnToolkit(long eventMask) {
return (enabledOnToolkitMask & eventMask) != 0;
}
|
public AWTEventListener[] getAWTEventListeners() {
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkPermission(SecurityConstants.AWT.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;
}
}
Returns an array of all the AWTEventListener s
registered on this toolkit.
If there is a security manager, its {@code checkPermission}
method is called with an
{@code AWTPermission("listenToAllAWTEvents")} permission.
This may result in a SecurityException.
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. |
public AWTEventListener[] getAWTEventListeners(long eventMask) {
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkPermission(SecurityConstants.AWT.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]);
}
}
Returns an array of all the AWTEventListener s
registered on this toolkit which listen to all of the event
types specified in the {@code eventMask} argument.
If there is a security manager, its {@code checkPermission}
method is called with an
{@code AWTPermission("listenToAllAWTEvents")} permission.
This may result in a SecurityException.
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. |
public Dimension getBestCursorSize(int preferredWidth,
int preferredHeight) throws HeadlessException {
GraphicsEnvironment.checkHeadless();
// Override to implement custom cursor support.
if (this != Toolkit.getDefaultToolkit()) {
return Toolkit.getDefaultToolkit().
getBestCursorSize(preferredWidth, preferredHeight);
} else {
return new Dimension(0, 0);
}
}
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. |
abstract public 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 the Component class. |
public static synchronized Toolkit getDefaultToolkit() {
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 {
nm = System.getProperty("awt.toolkit");
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;
}
Gets the default toolkit.
If a system property named "java.awt.headless" is set
to true then the headless implementation
of Toolkit is used.
If there is no "java.awt.headless" or it is set to
false and there is a system property named
"awt.toolkit" ,
that property is treated as the name of a class that is a subclass
of Toolkit ;
otherwise the default platform-specific implementation of
Toolkit 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. |
public final synchronized Object getDesktopProperty(String propertyName) {
// 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);
}
}
/* for property "awt.font.desktophints" */
if (value instanceof RenderingHints) {
value = ((RenderingHints)value).clone();
}
return value;
}
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. |
static EventQueue getEventQueue() {
return getDefaultToolkit().getSystemEventQueueImpl();
}
|
abstract public String[] getFontList()Deprecated! see - java.awt.GraphicsEnvironment#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. |
abstract public FontMetrics getFontMetrics(Font font)Deprecated! As - of JDK version 1.2, replaced by the Font
method getLineMetrics .
Gets the screen device metrics for rendering of the font. |
abstract protected FontPeer getFontPeer(String name,
int style)Deprecated! see - java.awt.GraphicsEnvironment#getAllFonts
Creates this toolkit's implementation of Font using
the specified peer interface. |
abstract public Image getImage(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 the createImage
variant wherever available.
If the image data contained in the specified file changes,
the Image 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 the flush method on the
returned Image .
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. |
abstract public Image getImage(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 the createImage
variant wherever available.
If the image data stored at the specified URL changes,
the Image 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 the flush method on the
returned Image .
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 with
FilePermission or SocketPermission ,
the method throws the SecurityException
if the corresponding 1.1-style SecurityManager.checkXXX method
also denies permission. |
public boolean getLockingKeyState(int keyCode) throws UnsupportedOperationException {
GraphicsEnvironment.checkHeadless();
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 int getMaximumCursorColors() throws HeadlessException {
GraphicsEnvironment.checkHeadless();
// Override to implement custom cursor support.
if (this != Toolkit.getDefaultToolkit()) {
return Toolkit.getDefaultToolkit().getMaximumCursorColors();
} else {
return 0;
}
}
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. |
public int getMenuShortcutKeyMask() throws HeadlessException {
GraphicsEnvironment.checkHeadless();
return Event.CTRL_MASK;
}
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. |
protected MouseInfoPeer getMouseInfoPeer() {
throw new UnsupportedOperationException("Not implemented");
}
Obtains this toolkit's implementation of helper class for
MouseInfo operations. |
protected static Container getNativeContainer(Component c) {
return c.getNativeContainer();
}
Give native peers the ability to query the native container
given a native component (eg the direct parent may be lightweight). |
abstract public PrintJob getPrintJob(Frame frame,
String jobtitle,
Properties props)
Gets a PrintJob object which is the result of initiating
a print operation on the toolkit's platform.
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. |
public PrintJob getPrintJob(Frame frame,
String jobtitle,
JobAttributes jobAttributes,
PageAttributes pageAttributes) {
// Override to add printing support with new job/page control classes
if (this != Toolkit.getDefaultToolkit()) {
return Toolkit.getDefaultToolkit().getPrintJob(frame, jobtitle,
jobAttributes,
pageAttributes);
} else {
return getPrintJob(frame, jobtitle, null);
}
}
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. |
public static String getProperty(String key,
String defaultValue) {
if (resources != null) {
try {
return resources.getString(key);
}
catch (MissingResourceException e) {}
}
return defaultValue;
}
Gets a property with the specified key and default.
This method returns defaultValue if the property is not found. |
public PropertyChangeListener[] getPropertyChangeListeners() {
return desktopPropsSupport.getPropertyChangeListeners();
}
Returns an array of all the property change listeners
registered on this toolkit. The returned array
contains java.beans.PropertyChangeListenerProxy objects
that associate listeners with the names of desktop properties. |
public PropertyChangeListener[] getPropertyChangeListeners(String propertyName) {
return desktopPropsSupport.getPropertyChangeListeners(propertyName);
}
Returns an array of all property change listeners
associated with the specified name of a desktop property. |
public Insets getScreenInsets(GraphicsConfiguration gc) throws HeadlessException {
GraphicsEnvironment.checkHeadless();
if (this != Toolkit.getDefaultToolkit()) {
return Toolkit.getDefaultToolkit().getScreenInsets(gc);
} else {
return new Insets(0, 0, 0, 0);
}
}
Gets the insets of the screen. |
abstract public int getScreenResolution() throws HeadlessException
Returns the screen resolution in dots-per-inch. |
abstract public Dimension getScreenSize() throws HeadlessException
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 . |
abstract public 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'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. |
public final EventQueue getSystemEventQueue() {
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkAwtEventQueueAccess();
}
return getSystemEventQueueImpl();
}
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. |
abstract protected EventQueue getSystemEventQueueImpl()
Gets the application's or applet's EventQueue
instance, without checking access. For security reasons,
this can only be called from a Toolkit subclass. |
public Clipboard getSystemSelection() throws HeadlessException {
GraphicsEnvironment.checkHeadless();
if (this != Toolkit.getDefaultToolkit()) {
return Toolkit.getDefaultToolkit().getSystemSelection();
} else {
GraphicsEnvironment.checkHeadless();
return null;
}
}
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 Component s 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. |
protected void initializeDesktopProperties() {
}
initializeDesktopProperties |
public boolean isAlwaysOnTopSupported() {
return true;
}
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 . |
public boolean isDynamicLayoutActive() throws HeadlessException {
GraphicsEnvironment.checkHeadless();
if (this != Toolkit.getDefaultToolkit()) {
return Toolkit.getDefaultToolkit().isDynamicLayoutActive();
} else {
return false;
}
}
Returns whether dynamic layout of Containers on resize is
currently active (both set in program
( {@code 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
the {@code Component.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
the {@code validate()} method will be invoked each time.
The OS/WM support can be queried using
the getDesktopProperty("awt.dynamicLayoutSupported") method. |
protected boolean isDynamicLayoutSet() throws HeadlessException {
GraphicsEnvironment.checkHeadless();
if (this != Toolkit.getDefaultToolkit()) {
return Toolkit.getDefaultToolkit().isDynamicLayoutSet();
} else {
return false;
}
}
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"). |
public boolean isFrameStateSupported(int state) throws HeadlessException {
GraphicsEnvironment.checkHeadless();
if (this != Toolkit.getDefaultToolkit()) {
return Toolkit.getDefaultToolkit().
isFrameStateSupported(state);
} else {
return (state == Frame.NORMAL); // others are not guaranteed
}
}
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
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.
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 {@code false} for the present
method actually indicates that the given state is not
supported. If the method returns {@code true} the given state
may still be unsupported and/or unavailable for a particular
frame.
- The developer should consider examining the value of the
java.awt.event.WindowEvent#getNewState method of the
{@code WindowEvent} received through the java.awt.event.WindowStateListener , rather than assuming
that the state given to the {@code setExtendedState()} method
will be definitely applied. For more information see the
documentation for the Frame#setExtendedState method.
|
abstract public boolean isModalExclusionTypeSupported(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. |
abstract public boolean isModalityTypeSupported(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. |
protected Object lazilyLoadDesktopProperty(String name) {
return null;
}
an opportunity to lazily evaluate desktop property values. |
static void loadLibraries() {
if (!loaded) {
java.security.AccessController.doPrivileged(
new sun.security.action.LoadLibraryAction("awt"));
loaded = true;
}
}
|
protected void loadSystemColors(int[] systemColors) throws HeadlessException {
GraphicsEnvironment.checkHeadless();
}
Fills in the integer array that is supplied as an argument
with the current system color values. |
abstract public Map<TextAttribute, ?> mapInputMethodHighlight(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. |
void notifyAWTEventListeners(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);
}
}
|
abstract public boolean prepareImage(Image image,
int width,
int height,
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. |
public void removeAWTEventListener(AWTEventListener listener) {
AWTEventListener localL = deProxyAWTEventListener(listener);
if (listener == null) {
return;
}
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkPermission(SecurityConstants.AWT.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);
}
}
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. |
public void removePropertyChangeListener(String name,
PropertyChangeListener pcl) {
desktopPropsSupport.removePropertyChangeListener(name, pcl);
}
Removes the specified property change listener for the named
desktop property. When a java.beans.PropertyChangeListenerProxy object
is removed, its property name is ignored, and
the wrapped listener is removed.
If {@code name} is {@code null} or {@code pcl} is {@code null},
no exception is thrown and no action is performed. |
protected final void setDesktopProperty(String name,
Object newValue) {
// 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);
}
// Don't fire change event if old and new values are null.
// It helps to avoid recursive resending of WM_THEMECHANGED
if (oldValue != null || newValue != null) {
desktopPropsSupport.firePropertyChange(name, oldValue, 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. |
public void setDynamicLayout(boolean dynamic) throws HeadlessException {
GraphicsEnvironment.checkHeadless();
}
Controls whether the layout of Containers is validated dynamically
during resizing, or statically, after resizing is complete.
Use {@code 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. |
public void setLockingKeyState(int keyCode,
boolean on) throws UnsupportedOperationException {
GraphicsEnvironment.checkHeadless();
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");
}
Sets the state of the given locking key on the keyboard.
Valid key codes are
VK_CAPS_LOCK ,
VK_NUM_LOCK ,
VK_SCROLL_LOCK , and
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. |
abstract public void sync()
|