📄 toolkit.java
字号:
* generated. * <p> * This method is called by components <code>prepareImage</code> * methods. * <p> * 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 * screen representation. * @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 * @since JDK1.0 */ public abstract boolean prepareImage(Image image, int width, int height, ImageObserver observer); /** * Indicates the construction status of a specified image that is * being prepared for display. * <p> * 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 * and height. * <p> * This method does not cause the image to begin loading. * An application must call <code>prepareImage</code> to force * the loading of an image. * <p> * This method is called by the component's <code>checkImage</code> * methods. * <p> * 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 * @since JDK1.0 */ public abstract int checkImage(Image image, int width, int height, ImageObserver observer); /** * Creates an image with the specified image producer. * @param producer the image producer to be used. * @return an image with the specified image producer. * @see java.awt.Image * @see java.awt.image.ImageProducer * @see java.awt.Component#createImage(java.awt.image.ImageProducer) * @since JDK1.0 */ public abstract Image createImage(ImageProducer producer); /** * Creates an image which decodes the image stored in the specified * byte array. * <p> * The data must be in some image format, such as GIF or JPEG, * that is supported by this toolkit. * @param imagedata an array of bytes, representing * image data in a supported image format. * @return an image. * @since JDK1.1 */ public Image createImage(byte[] imagedata) { return createImage(imagedata, 0, imagedata.length); } /** * Creates an image which decodes the image stored in the specified * byte array, and at the specified offset and length. * The data must be in some image format, such as GIF or JPEG, * that is supported by this toolkit. * @param imagedata an array of bytes, representing * image data in a supported image format. * @param imageoffset the offset of the beginning * of the data in the array. * @param imagelength the length of the data in the array. * @return an image. * @since JDK1.1 */ public abstract Image createImage(byte[] imagedata, int imageoffset, int imagelength); abstract Image createImage(Component component, int width, int height); /** * Emits an audio beep. * @since JDK1.1 */ public abstract void beep(); /** * Give native peers the ability to query the native container * given a native component (eg the direct parent may be lightweight). */ /** * 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() * returns true * @see java.awt.GraphicsEnvironment#isHeadless * @since 1.4 */ public Insets getScreenInsets(GraphicsConfiguration gc) throws HeadlessException { if (this != Toolkit.getDefaultToolkit()) { return Toolkit.getDefaultToolkit().getScreenInsets(gc); } else { return new Insets(0, 0, 0, 0); } } /* protected static Container getNativeContainer(Component c) { return c.getFrame(); } */ /** * Determines which modifier key is the appropriate accelerator * key for menu shortcuts. * <p> * Menu shortcuts, which are embodied in the * <code>MenuShortcut</code> class, are handled by the * <code>MenuBar</code> class. * <p> * 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. * @see java.awt.MenuBar * @see java.awt.MenuShortcut * @since JDK1.1 */ /* public int getMenuShortcutKeyMask() { return InputEvent.CTRL_MASK; } */ /* Support for I18N: any visible strings should be stored in * lib/awt.properties. The Properties list is stored here, so * that only one copy is maintained. */ private static Properties properties; static { String sep = FileIO.separator; String filename = (String) AccessController.doPrivileged( new GetPropertyAction("java.home")) + sep + "lib" + sep + "awt.properties"; FileIO propsFile = FileIOFactory.newInstance(filename); properties = new Properties(); try { InputStream in = propsFile.getInputStream(); properties.load(new BufferedInputStream(in)); in.close(); } catch (Exception e) {// No properties, defaults will be used. } } /** * Gets a property with the specified key and default. * This method returns defaultValue if the property is not found. */ public static String getProperty(String key, String defaultValue) { String val = properties.getProperty(key); return (val == null) ? defaultValue : val; } /** * 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. */ public final EventQueue getSystemEventQueue() { SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkAwtEventQueueAccess(); } return getSystemEventQueueImpl(); } /* * Get the application's or applet's EventQueue instance, without * checking access. For security reasons, this can only be called * from a Toolkit subclass. Implementations wishing to modify * the default EventQueue support should subclass this method. */ protected abstract EventQueue getSystemEventQueueImpl(); /* Accessor method for use by AWT package routines. */ static EventQueue getEventQueue() { return getDefaultToolkit().getSystemEventQueueImpl(); } /** * Adds an AWTEventListener to receive all AWTEvents dispatched * system-wide that conform to the given <code>eventMask</code>. * <p> * 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. * <p> * <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>. * <p> * Note: event listener use is not recommended for normal * application use, but are intended solely to support special * purpose facilities including support for accessibility, * event record/playback, and diagnostic tracing. * * If listener is null, no exception is thrown and no action is performed. * * @param listener the event listener. * @param eventMask the bitmask of event types to receive * @throws SecurityException * if a security manager exists and its * <code>checkPermission</code> method doesn't allow the operation. * @see java.awt.event.AWTEventListener * @see java.awt.Toolkit#addAWTEventListener * @see java.awt.AWTEvent * @see SecurityManager#checkPermission * @see java.awt.AWTPermission * @since 1.2 */ public void addAWTEventListener(AWTEventListener listener, long eventMask) { AWTEventListener localL = deProxyAWTEventListener(listener); if (localL == null) { return; } SecurityManager security = System.getSecurityManager(); if (security != null) { if (listenToAllAWTEventsPermission == null) { listenToAllAWTEventsPermission = new AWTPermission("listenToAllAWTEvents"); } security.checkPermission(listenToAllAWTEventsPermission); } 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); } } /** * Removes an AWTEventListener from receiving dispatched AWTEvents. * <p> * 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. * <p> * Note: event listener use is not recommended for normal * application use, but are intended solely to support special * purpose facilities including support for accessibility, * event record/playback, and diagnostic tracing. * * If listener is null, no exception is thrown and no action is performed. * * @param listener the event listener. * @throws SecurityException * if a security manager exists and its * <code>checkPermission</code> method doesn't allow the operation. * @see java.awt.event.AWTEventListener * @see java.awt.Toolkit#addAWTEventListener * @see java.awt.AWTEvent * @see SecurityManager#checkPermission * @see java.awt.AWTPermission * @since 1.2 */ public void removeAWTEventListener(AWTEventListener listener) { AWTEventListener localL = deProxyAWTEventListener(listener); if (listener == null) { return; } SecurityManager security = System.getSecurityManager(); if (security != null) { if (listenToAllAWTEventsPermission == null) { listenToAllAWTEventsPermission = new AWTPermission("listenToAllAWTEvents"); } security.checkPermission(listenToAllAWTEventsPermission); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -