⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 toolkit.java

📁 This is a resource based on j2me embedded,if you dont understand,you can connection with me .
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* * @(#)Toolkit.java	1.28 06/10/10 * * Copyright  1990-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER *  * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version * 2 only, as published by the Free Software Foundation.  *  * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License version 2 for more details (a copy is * included at /legal/license.txt).  *  * You should have received a copy of the GNU General Public License * version 2 along with this work; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA  *  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa * Clara, CA 95054 or visit www.sun.com if you need additional * information or have any questions.  * *//* * Warning : * Two versions of this file exist in this workspace. * One for Personal Basis, and one for Personal Profile. * Don't edit the wrong one !!! */package java.awt;import java.util.Properties;import java.util.Map;import java.util.WeakHashMap;import java.util.EventListener;import java.awt.im.InputMethodHighlight;import java.awt.image.ImageObserver;import java.awt.image.ImageProducer;import java.awt.image.ColorModel;import java.awt.event.*;import java.net.URL;import java.io.BufferedInputStream;import java.io.InputStream;import java.security.AccessController;import sun.security.action.GetPropertyAction;import sun.io.FileIO;import sun.io.FileIOFactory;import java.util.ArrayList;/* NOTE: It is no longer a requirement for <code>Toolkit</code> and AWT implementations to be peer based. However, the implementation of the <code>java.awt</code> components provided assume the toolkit is peer based. To create a toolkit to work with this implementation it is necessary to sub-class the <code>sun.awt.PeerBasedToolkit<code> class.*//** Defines the common functionaily of a toolkit for the AWT classes. A <code>Toolkit</code> is responsible for, among other things, providing the system event queue to receive low level events from the native toolkit, loading and creating images, as well as determining the screen resolution and size. <p> * @version 	1.16, 08/19/02 * @author	Sami Shaio * @author	Arthur van Hoff * @since       JDK1.0 */public abstract class  Toolkit {    private AWTEventListener eventListener = null;    private Map listener2SelectiveListener = new WeakHashMap();    private AWTPermission listenToAllAWTEventsPermission = null;    /**     * Fills in the integer array that is supplied as an argument     * with the current system color values.     * <p>     * This method is called by the method <code>updateSystemColors</code>     * in the <code>SystemColor</code> class.     * @param     systemColors  an integer array.     * @since     JDK1.1     */    protected void loadSystemColors(int[] systemColors) {}	    /**     * Gets the size of the screen.     * @return    the size of this toolkit's screen, in pixels.     * @since     JDK1.0     */    public abstract Dimension getScreenSize();	    /**     * Returns the screen resolution in dots-per-inch.     * @return    this toolkit's screen resolution, in dots-per-inch.     * @since     JDK1.0     */    public abstract int getScreenResolution();	    /**     * Determines the color model of this toolkit's screen.     * <p>     * <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,     * and alpha components.     * <p>     * 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.     * @see       java.awt.image.ColorModel     * @see       java.awt.Component#getColorModel     * @since     JDK1.0     */    public abstract ColorModel getColorModel();	    /**     * Returns the names of the available fonts in this toolkit.<p>     * For 1.1, the following font names are deprecated (the replacement     * name follows):     * <ul>     * <li>TimesRoman (use Serif)     * <li>Helvetica (use SansSerif)     * <li>Courier (use Monospaced)     * </ul><p>     * The ZapfDingbats font is also deprecated in 1.1, but only as a     * separate fontname.  Unicode defines the ZapfDingbat characters     * starting at \u2700, and as of 1.1 Java supports those characters.     * @return    the names of the available fonts in this toolkit.     * @since     JDK1.0     */    public abstract String[] getFontList();	    /**     * Gets the screen metrics of the font.     * @param     font   a font.     * @return    the screen metrics of the specified font in this toolkit.     * @since     JDK1.0     */    public abstract FontMetrics getFontMetrics(Font font);	    /**     * Synchronizes this toolkit's graphics state. Some window systems     * may do buffering of graphics events.     * <p>     * This method ensures that the display is up-to-date. It is useful     * for animation.     * @since     JDK1.0     */    public abstract void sync();    /**     * The default toolkit.     */    private static Toolkit toolkit;    // fix for 4187686 Several class objects are used for synchronization    private static Object classLock = new Object();    /**     * Gets the default toolkit.     * <p>     * If 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>.     * <p>     * If the system property does not exist, then the default toolkit     * used is <code>"sun.awt.motif.MToolkit"</code> for Solaris, and     *<code>"sun.awt.gtk.GToolkit"</code> for Linux. Both of which are     * implementations of Abstract Window Toolkits.     * @return    the default toolkit.     * @exception  AWTError  if a toolkit could not be found, or     *                 if one could not be accessed or instantiated.     * @since     JDK1.0     */    public static synchronized Toolkit getDefaultToolkit() {        if (toolkit == null) {            // JDK 1.2 wraps this block of code with a Compiler.disable/enable            // to turn off a JIT because toolkit initilization touches many            // classes that are only touched once. If Personal Java uses a            // JIT in the future that kind of wrapping would make sense here.            java.security.AccessController.doPrivileged(                new java.security.PrivilegedAction() {                    public Object run() {                        String nm = null;                        try {                            nm = System.getProperty("awt.toolkit");                            toolkit = (Toolkit) Class.forName(nm).newInstance();                        } catch (ClassNotFoundException e) {                            throw new AWTError("Toolkit not found: " + nm);                        } catch (InstantiationException e) {                            throw new AWTError("Could not instantiate Toolkit: " + nm);                        } catch (IllegalAccessException e) {                            throw new AWTError("Could not access Toolkit: " + nm);                        }                        return null;                    }                }            );        }        return toolkit;    }	    /** Gets a Graphics object for the suplied Window. The graphics object     should be initialised with the foreground, background and font of     the window and should draw to the GraphicsDevice the Window's     GraphicsConfiguration belongs to. This method is package protected so     as to be spec compatiable. It should be abstract but this would cause     spec issues. */	    Graphics getGraphics(Window window) {        throw new UnsupportedOperationException();    }	    /** Gets the GraphicsEnvironment for this toolkit. This is called from     GraphicsEnvironment.getLocalGraphicsEnvironment. */	    GraphicsEnvironment getLocalGraphicsEnvironment() {        throw new UnsupportedOperationException();    }	    /**      * Returns an image which gets pixel data from the specified file,     * whose format can be either GIF, JPEG or PNG.     * The underlying toolkit attempts to resolve multiple requests     * with the same filename to the same returned Image.     * Since the mechanism required to facilitate this sharing of     * Image objects may continue to hold onto images that are no     * longer of use for an indefinite period of time, developers     * are encouraged to implement their own caching of images by     * using the createImage variant wherever available.     * @param     filename   the name of a file containing pixel data     *                         in a recognized file format.     * @return    an image which gets its pixel data from     *                         the specified file.     * @see       java.awt.Toolkit#createImage(java.lang.String)     */    public abstract Image getImage(String filename);	  // PBP/PP [6262540]  // Fix for J2SE bug 6262530    /**      * Returns an image which gets pixel data from the specified URL.     * The pixel data referenced by the specified URL must be in one     * of the following formats: GIF, JPEG or PNG.     * The underlying toolkit attempts to resolve multiple requests     * with the same URL to the same returned Image.     * Since the mechanism required to facilitate this sharing of     * Image objects may continue to hold onto images that are no     * longer of use for an indefinite period of time, developers     * are encouraged to implement their own caching of images by     * using the createImage variant wherever available.     *     * <p>     * <em>     * This method will throw {@link SecurityException} if the     * caller does not have the permission obtained from     * <code>url.openConnection.getPermission()</code>.     * For compatibility with pre-1.2 security managers, if the permission     * is a {@link java.io.FilePermission} or a     * {@link java.net.SocketPermission}, then the 1.1-style     * <code>SecurityManager.checkXXX</code> methods are called instead of     * {@link SecurityManager#checkPermission}.     * </em>     *     * <!-- PBP/PP -->     * @throws SecurityException If the caller does not have permission to     * access this URL.     *     * @param     url   the URL to use in fetching the pixel data.     * @return    an image which gets its pixel data from     *                         the specified URL.     * @see       java.awt.Toolkit#createImage(java.net.URL)     */    public abstract Image getImage(URL 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.     * @param     filename   the name of a file containing pixel data     *                         in a recognized file format.     * @return    an image which gets its pixel data from     *                         the specified file.     * @see       java.awt.Toolkit#getImage(java.lang.String)     */	    public abstract Image createImage(String filename);	  // PBP/PP [6262540]  // Fix for J2SE bug 6262530    /**     * 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.     *     * <p>     * <em>     * This method will throw {@link SecurityException} if the     * caller does not have the permission obtained from     * <code>url.openConnection.getPermission()</code>.     * For compatibility with pre-1.2 security managers, if the permission     * is a {@link java.io.FilePermission} or a     * {@link java.net.SocketPermission}, then the 1.1-style     * <code>SecurityManager.checkXXX</code> methods are called instead of     * {@link SecurityManager#checkPermission}.     * </em>     *     * <!-- PBP/PP -->     * @throws SecurityException If the caller does not have permission to     * access this URL.     *     * @param     url   the URL to use in fetching the pixel data.     * @return    an image which gets its pixel data from     *                         the specified URL.     * @see       java.awt.Toolkit#getImage(java.net.URL)     */	    public abstract Image createImage(URL url);	    /**     * Prepares an image for rendering.     * <p>     * 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.     * <p>     * The image data is downloaded asynchronously in another thread,     * and an appropriately scaled screen representation of the image is

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -