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

📄 metallookandfeel.java

📁 Mobile 应用程序使用 Java Micro Edition (Java ME) 平台
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/* * @(#)MetalLookAndFeel.java	1.206 06/07/12 * * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */package javax.swing.plaf.metal;import java.awt.*;import java.beans.PropertyChangeEvent;import java.beans.PropertyChangeListener;import javax.swing.plaf.*;import javax.swing.*;import javax.swing.plaf.basic.*;import javax.swing.border.*;import javax.swing.text.JTextComponent;import javax.swing.text.DefaultEditorKit;import java.util.*;import java.awt.Font;import java.awt.Color;import java.awt.SystemColor;import java.awt.event.KeyEvent;import java.awt.event.InputEvent;import java.lang.reflect.*;import java.lang.ref.ReferenceQueue;import java.lang.ref.WeakReference;import java.net.URL;import java.io.Serializable;import java.security.AccessController;import java.security.PrivilegedAction;import sun.awt.AppContext;import sun.awt.SunToolkit;import sun.security.action.GetPropertyAction;import sun.swing.DefaultLayoutStyle;import sun.swing.SwingLazyValue;import sun.swing.SwingUtilities2;/** * The Java Look and Feel, otherwise known as Metal. * <p> * Each of the {@code ComponentUI}s provided by {@code * MetalLookAndFeel} derives its behavior from the defaults * table. Unless otherwise noted each of the {@code ComponentUI} * implementations in this package document the set of defaults they * use. Unless otherwise noted the defaults are installed at the time * {@code installUI} is invoked, and follow the recommendations * outlined in {@code LookAndFeel} for installing defaults. * <p> * {@code MetalLookAndFeel} derives it's color palette and fonts from * {@code MetalTheme}. The default theme is {@code OceanTheme}. The theme * can be changed using the {@code setCurrentTheme} method, refer to it * for details on changing the theme. Prior to 1.5 the default  * theme was {@code DefaultMetalTheme}. The system property * {@code "swing.metalTheme"} can be set to {@code "steel"} to indicate * the default should be {@code DefaultMetalTheme}. * <p> * <strong>Warning:</strong> * Serialized objects of this class will not be compatible with * future Swing releases. The current serialization support is * appropriate for short term storage or RMI between applications running * the same version of Swing.  As of 1.4, support for long term storage * of all JavaBeans<sup><font size="-2">TM</font></sup> * has been added to the <code>java.beans</code> package. * Please see {@link java.beans.XMLEncoder}. * * @see MetalTheme * @see DefaultMetalTheme * @see OceanTheme * * @version @(#)MetalLookAndFeel.java	1.206 06/07/12 * @author Steve Wilson */public class MetalLookAndFeel extends BasicLookAndFeel{    private static boolean METAL_LOOK_AND_FEEL_INITED = false;    private static MetalTheme currentTheme;    private static boolean isOnlyOneContext = true;    private static AppContext cachedAppContext;    /**     * True if checked for windows yet.     */    private static boolean checkedWindows;    /**     * True if running on Windows.     */    private static boolean isWindows;    /**     * Set to true first time we've checked swing.useSystemFontSettings.     */    private static boolean checkedSystemFontSettings;    /**     * True indicates we should use system fonts, unless the developer has     * specified otherwise with Application.useSystemFontSettings.     */    private static boolean useSystemFonts;    /**     * Returns true if running on Windows.     */    static boolean isWindows() {        if (!checkedWindows) {            String osName = (String)AccessController.doPrivileged(                new GetPropertyAction("os.name"));            if (osName != null && osName.indexOf("Windows") != -1) {                isWindows = true;                String systemFonts = (String)AccessController.doPrivileged(                    new GetPropertyAction("swing.useSystemFontSettings"));                useSystemFonts = (systemFonts != null &&                               (Boolean.valueOf(systemFonts).booleanValue()));            }            checkedWindows = true;        }        return isWindows;    }    /**     * Returns true if system fonts should be used, this is only useful     * for windows.     */    static boolean useSystemFonts() {        if (isWindows() && useSystemFonts) {            if (METAL_LOOK_AND_FEEL_INITED) {                Object value = UIManager.get(                                 "Application.useSystemFontSettings");                return (value == null || Boolean.TRUE.equals(value));            }            // If an instanceof MetalLookAndFeel hasn't been inited yet, we            // don't want to trigger loading of a UI by asking the UIManager            // for a property, assume the user wants system fonts. This will            // be properly adjusted when install is invoked on the            // MetalTheme            return true;        }        return false;    }    /**     * Returns true if the high contrast theme should be used as the default     * theme.     */    private static boolean useHighContrastTheme() {        if (isWindows() && useSystemFonts()) {            Boolean highContrast = (Boolean)Toolkit.getDefaultToolkit().                                  getDesktopProperty("win.highContrast.on");            return (highContrast == null) ? false : highContrast.                                            booleanValue();        }        return false;    }    /**     * Returns true if we're using the Ocean Theme.     */    static boolean usingOcean() {        return (getCurrentTheme() instanceof OceanTheme);    }    /**     * Returns the name of this look and feel. This returns      * {@code "Metal"}.     *     * @return the name of this look and feel     */    public String getName() {        return "Metal";    }    /**     * Returns an identifier for this look and feel. This returns     * {@code "Metal"}.     *     * @return the identifier of this look and feel     */    public String getID() {        return "Metal";    }    /**     * Returns a short description of this look and feel. This returns     * {@code "The Java(tm) Look and Feel"}.     * @return a short description for the look and feel     */    public String getDescription() {        return "The Java(tm) Look and Feel";    }    /**     * Returns {@code false}; {@code MetalLookAndFeel} is not a native     * look and feel.     *     * @return {@code false}     */    public boolean isNativeLookAndFeel() {        return false;    }    /**     * Returns {@code true}; {@code MetalLookAndFeel} can be run on     * any platform.     *     * @return {@code true}     */    public boolean isSupportedLookAndFeel() {        return true;    }        /**     * Returns {@code true}; metal can provide {@code Window}     * decorations.     *     * @return {@code true}     *     * @see JDialog#setDefaultLookAndFeelDecorated     * @see JFrame#setDefaultLookAndFeelDecorated     * @see JRootPane#setWindowDecorationStyle     * @since 1.4     */    public boolean getSupportsWindowDecorations() {        return true;    }    /**      * Populates {@code table} with mappings from {@code uiClassID} to     * the fully qualified name of the ui class. {@code     * MetalLookAndFeel} registers an entry for each of the classes in     * the package {@code javax.swing.plaf.metal} that are named     * MetalXXXUI. The string {@code XXX} is one of Swing's uiClassIDs. For     * the {@code uiClassIDs} that do not have a class in metal, the     * corresponding class in {@code javax.swing.plaf.basic} is     * used. For example, metal does not have a class named {@code     * "MetalColorChooserUI"}, as such, {@code     * javax.swing.plaf.basic.BasicColorChooserUI} is used.     *      * @param table the {@code UIDefaults} instance the entries are     *        added to     * @throws NullPointerException if {@code table} is {@code null}     *     * @see javax.swing.plaf.basic.BasicLookAndFeel#initClassDefaults     */    protected void initClassDefaults(UIDefaults table)    {        super.initClassDefaults(table);        final String metalPackageName = "javax.swing.plaf.metal.";        Object[] uiDefaults = {                   "ButtonUI", metalPackageName + "MetalButtonUI",                 "CheckBoxUI", metalPackageName + "MetalCheckBoxUI",                 "ComboBoxUI", metalPackageName + "MetalComboBoxUI",              "DesktopIconUI", metalPackageName + "MetalDesktopIconUI",              "FileChooserUI", metalPackageName + "MetalFileChooserUI",            "InternalFrameUI", metalPackageName + "MetalInternalFrameUI",                    "LabelUI", metalPackageName + "MetalLabelUI",       "PopupMenuSeparatorUI", metalPackageName + "MetalPopupMenuSeparatorUI",              "ProgressBarUI", metalPackageName + "MetalProgressBarUI",              "RadioButtonUI", metalPackageName + "MetalRadioButtonUI",                "ScrollBarUI", metalPackageName + "MetalScrollBarUI",               "ScrollPaneUI", metalPackageName + "MetalScrollPaneUI",                "SeparatorUI", metalPackageName + "MetalSeparatorUI",                   "SliderUI", metalPackageName + "MetalSliderUI",                "SplitPaneUI", metalPackageName + "MetalSplitPaneUI",               "TabbedPaneUI", metalPackageName + "MetalTabbedPaneUI",                "TextFieldUI", metalPackageName + "MetalTextFieldUI",             "ToggleButtonUI", metalPackageName + "MetalToggleButtonUI",                  "ToolBarUI", metalPackageName + "MetalToolBarUI",                  "ToolTipUI", metalPackageName + "MetalToolTipUI",

⌨️ 快捷键说明

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