Toolkit.java revision 3949
3763N/A * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * This class is the abstract superclass of all actual 0N/A * implementations of the Abstract Window Toolkit. Subclasses of 0N/A * the <code>Toolkit</code> class are used to bind the various components 0N/A * to particular native toolkit implementations. 0N/A * Many GUI events may be delivered to user 0N/A * asynchronously, if the opposite is not specified explicitly. 0N/A * many GUI operations may be performed asynchronously. 0N/A * This fact means that if the state of a component is set, and then 0N/A * the state immediately queried, the returned value may not yet 7N/A * reflect the requested change. This behavior includes, but is not 0N/A * <li>Scrolling to a specified position. 0N/A * <br>For example, calling <code>ScrollPane.setScrollPosition</code> 0N/A * and then <code>getScrollPosition</code> may return an incorrect 7N/A * value if the original request has not yet been processed. 0N/A * <li>Moving the focus from one component to another. 3142N/A * <br>For more information, see 3142N/A * Focus Transfers</a>, a section in 3142N/A * <li>Making a top-level container visible. 3142N/A * <br>Calling <code>setVisible(true)</code> on a <code>Window</code>, 3142N/A * <code>Frame</code> or <code>Dialog</code> may occur 3142N/A * <li>Setting the size or location of a top-level container. 3142N/A * <br>Calls to <code>setSize</code>, <code>setBounds</code> or 0N/A * <code>setLocation</code> on a <code>Window</code>, 0N/A * <code>Frame</code> or <code>Dialog</code> are forwarded 0N/A * to the underlying window management system and may be 0N/A * ignored or modified. See {@link java.awt.Window} for 0N/A * Most applications should not call any of the methods in this 0N/A * class directly. The methods defined by <code>Toolkit</code> are 0N/A * the "glue" that joins the platform-independent classes in the 0N/A * <code>java.awt</code> package with their counterparts in 0N/A * <code>java.awt.peer</code>. Some methods defined by 0N/A * <code>Toolkit</code> query the native operating system directly. 0N/A * @author Sami Shaio 0N/A * @author Arthur van Hoff 3867N/A * Creates this toolkit's implementation of the <code>Desktop</code> 3867N/A * using the specified peer interface. 3867N/A * @param target the desktop to be implemented 3867N/A * @return this toolkit's implementation of the <code>Desktop</code> 3767N/A * @exception HeadlessException if GraphicsEnvironment.isHeadless() 3767N/A * @see java.awt.GraphicsEnvironment#isHeadless 3767N/A * @see java.awt.peer.DesktopPeer 3767N/A * Creates this toolkit's implementation of <code>Button</code> using 3767N/A * the specified peer interface. 3767N/A * @param target the button to be implemented. 3767N/A * @return this toolkit's implementation of <code>Button</code>. 3767N/A * @exception HeadlessException if GraphicsEnvironment.isHeadless() 3767N/A * @see java.awt.GraphicsEnvironment#isHeadless 3767N/A * @see java.awt.peer.ButtonPeer 3763N/A * Creates this toolkit's implementation of <code>TextField</code> using 3763N/A * the specified peer interface. 0N/A * @param target the text field to be implemented. 0N/A * @return this toolkit's implementation of <code>TextField</code>. 0N/A * @exception HeadlessException if GraphicsEnvironment.isHeadless() 0N/A * @see java.awt.GraphicsEnvironment#isHeadless 0N/A * @see java.awt.TextField 0N/A * @see java.awt.peer.TextFieldPeer 0N/A * Creates this toolkit's implementation of <code>Label</code> using 0N/A * the specified peer interface. 0N/A * @param target the label to be implemented. 0N/A * @return this toolkit's implementation of <code>Label</code>. 0N/A * @exception HeadlessException if GraphicsEnvironment.isHeadless() 0N/A * @see java.awt.GraphicsEnvironment#isHeadless 0N/A * @see java.awt.Label 0N/A * @see java.awt.peer.LabelPeer 0N/A * Creates this toolkit's implementation of <code>List</code> using 0N/A * the specified peer interface. 0N/A * @param target the list to be implemented. 4632N/A * @return this toolkit's implementation of <code>List</code>. 4632N/A * @exception HeadlessException if GraphicsEnvironment.isHeadless() 0N/A * @see java.awt.GraphicsEnvironment#isHeadless 0N/A * @see java.awt.List 0N/A * @see java.awt.peer.ListPeer 4632N/A * Creates this toolkit's implementation of <code>Checkbox</code> using 0N/A * the specified peer interface. 0N/A * @param target the check box to be implemented. 0N/A * @return this toolkit's implementation of <code>Checkbox</code>. 0N/A * @exception HeadlessException if GraphicsEnvironment.isHeadless() 0N/A * @see java.awt.GraphicsEnvironment#isHeadless 0N/A * @see java.awt.Checkbox 0N/A * @see java.awt.peer.CheckboxPeer 4632N/A * Creates this toolkit's implementation of <code>Scrollbar</code> using 4632N/A * the specified peer interface. 0N/A * @param target the scroll bar to be implemented. 0N/A * @return this toolkit's implementation of <code>Scrollbar</code>. 0N/A * @exception HeadlessException if GraphicsEnvironment.isHeadless() 0N/A * @see java.awt.GraphicsEnvironment#isHeadless 1592N/A * @see java.awt.peer.ScrollbarPeer 0N/A * Creates this toolkit's implementation of <code>ScrollPane</code> using 0N/A * the specified peer interface. 3153N/A * @param target the scroll pane to be implemented. 3153N/A * @return this toolkit's implementation of <code>ScrollPane</code>. 0N/A * @exception HeadlessException if GraphicsEnvironment.isHeadless() 0N/A * @see java.awt.GraphicsEnvironment#isHeadless 0N/A * @see java.awt.ScrollPane 0N/A * @see java.awt.peer.ScrollPanePeer 0N/A * Creates this toolkit's implementation of <code>TextArea</code> using 0N/A * the specified peer interface. 0N/A * @param target the text area to be implemented. 0N/A * @return this toolkit's implementation of <code>TextArea</code>. 0N/A * @exception HeadlessException if GraphicsEnvironment.isHeadless() 0N/A * @see java.awt.GraphicsEnvironment#isHeadless 0N/A * @see java.awt.TextArea 0N/A * @see java.awt.peer.TextAreaPeer 0N/A * Creates this toolkit's implementation of <code>Choice</code> using 0N/A * the specified peer interface. 0N/A * @param target the choice to be implemented. 0N/A * @return this toolkit's implementation of <code>Choice</code>. 0N/A * @exception HeadlessException if GraphicsEnvironment.isHeadless() 0N/A * @see java.awt.GraphicsEnvironment#isHeadless 4632N/A * @see java.awt.peer.ChoicePeer 0N/A * Creates this toolkit's implementation of <code>Frame</code> using 0N/A * the specified peer interface. 0N/A * @param target the frame to be implemented. 0N/A * @return this toolkit's implementation of <code>Frame</code>. 0N/A * @exception HeadlessException if GraphicsEnvironment.isHeadless() 0N/A * @see java.awt.GraphicsEnvironment#isHeadless 0N/A * @see java.awt.Frame 0N/A * @see java.awt.peer.FramePeer 0N/A * Creates this toolkit's implementation of <code>Canvas</code> using 0N/A * the specified peer interface. 0N/A * @param target the canvas to be implemented. 0N/A * @return this toolkit's implementation of <code>Canvas</code>. 165N/A * @see java.awt.peer.CanvasPeer 0N/A * Creates this toolkit's implementation of <code>Panel</code> using 0N/A * the specified peer interface. 0N/A * @param target the panel to be implemented. 0N/A * @return this toolkit's implementation of <code>Panel</code>. 0N/A * @see java.awt.Panel 0N/A * @see java.awt.peer.PanelPeer 0N/A * Creates this toolkit's implementation of <code>Window</code> using 0N/A * the specified peer interface. 0N/A * @param target the window to be implemented. 2812N/A * @return this toolkit's implementation of <code>Window</code>. 0N/A * @exception HeadlessException if GraphicsEnvironment.isHeadless() 0N/A * @see java.awt.GraphicsEnvironment#isHeadless 0N/A * @see java.awt.Window 0N/A * @see java.awt.peer.WindowPeer 0N/A * Creates this toolkit's implementation of <code>Dialog</code> using 0N/A * the specified peer interface. 0N/A * @param target the dialog to be implemented. 0N/A * @return this toolkit's implementation of <code>Dialog</code>. 0N/A * @exception HeadlessException if GraphicsEnvironment.isHeadless() 4378N/A * @see java.awt.GraphicsEnvironment#isHeadless 4378N/A * @see java.awt.peer.DialogPeer 3378N/A * Creates this toolkit's implementation of <code>MenuBar</code> using 0N/A * the specified peer interface. 0N/A * @param target the menu bar to be implemented. 0N/A * @return this toolkit's implementation of <code>MenuBar</code>. 0N/A * @exception HeadlessException if GraphicsEnvironment.isHeadless() 0N/A * @see java.awt.GraphicsEnvironment#isHeadless 0N/A * @see java.awt.MenuBar 0N/A * @see java.awt.peer.MenuBarPeer 0N/A * Creates this toolkit's implementation of <code>Menu</code> using 0N/A * the specified peer interface. 0N/A * @param target the menu to be implemented. 0N/A * @return this toolkit's implementation of <code>Menu</code>. 0N/A * @exception HeadlessException if GraphicsEnvironment.isHeadless() 0N/A * @see java.awt.GraphicsEnvironment#isHeadless 0N/A * @see java.awt.Menu 0N/A * @see java.awt.peer.MenuPeer 0N/A * Creates this toolkit's implementation of <code>PopupMenu</code> using 0N/A * the specified peer interface. 0N/A * @param target the popup menu to be implemented. 0N/A * @return this toolkit's implementation of <code>PopupMenu</code>. 0N/A * @exception HeadlessException if GraphicsEnvironment.isHeadless() 0N/A * @see java.awt.GraphicsEnvironment#isHeadless 0N/A * @see java.awt.PopupMenu 0N/A * @see java.awt.peer.PopupMenuPeer 0N/A * Creates this toolkit's implementation of <code>MenuItem</code> using 0N/A * the specified peer interface. 0N/A * @param target the menu item to be implemented. 0N/A * @return this toolkit's implementation of <code>MenuItem</code>. 0N/A * @exception HeadlessException if GraphicsEnvironment.isHeadless() 0N/A * @see java.awt.GraphicsEnvironment#isHeadless 0N/A * @see java.awt.MenuItem 0N/A * @see java.awt.peer.MenuItemPeer 0N/A * Creates this toolkit's implementation of <code>FileDialog</code> using 0N/A * the specified peer interface. 0N/A * @param target the file dialog to be implemented. 0N/A * @return this toolkit's implementation of <code>FileDialog</code>. 0N/A * @exception HeadlessException if GraphicsEnvironment.isHeadless() 0N/A * @see java.awt.GraphicsEnvironment#isHeadless 0N/A * @see java.awt.peer.FileDialogPeer 0N/A * Creates this toolkit's implementation of <code>CheckboxMenuItem</code> using 0N/A * the specified peer interface. 0N/A * @param target the checkbox menu item to be implemented. 0N/A * @return this toolkit's implementation of <code>CheckboxMenuItem</code>. 4632N/A * @exception HeadlessException if GraphicsEnvironment.isHeadless() 4632N/A * @see java.awt.GraphicsEnvironment#isHeadless 4632N/A * @see java.awt.CheckboxMenuItem 4632N/A * @see java.awt.peer.CheckboxMenuItemPeer 0N/A * Obtains this toolkit's implementation of helper class for 0N/A * <code>MouseInfo</code> operations. 0N/A * @return this toolkit's implementation of helper for <code>MouseInfo</code> 0N/A * @throws UnsupportedOperationException if this operation is not implemented 0N/A * @see java.awt.peer.MouseInfoPeer 0N/A * @see java.awt.MouseInfo 0N/A * Creates a peer for a component or container. This peer is windowless 0N/A * and allows the Component and Container classes to be extended directly 0N/A * to create windowless components that are defined entirely in java. 0N/A * @param target The Component to be created. 0N/A * Creates this toolkit's implementation of <code>Font</code> using 0N/A * the specified peer interface. 0N/A * @param name the font to be implemented 0N/A * @param style the style of the font, such as <code>PLAIN</code>, 0N/A * <code>BOLD</code>, <code>ITALIC</code>, or a combination 0N/A * @return this toolkit's implementation of <code>Font</code> 0N/A * @see java.awt.Font 0N/A * @see java.awt.peer.FontPeer 0N/A * @see java.awt.GraphicsEnvironment#getAllFonts 0N/A * @deprecated see java.awt.GraphicsEnvironment#getAllFonts 0N/A // The following method is called by the private method 0N/A // <code>updateSystemColors</code> in <code>SystemColor</code>. 0N/A * Fills in the integer array that is supplied as an argument 0N/A * with the current system color values. 0N/A * @param systemColors an integer array. 0N/A * @exception HeadlessException if GraphicsEnvironment.isHeadless() 2080N/A * @see java.awt.GraphicsEnvironment#isHeadless 2080N/A * Controls whether the layout of Containers is validated dynamically 0N/A * during resizing, or statically, after resizing is complete. 0N/A * Use {@code isDynamicLayoutActive()} to detect if this feature enabled 0N/A * in this program and is supported by this operating system 0N/A * Note that this feature is supported not on all platforms, and 0N/A * conversely, that this feature cannot be turned off on some platforms. 0N/A * On these platforms where dynamic layout during resizing is not supported 0N/A * (or is always supported), setting this property has no effect. 0N/A * Note that this feature can be set or unset as a property of the 0N/A * operating system or window manager on some platforms. On such 0N/A * platforms, the dynamic resize property must be set at the operating 0N/A * system or window manager level before this method can take effect. 0N/A * This method does not change support or settings of the underlying 2080N/A * queried using getDesktopProperty("awt.dynamicLayoutSupported") method. 2080N/A * @param dynamic If true, Containers should re-layout their 2080N/A * components as the Container is being resized. If false, 2080N/A * the layout will be validated after resizing is completed. 2080N/A * @exception HeadlessException if GraphicsEnvironment.isHeadless() 2080N/A * @see #isDynamicLayoutSet() 2080N/A * @see #isDynamicLayoutActive() 3686N/A * @see #getDesktopProperty(String propertyName) 0N/A * @see java.awt.GraphicsEnvironment#isHeadless 0N/A * Returns whether the layout of Containers is validated dynamically 0N/A * during resizing, or statically, after resizing is complete. 0N/A * Note: this method returns the value that was set programmatically; 0N/A * it does not reflect support at the level of the operating system 0N/A * or window manager for dynamic layout on resizing, or the current 0N/A * operating system or window manager settings. The OS/WM support can 0N/A * be queried using getDesktopProperty("awt.dynamicLayoutSupported"). 0N/A * @return true if validation of Containers is done dynamically, 0N/A * false if validation is done after resizing is finished. 0N/A * @exception HeadlessException if GraphicsEnvironment.isHeadless() 3767N/A * @see #setDynamicLayout(boolean dynamic) 3767N/A * @see #isDynamicLayoutActive() 0N/A * @see #getDesktopProperty(String propertyName) 3767N/A * @see java.awt.GraphicsEnvironment#isHeadless 0N/A * Returns whether dynamic layout of Containers on resize is 0N/A * currently active (both set in program 420N/A *( {@code isDynamicLayoutSet()} ) 0N/A * by the underlying operating system and/or window manager). 3698N/A * If dynamic layout is currently inactive then Containers 3698N/A * re-layout their components when resizing is completed. As a result 3698N/A * the {@code Component.validate()} method will be invoked only 0N/A * If dynamic layout is currently active then Containers 2080N/A * re-layout their components on every native resize event and 0N/A * the {@code validate()} method will be invoked each time. 536N/A * the getDesktopProperty("awt.dynamicLayoutSupported") method. 536N/A * @return true if dynamic layout of Containers on resize is 536N/A * currently active, false otherwise. 536N/A * @exception HeadlessException if the GraphicsEnvironment.isHeadless() 536N/A * @see #setDynamicLayout(boolean dynamic) 536N/A * @see #isDynamicLayoutSet() 536N/A * @see #getDesktopProperty(String propertyName) 536N/A * @see java.awt.GraphicsEnvironment#isHeadless * Gets the size of the screen. On systems with multiple displays, the * primary display is used. Multi-screen aware display dimensions are * available from <code>GraphicsConfiguration</code> and * <code>GraphicsDevice</code>. * @return the size of this toolkit's screen, in pixels. * @exception HeadlessException if GraphicsEnvironment.isHeadless() * @see java.awt.GraphicsConfiguration#getBounds * @see java.awt.GraphicsDevice#getDisplayMode * @see java.awt.GraphicsEnvironment#isHeadless * Returns the screen resolution in dots-per-inch. * @return this toolkit's screen resolution, in dots-per-inch. * @exception HeadlessException if GraphicsEnvironment.isHeadless() * @see java.awt.GraphicsEnvironment#isHeadless * Gets the insets of the screen. * @param gc a <code>GraphicsConfiguration</code> * @return the insets of this toolkit's screen, in pixels. * @exception HeadlessException if GraphicsEnvironment.isHeadless() * @see java.awt.GraphicsEnvironment#isHeadless return new Insets(
0,
0,
0,
0);
* Determines the color model of this toolkit's screen. * <code>ColorModel</code> is an abstract class that * encapsulates the ability to translate between the * pixel values of an image and its red, green, blue, * This toolkit method is called by the * <code>getColorModel</code> method * of the <code>Component</code> class. * @return the color model of this toolkit's screen. * @exception HeadlessException if GraphicsEnvironment.isHeadless() * @see java.awt.GraphicsEnvironment#isHeadless * @see java.awt.image.ColorModel * @see java.awt.Component#getColorModel * Returns the names of the available fonts in this toolkit.<p> * For 1.1, the following font names are deprecated (the replacement * <li>TimesRoman (use Serif) * <li>Helvetica (use SansSerif) * <li>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 * @return the names of the available fonts in this toolkit. * @deprecated see {@link java.awt.GraphicsEnvironment#getAvailableFontFamilyNames()} * @see java.awt.GraphicsEnvironment#getAvailableFontFamilyNames() * Gets the screen device metrics for rendering of the font. * @return the screen metrics of the specified font in this toolkit * @deprecated As of JDK version 1.2, replaced by the <code>Font</code> * method <code>getLineMetrics</code>. * @see java.awt.font.LineMetrics * @see java.awt.Font#getLineMetrics * @see java.awt.GraphicsEnvironment#getScreenDevices * 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 public abstract void sync();
* Used internally by the assistive technologies functions; set at * init time and used at load time * Initializes properties related to assistive technologies. * These properties are used both in the loadAssistiveProperties() * function below, as well as other classes in the jdk that depend * on the properties (such as the use of the screen_magnifier_present * property in Java2D hardware acceleration initialization). The * initialization of the properties must be done before the platform- * specific Toolkit class is instantiated so that all necessary * properties are set up properly before any classes dependent upon them // Get accessibility properties // Try loading the per-user accessibility properties file. // Inputstream has been buffered in Properties class // Per-user accessibility properties file does not exist // Try loading the system-wide accessibility properties // file only if a per-user accessibility properties // file does not exist or is empty. // Inputstream has been buffered in Properties class // System-wide accessibility properties file does // Get whether a screen magnifier is present. First check // the system property and then check the properties file. // Get the names of any assistive technolgies to load. First // check the system property and then check the properties * Loads additional classes into the VM, using the property * 'assistive_technologies' specified in the Sun reference * file. The form is "assistive_technologies=..." where * the "..." is a comma-separated list of assistive technology * classes to load. Each class is loaded in the order given * and a single instance of each is created using * Class.forName(class).newInstance(). All errors are handled * via an AWTError exception. * <p>The assumption is made that assistive technology classes are supplied * as part of INSTALLED (as opposed to: BUNDLED) extensions or specified * (and therefore can be loaded using the class loader returned by * a call to <code>ClassLoader.getSystemClassLoader</code>, whose * delegation parent is the extension class loader for installed // Load any assistive technologies throw new AWTError(
"Assistive Technology not found: " throw new AWTError(
"Could not instantiate Assistive" throw new AWTError(
"Could not access Assistive" throw new AWTError(
"Error trying to install Assistive" +
" Technology: " +
atName +
" " + e);
* Gets the default toolkit. * If a system property named <code>"java.awt.headless"</code> is set * to <code>true</code> then the headless implementation * of <code>Toolkit</code> is used. * If there is no <code>"java.awt.headless"</code> or it is set to * <code>false</code> and there is a system property named * <code>"awt.toolkit"</code>, * that property is treated as the name of a class that is a subclass * of <code>Toolkit</code>; * otherwise the default platform-specific implementation of * <code>Toolkit</code> is used. * Also loads additional classes into the VM, using the property * 'assistive_technologies' specified in the Sun reference * 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 * @return the default toolkit. * @exception AWTError if a toolkit could not be found, or * if one could not be accessed or instantiated. // 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. throw new AWTError(
"Could not instantiate Toolkit: " +
nm);
throw new AWTError(
"Could not access Toolkit: " +
nm);
// Make sure to always re-enable the JIT. * 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 * <code>Image</code> 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 {@link #createImage(java.lang.String) createImage} * variant wherever available. * If the image data contained in the specified file changes, * the <code>Image</code> 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 {@link Image#flush flush} method on the * returned <code>Image</code>. * This method first checks if there is a security manager installed. * If so, the method calls the security manager's * <code>checkRead</code> method with the file specified to ensure * that the access to the image is allowed. * @param filename the name of a file containing pixel data * in a recognized file format. * @return an image which gets its pixel data from * @throws SecurityException if a security manager exists and its * checkRead method doesn't allow the operation. * @see #createImage(java.lang.String) * 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 * <code>Image</code> 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 {@link #createImage(java.net.URL) createImage} * variant wherever available. * If the image data stored at the specified URL changes, * the <code>Image</code> 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 {@link Image#flush flush} method on the * returned <code>Image</code>. * This method first checks if there is a security manager installed. * If so, the method calls the security manager's * <code>checkPermission</code> 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 * <code>FilePermission</code> or <code>SocketPermission</code>, * the method throws the <code>SecurityException</code> * if the corresponding 1.1-style SecurityManager.checkXXX method * also denies permission. * @param url the URL to use in fetching the pixel data. * @return an image which gets its pixel data from * @throws SecurityException if a security manager exists and its * checkPermission method doesn't allow * @see #createImage(java.net.URL) * 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 * <code>checkRead</code> method with the specified file to ensure * that the image creation is allowed. * @param filename the name of a file containing pixel data * in a recognized file format. * @return an image which gets its pixel data from * @throws SecurityException if a security manager exists and its * checkRead method doesn't allow the operation. * @see #getImage(java.lang.String) * 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 * <code>checkPermission</code> 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 * <code>FilePermission</code> or <code>SocketPermission</code>, * the method throws <code>SecurityException</code> * if the corresponding 1.1-style SecurityManager.checkXXX method * also denies permission. * @param url the URL to use in fetching the pixel data. * @return an image which gets its pixel data from * @throws SecurityException if a security manager exists and its * checkPermission method doesn't allow * @see #getImage(java.net.URL) * Prepares an image for rendering. * If the values of the width and height arguments are both * <code>-1</code>, 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 * This method is called by components <code>prepareImage</code> * Information on the flags returned by this method can be found * with the definition of the <code>ImageObserver</code> interface. * @param image the image for which to prepare a * @param width the width of the desired screen * representation, or <code>-1</code>. * @param height the height of the desired screen * representation, or <code>-1</code>. * @param observer the <code>ImageObserver</code> * object to be notified as the * image is being prepared. * @return <code>true</code> if the image has already been * fully prepared; <code>false</code> otherwise. * @see java.awt.Component#prepareImage(java.awt.Image, * java.awt.image.ImageObserver) * @see java.awt.Component#prepareImage(java.awt.Image, * int, int, java.awt.image.ImageObserver) * @see java.awt.image.ImageObserver * 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 * <code>-1</code>, 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 * This method does not cause the image to begin loading. * An application must call <code>prepareImage</code> to force * the loading of an image. * This method is called by the component's <code>checkImage</code> * Information on the flags returned by this method can be found * with the definition of the <code>ImageObserver</code> interface. * @param image the image whose status is being checked. * @param width the width of the scaled version whose status is * being checked, or <code>-1</code>. * @param height the height of the scaled version whose status * is being checked, or <code>-1</code>. * @param observer the <code>ImageObserver</code> object to be * notified as the image is being prepared. * @return the bitwise inclusive <strong>OR</strong> of the * <code>ImageObserver</code> flags for the * image data that is currently available. * @see java.awt.Toolkit#prepareImage(java.awt.Image, * int, int, java.awt.image.ImageObserver) * @see java.awt.Component#checkImage(java.awt.Image, * java.awt.image.ImageObserver) * @see java.awt.Component#checkImage(java.awt.Image, * int, int, java.awt.image.ImageObserver) * @see java.awt.image.ImageObserver * Creates an image with the specified image producer. * @param producer the image producer to be used. * @return an image with the specified image producer. * @see java.awt.image.ImageProducer * @see java.awt.Component#createImage(java.awt.image.ImageProducer) * Creates an image which decodes the image stored in the specified * The data must be in some image format, such as GIF or JPEG, * that is supported by this toolkit. * @param imagedata an array of bytes, representing * image data in a supported image format. * Creates an image which decodes the image stored in the specified * byte array, and at the specified offset and length. * The data must be in some image format, such as GIF or JPEG, * that is supported by this toolkit. * @param imagedata an array of bytes, representing * image data in a supported image format. * @param imageoffset the offset of the beginning * of the data in the array. * @param imagelength the length of the data in the array. * Gets a <code>PrintJob</code> 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 <code>checkPrintJobAccess</code> method to * ensure initiation of a print operation is allowed. If the default * implementation of <code>checkPrintJobAccess</code> is used (that is, * that method is not overriden), then this results in a call to the * security manager's <code>checkPermission</code> method with a <code> * RuntimePermission("queuePrintJob")</code> permission. * @param frame the parent of the print dialog. May not be null. * @param jobtitle the title of the PrintJob. A null title is equivalent * @param props a Properties object containing zero or more properties. * Properties are not standardized and are not consistent across * implementations. Because of this, PrintJobs which require job * and page control should use the version of this function which * takes JobAttributes and PageAttributes objects. This object * may be updated to reflect the user's job choices on exit. May * @return a <code>PrintJob</code> object, or <code>null</code> if the * user cancelled the print job. * @throws NullPointerException if frame is null * @throws SecurityException if this thread is not allowed to initiate a * @see java.awt.GraphicsEnvironment#isHeadless * @see java.lang.RuntimePermission * Gets a <code>PrintJob</code> 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 <code>checkPrintJobAccess</code> method to * ensure initiation of a print operation is allowed. If the default * implementation of <code>checkPrintJobAccess</code> is used (that is, * that method is not overriden), then this results in a call to the * security manager's <code>checkPermission</code> method with a <code> * RuntimePermission("queuePrintJob")</code> permission. * @param frame the parent of the print dialog. May be null if and only * if jobAttributes is not null and jobAttributes.getDialog() * returns JobAttributes.DialogType.NONE or * JobAttributes.DialogType.COMMON. * @param jobtitle the title of the PrintJob. A null title is equivalent * @param jobAttributes a set of job attributes which will control the * PrintJob. The attributes will be updated to reflect the user's * choices as outlined in the JobAttributes documentation. May be * @param pageAttributes a set of page attributes which will control the * PrintJob. The attributes will be applied to every page in the * job. The attributes will be updated to reflect the user's * choices as outlined in the PageAttributes documentation. May be * @return a <code>PrintJob</code> object, or <code>null</code> if the * user cancelled the print job. * @throws NullPointerException if frame is null * @throws 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. * @throws SecurityException if this thread is not allowed to initiate a * print job request, or if jobAttributes specifies print to file, * and this thread is not allowed to access the file system * @see java.awt.GraphicsEnvironment#isHeadless * @see java.lang.RuntimePermission * @see java.awt.JobAttributes * @see java.awt.PageAttributes // Override to add printing support with new job/page control classes public abstract void beep();
* 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. * file, or other file specified by the <code>AWT.DnD.flavorMapFileURL * </code> Toolkit property, text returned by the system Clipboard's <code> * getTransferData()</code> method is available in the following flavors: * <li>DataFlavor.stringFlavor</li> * <li>DataFlavor.plainTextFlavor (<b>deprecated</b>)</li> * As with <code>java.awt.datatransfer.StringSelection</code>, if the * requested flavor is <code>DataFlavor.plainTextFlavor</code>, or an * equivalent flavor, a Reader is returned. <b>Note:</b> The behavior of * the system Clipboard's <code>getTransferData()</code> method for <code> * DataFlavor.plainTextFlavor</code>, and equivalent DataFlavors, is * inconsistent with the definition of <code>DataFlavor.plainTextFlavor * </code>. Because of this, support for <code> * DataFlavor.plainTextFlavor</code>, and equivalent flavors, is * 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 <code>checkSystemClipboardAccess</code> method * to ensure it's ok to to access the system clipboard. If the default * implementation of <code>checkSystemClipboardAccess</code> is used (that * is, that method is not overriden), then this results in a call to the * security manager's <code>checkPermission</code> method with an <code> * AWTPermission("accessClipboard")</code> permission. * @return the system Clipboard * @exception HeadlessException if GraphicsEnvironment.isHeadless() * @see java.awt.GraphicsEnvironment#isHeadless * @see java.awt.datatransfer.Clipboard * @see java.awt.datatransfer.StringSelection * @see java.awt.datatransfer.DataFlavor#stringFlavor * @see java.awt.datatransfer.DataFlavor#plainTextFlavor * @see java.awt.AWTPermission * Gets the singleton instance of the system selection as a * <code>Clipboard</code> 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 * <code>FocusListener</code> on all <code>Component</code>s which support * text selection, and, between <code>FOCUS_GAINED</code> and * <code>FOCUS_LOST</code> events delivered to that <code>Component</code>, * updating the system selection <code>Clipboard</code> when the selection * changes inside the <code>Component</code>. 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 <code>java.awt.TextComponent</code> and * <code>javax.swing.text.JTextComponent</code> 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 <code>Clipboard</code>. * On those platforms, this method will return <code>null</code>. In such a * case, an application is absolved from its responsibility to update the * system selection <code>Clipboard</code> as described above. * Each actual implementation of this method should first check if there * is a <code>SecurityManager</code> installed. If there is, the method * should call the <code>SecurityManager</code>'s * <code>checkSystemClipboardAccess</code> method to ensure that client * code has access the system selection. If the default implementation of * <code>checkSystemClipboardAccess</code> is used (that is, if the method * is not overridden), then this results in a call to the * <code>SecurityManager</code>'s <code>checkPermission</code> method with * an <code>AWTPermission("accessClipboard")</code> permission. * @return the system selection as a <code>Clipboard</code>, or * <code>null</code> if the native platform does not support a * system selection <code>Clipboard</code> * @exception HeadlessException if GraphicsEnvironment.isHeadless() * @see java.awt.datatransfer.Clipboard * @see java.awt.event.FocusListener * @see java.awt.event.FocusEvent#FOCUS_GAINED * @see java.awt.event.FocusEvent#FOCUS_LOST * @see javax.swing.text.JTextComponent * @see GraphicsEnvironment#isHeadless * Determines which modifier key is the appropriate accelerator * key for menu shortcuts. * Menu shortcuts, which are embodied in the * <code>MenuShortcut</code> class, are handled by the * <code>MenuBar</code> class. * By default, this method returns <code>Event.CTRL_MASK</code>. * Toolkit implementations should override this method if the * <b>Control</b> key isn't the correct key for accelerators. * @return the modifier mask on the <code>Event</code> class * that is used for menu shortcuts on this toolkit. * @exception HeadlessException if GraphicsEnvironment.isHeadless() * @see java.awt.GraphicsEnvironment#isHeadless * @see java.awt.MenuShortcut * Returns whether the given locking key on the keyboard is currently in * {@link java.awt.event.KeyEvent#VK_CAPS_LOCK VK_CAPS_LOCK}, * {@link java.awt.event.KeyEvent#VK_NUM_LOCK VK_NUM_LOCK}, * {@link java.awt.event.KeyEvent#VK_SCROLL_LOCK VK_SCROLL_LOCK}, and * {@link java.awt.event.KeyEvent#VK_KANA_LOCK VK_KANA_LOCK}. * @exception java.lang.IllegalArgumentException if <code>keyCode</code> * is not one of the valid key codes * @exception java.lang.UnsupportedOperationException if the host system doesn't * allow getting the state of this key programmatically, or if the keyboard * @exception HeadlessException if GraphicsEnvironment.isHeadless() * @see java.awt.GraphicsEnvironment#isHeadless * Sets the state of the given locking key on the keyboard. * {@link java.awt.event.KeyEvent#VK_CAPS_LOCK VK_CAPS_LOCK}, * {@link java.awt.event.KeyEvent#VK_NUM_LOCK VK_NUM_LOCK}, * {@link java.awt.event.KeyEvent#VK_SCROLL_LOCK VK_SCROLL_LOCK}, and * {@link java.awt.event.KeyEvent#VK_KANA_LOCK VK_KANA_LOCK}. * Depending on the platform, setting the state of a locking key may * involve event processing and therefore may not be immediately * observable through getLockingKeyState. * @exception java.lang.IllegalArgumentException if <code>keyCode</code> * is not one of the valid key codes * @exception java.lang.UnsupportedOperationException if the host system doesn't * allow setting the state of this key programmatically, or if the keyboard * @exception HeadlessException if GraphicsEnvironment.isHeadless() * @see java.awt.GraphicsEnvironment#isHeadless * Give native peers the ability to query the native container * given a native component (eg the direct parent may be lightweight). * 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). * <p>Note that multi-frame images are invalid and may cause this * @param cursor the image to display when the cursor is actived * @param hotSpot the X and Y of the large cursor's hot spot; the * hotSpot values must be less than the Dimension returned by * <code>getBestCursorSize</code> * @param name a localized description of the cursor, for Java Accessibility use * @exception IndexOutOfBoundsException if the hotSpot values are outside * the bounds of the cursor * @exception HeadlessException if GraphicsEnvironment.isHeadless() * @see java.awt.GraphicsEnvironment#isHeadless // Override to implement custom cursor support. * 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. <p> * Note: if an image is used whose dimensions don't match a supported size * (as returned by this method), the Toolkit implementation will attempt to * resize the image to a supported size. * Since converting low-resolution images is difficult, * no guarantees are made as to the quality of a cursor image which isn't a * supported size. It is therefore recommended that this method * be called and an appropriate image used so no image conversion is made. * @param preferredWidth the preferred cursor width the component would like * @param preferredHeight the preferred cursor height the component would like * @return the closest matching supported cursor size, or a dimension of 0,0 if * the Toolkit implementation doesn't support custom cursors. * @exception HeadlessException if GraphicsEnvironment.isHeadless() * @see java.awt.GraphicsEnvironment#isHeadless // Override to implement custom cursor support. * Returns the maximum number of colors the Toolkit supports in a custom cursor * Note: if an image is used which has more colors in its palette than * the supported maximum, the Toolkit implementation will attempt to flatten the * palette to the maximum. Since converting low-resolution images is difficult, * no guarantees are made as to the quality of a cursor image which has more * colors than the system supports. It is therefore recommended that this method * be called and an appropriate image used so no image conversion is made. * @return the maximum number of colors, or zero if custom cursors are not * supported by this Toolkit implementation. * @exception HeadlessException if GraphicsEnvironment.isHeadless() * @see java.awt.GraphicsEnvironment#isHeadless // Override to implement custom cursor support. * Returns whether Toolkit supports this state for * <code>Frame</code>s. This method tells whether the <em>UI * concept</em> of, say, maximization or iconification is * supported. It will always return false for "compound" states * like <code>Frame.ICONIFIED|Frame.MAXIMIZED_VERT</code>. * In other words, the rule of thumb is that only queries with a * single frame state constant as an argument are meaningful. * <p>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 * <li>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 * <li>The developer should consider examining the value of the * {@link java.awt.event.WindowEvent#getNewState} method of the * {@code WindowEvent} received through the {@link * 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 {@link Frame#setExtendedState} method. * @param state one of named frame state constants. * @return <code>true</code> is this frame state is supported by * this Toolkit implementation, <code>false</code> otherwise. * @exception HeadlessException * if <code>GraphicsEnvironment.isHeadless()</code> * returns <code>true</code>. * @see java.awt.Window#addWindowStateListener * Support for I18N: any visible strings should be stored in * here, so that only one copy is maintained. * Initialize JNI field and method ids private static native void initIDs();
* WARNING: This is a temporary workaround for a problem in the * way the AWT loads native libraries. A number of classes in the * AWT package have a native method, initIDs(), which initializes * the JNI field and method ids used in the native portion of * Since the use and storage of these ids is done by the * implementation libraries, the implementation of these method is * provided by the particular AWT implementations (for example, * "Toolkit"s/Peer), such as Motif, Microsoft Windows, or Tiny. The * problem is that this means that the native libraries must be * loaded by the java.* classes, which do not necessarily know the * names of the libraries to load. A better way of doing this * would be to provide a separate library which defines java.awt.* * initIDs, and exports the relevant symbols out to the * implementation libraries. * For now, we know it's done by the implementation, and we assume * that the name of the library is "awt". -br. * If you change loadLibraries(), please add the change to * java.awt.image.ColorModel.loadLibraries(). Unfortunately, * classes can be loaded in java.awt.image that depend on * libawt and there is no way to call Toolkit.loadLibraries() private static boolean loaded =
false;
// No resource file; defaults will be used. // ensure that the proper libraries are loaded * Gets a property with the specified key and default. * This method returns defaultValue if the property is not found. * 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. * <p>First, if there is a security manager, its * <code>checkAwtEventQueueAccess</code> * If the default implementation of <code>checkAwtEventQueueAccess</code> * is used (that is, that method is not overriden), then this results in * a call to the security manager's <code>checkPermission</code> method * with an <code>AWTPermission("accessEventQueue")</code> permission. * @return the <code>EventQueue</code> object * @throws SecurityException * if a security manager exists and its <code>{@link * java.lang.SecurityManager#checkAwtEventQueueAccess}</code> * method denies access to the <code>EventQueue</code> * @see java.awt.AWTPermission * Gets the application's or applet's <code>EventQueue</code> * instance, without checking access. For security reasons, * this can only be called from a <code>Toolkit</code> subclass. * @return the <code>EventQueue</code> object /* Accessor method for use by AWT package routines. */ * Creates the peer for a DragSourceContext. * Always throws InvalidDndOperationException if * GraphicsEnvironment.isHeadless() returns true. * @see java.awt.GraphicsEnvironment#isHeadless * Creates a concrete, platform dependent, subclass of the abstract * DragGestureRecognizer class requested, and associates it with the * DragSource, Component and DragGestureListener specified. * subclasses should override this to provide their own implementation * @param abstractRecognizerClass The abstract class of the required recognizer * @param ds The DragSource * @param c The Component target for the DragGestureRecognizer * @param srcActions The actions permitted for the gesture * @param dgl The DragGestureListener * @return the new object or null. Always returns null if * GraphicsEnvironment.isHeadless() returns true. * @see java.awt.GraphicsEnvironment#isHeadless * 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 // 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. // This property should never be cached /* for property "awt.font.desktophints" */ * Sets the named desktop property to the specified value and fires a * property change event to notify any listeners that the value has changed. // This is a workaround for headless toolkits. It would be // better to override this method but it is declared final. // "this instanceof" syntax defeats polymorphism. // Don't fire change event if old and new values are null. // It helps to avoid recursive resending of WM_THEMECHANGED * an opportunity to lazily evaluate desktop property values. * initializeDesktopProperties * Adds the specified property change listener for the named desktop * If pcl is null, no exception is thrown and no action is performed. * @param name The name of the property to listen for * @param pcl The property change listener * Removes the specified property change listener for the named * If pcl is null, no exception is thrown and no action is performed. * @param name The name of the property to remove * @param pcl The property change listener * Returns an array of all the property change listeners * registered on this toolkit. * @return all of this toolkit's <code>PropertyChangeListener</code>s * or an empty array if no property change * listeners are currently registered * Returns an array of all the <code>PropertyChangeListener</code>s * associated with the named property. * @param propertyName the named property * @return all of the <code>PropertyChangeListener</code>s associated with * the named property or an empty array if no such listeners have * 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 {@link Window#isAlwaysOnTopSupported}. * @return <code>true</code>, if current toolkit supports the always-on-top mode, * otherwise returns <code>false</code> * @see Window#isAlwaysOnTopSupported * @see Window#setAlwaysOnTop(boolean) * Returns whether the given modality type is supported by this toolkit. If * a dialog with unsupported modality type is created, then * <code>Dialog.ModalityType.MODELESS</code> is used instead. * @param modalityType modality type to be checked for support by this toolkit * @return <code>true</code>, if current toolkit supports given modality * type, <code>false</code> otherwise * @see java.awt.Dialog.ModalityType * @see java.awt.Dialog#getModalityType * @see java.awt.Dialog#setModalityType * 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 <code>Dialog.ModalExclusionType.NO_EXCLUDE</code> is used instead. * @param modalExclusionType modal exclusion type to be checked for support by this toolkit * @return <code>true</code>, if current toolkit supports given modal exclusion * type, <code>false</code> otherwise * @see java.awt.Dialog.ModalExclusionType * @see java.awt.Window#getModalExclusionType * @see java.awt.Window#setModalExclusionType * Extracts a "pure" AWTEventListener from a AWTEventListenerProxy, * if the listener is proxied. // if user passed in a AWTEventListenerProxy object, extract * Adds an AWTEventListener to receive all AWTEvents dispatched * system-wide that conform to the given <code>eventMask</code>. * First, if there is a security manager, its <code>checkPermission</code> * method is called with an * <code>AWTPermission("listenToAllAWTEvents")</code> permission. * This may result in a SecurityException. * <code>eventMask</code> is a bitmask of event types to receive. * It is constructed by bitwise OR-ing together the event masks * defined in <code>AWTEvent</code>. * Note: event listener use is not recommended for normal * application use, but are intended solely to support special * purpose facilities including support for accessibility, * If listener is null, no exception is thrown and no action is performed. * @param listener the event listener. * @param eventMask the bitmask of event types to receive * @throws SecurityException * if a security manager exists and its * <code>checkPermission</code> method doesn't allow the operation. * @see #removeAWTEventListener * @see #getAWTEventListeners * @see SecurityManager#checkPermission * @see java.awt.AWTPermission * @see java.awt.event.AWTEventListener * @see java.awt.event.AWTEventListenerProxy // Create a new selectiveListener. // OR the eventMask into the selectiveListener's event mask. // If no bits are set, break out of loop. if ((
mask &
1L) !=
0) {
// Always test bit 0. mask >>>=
1;
// Right shift, fill with zeros on left. * Removes an AWTEventListener from receiving dispatched AWTEvents. * First, if there is a security manager, its <code>checkPermission</code> * method is called with an * <code>AWTPermission("listenToAllAWTEvents")</code> 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, * If listener is null, no exception is thrown and no action is performed. * @param listener the event listener. * @throws SecurityException * if a security manager exists and its * <code>checkPermission</code> method doesn't allow the operation. * @see #addAWTEventListener * @see #getAWTEventListeners * @see SecurityManager#checkPermission * @see java.awt.AWTPermission * @see java.awt.event.AWTEventListener * @see java.awt.event.AWTEventListenerProxy assert calls[i] >=
0:
"Negative Listeners count";
log.
fine(
"Assertion (eventMask != 0) failed");
* Returns an array of all the <code>AWTEventListener</code>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 <code>AWTEventListenerProxy</code> objects, which also contain * the event mask for the given listener. * Note that listener objects * added multiple times appear only once in the returned array. * @return all of the <code>AWTEventListener</code>s or an empty * array if no listeners are currently registered * @throws SecurityException * if a security manager exists and its * <code>checkPermission</code> method doesn't allow the operation. * @see #addAWTEventListener * @see #removeAWTEventListener * @see SecurityManager#checkPermission * @see java.awt.AWTPermission * @see java.awt.event.AWTEventListener * @see java.awt.event.AWTEventListenerProxy //assert tempL is not an AWTEventListenerProxy - we should // have weeded them all out // don't want to wrap a proxy inside a proxy * Returns an array of all the <code>AWTEventListener</code>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 <code>AWTEventListenerProxy</code> objects, which also contain * the event mask for the given listener. * Note that listener objects * added multiple times appear only once in the returned array. * @param eventMask the bitmask of event types to listen for * @return all of the <code>AWTEventListener</code>s registered * on this toolkit for the specified * event types, or an empty array if no such listeners * are currently registered * @throws SecurityException * if a security manager exists and its * <code>checkPermission</code> method doesn't allow the operation. * @see #addAWTEventListener * @see #removeAWTEventListener * @see SecurityManager#checkPermission * @see java.awt.AWTPermission * @see java.awt.event.AWTEventListener * @see java.awt.event.AWTEventListenerProxy //AWTEventListener tempL = sael.getListener(); * This method notifies any AWTEventListeners that an event * is about to be dispatched. * @param theEvent the event which will be dispatched. // 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. // Implementation cloned from AWTEventMulticaster. // #4178589: must overload remove(EventListener) to call our add() // instead of the static addInternal() so we allocate a // ToolkitEventMulticaster instead of an AWTEventMulticaster. // Note: this method is called by AWTEventListener.removeInternal(), // so its method signature must match AWTEventListener.remove(). if (
a2 == a &&
b2 == b) {
return this;
// it's not here // This array contains the number of times to call the eventlistener // For each event bit set in mask, increment its call count. // If no bits are set, break out of loop. if ((
mask &
1L) !=
0) {
// Always test bit 0. mask >>>=
1;
// Right shift, fill with zeros on left. long eventBit =
0;
// Used to save the bit of the event type. // Get the index of the call count for this event type. // Instead of using Math.log(...) we will calculate it with // bit shifts. That's what previous implementation looked like: // int ci = (int) (Math.log(eventBit)/Math.log(2)); // Call the listener as many times as it was added for this * Returns a map of visual attributes for the abstract level description * of the given input method highlight, or null if no mapping is found. * The style field of the input method highlight is ignored. The map * returned is unmodifiable. * @param highlight input method highlight * @return style attribute map, or <code>null</code> * @exception HeadlessException if * <code>GraphicsEnvironment.isHeadless</code> returns true * @see java.awt.GraphicsEnvironment#isHeadless * we do expect that all other fireXXX() methods of java.beans.PropertyChangeSupport * use this method. If this will be changed we will need to change this class. * Reports whether events from extra mouse buttons are allowed to be processed and posted into * 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. * The current value could be queried by using the * {@code System.getProperty("sun.awt.enableExtraMouseButtons")} method. * @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true * @return {@code true} if events from extra mouse buttons are allowed to be processed and posted; * {@code false} otherwise * @see System#getProperty(String propertyName) * @see System#setProperty(String propertyName, String value) * @see java.awt.EventQueue