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

📄 uimanager.java

📁 gcc的组建
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* UIManager.java --    Copyright (C) 2002, 2003, 2004, 2005  Free Software Foundation, Inc.This file is part of GNU Classpath.GNU Classpath is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2, or (at your option)any later version.GNU Classpath is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNUGeneral Public License for more details.You should have received a copy of the GNU General Public Licensealong with GNU Classpath; see the file COPYING.  If not, write to theFree Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA02110-1301 USA.Linking this library statically or dynamically with other modules ismaking a combined work based on this library.  Thus, the terms andconditions of the GNU General Public License cover the wholecombination.As a special exception, the copyright holders of this library give youpermission to link this library with independent modules to produce anexecutable, regardless of the license terms of these independentmodules, and to copy and distribute the resulting executable underterms of your choice, provided that you also meet, for each linkedindependent module, the terms and conditions of the license of thatmodule.  An independent module is a module which is not derived fromor based on this library.  If you modify this library, you may extendthis exception to your version of the library, but you are notobligated to do so.  If you do not wish to do so, delete thisexception statement from your version. */package javax.swing;import java.awt.Color;import java.awt.Dimension;import java.awt.Font;import java.awt.Insets;import java.beans.PropertyChangeListener;import java.io.Serializable;import java.util.Locale;import javax.swing.border.Border;import javax.swing.event.SwingPropertyChangeSupport;import javax.swing.plaf.ComponentUI;import javax.swing.plaf.metal.MetalLookAndFeel;/** * Manages the current {@link LookAndFeel} and any auxiliary {@link LookAndFeel} * instances. */public class UIManager implements Serializable{  /**   * Represents the basic information about a {@link LookAndFeel} (LAF), so    * that a list of installed LAFs can be presented without actually loading    * the LAF class(es).   */  public static class LookAndFeelInfo  {    String name, clazz;	    /**     * Creates a new instance.     *      * @param name  the look and feel name.     * @param clazz  the look and feel class name.     */    public LookAndFeelInfo(String name, 			   String clazz)    {      this.name  = name;      this.clazz = clazz;    }    /**     * Returns the name of the look and feel.     *      * @return The name of the look and feel.     */    public String getName()    {      return name;    }        /**     * Returns the fully qualified class name for the {@link LookAndFeel}.     *      * @return The fully qualified class name for the {@link LookAndFeel}.     */    public String getClassName()    {      return clazz;    }    /**     * Returns a String representation of the LookAndFeelInfo object.     *     * @return a String representation of the LookAndFeelInfo object     */    public String toString()    {      StringBuffer s = new StringBuffer();      s.append(getClass().getName());      s.append('[');      s.append(getName());      s.append(' ');      s.append(getClassName());      s.append(']');      return s.toString();    }  }  private static final long serialVersionUID = -5547433830339189365L;  /** The installed look and feel(s). */  static LookAndFeelInfo [] installed = {    new LookAndFeelInfo("Metal", "javax.swing.plaf.metal.MetalLookAndFeel")  };  /** The installed auxiliary look and feels. */  static LookAndFeel[] auxLookAndFeels;    /** The current look and feel. */  static LookAndFeel currentLookAndFeel;    static UIDefaults currentUIDefaults;  /**   * UIDefaults set by the user.   */  static UIDefaults userUIDefaults;  /** Property change listener mechanism. */  static SwingPropertyChangeSupport listeners       = new SwingPropertyChangeSupport(UIManager.class);  static  {    String defaultlaf = System.getProperty("swing.defaultlaf");    try {      if (defaultlaf != null)        {          Class lafClass = Class.forName(defaultlaf);          LookAndFeel laf = (LookAndFeel) lafClass.newInstance();          setLookAndFeel(laf);        }      else        {          setLookAndFeel(new MetalLookAndFeel());        }    }    catch (Exception ex)      {        System.err.println("cannot initialize Look and Feel: " + defaultlaf);        System.err.println("error: " + ex.toString());        System.err.println("falling back to Metal Look and Feel");        try          {            setLookAndFeel(new MetalLookAndFeel());          }        catch (Exception ex2)        {          throw (Error) new AssertionError("There must be no problem installing"                                           + " the MetalLookAndFeel.")                                           .initCause(ex2);        }      }  }  /**   * Creates a new instance of the <code>UIManager</code>.  There is no need   * to construct an instance of this class, since all methods are static.   */  public UIManager()  {    // Do nothing here.  }  /**   * Add a <code>PropertyChangeListener</code> to the listener list.   *   * @param listener the listener to add   */  public static void addPropertyChangeListener(PropertyChangeListener listener)  {    listeners.addPropertyChangeListener(listener);  }  /**   * Remove a <code>PropertyChangeListener</code> from the listener list.   *   * @param listener the listener to remove   */  public static void removePropertyChangeListener(PropertyChangeListener           listener)  {    listeners.removePropertyChangeListener(listener);  }  /**   * Returns an array of all added <code>PropertyChangeListener</code> objects.   *   * @return an array of listeners   *   * @since 1.4   */  public static PropertyChangeListener[] getPropertyChangeListeners()  {    return listeners.getPropertyChangeListeners();  }  /**   * Add a {@link LookAndFeel} to the list of auxiliary look and feels.   *    * @param laf  the auxiliary look and feel (<code>null</code> not permitted).   *    * @throws NullPointerException if <code>laf</code> is <code>null</code>.   *    * @see #getAuxiliaryLookAndFeels()   */  public static void addAuxiliaryLookAndFeel(LookAndFeel laf)  {    if (laf == null)      throw new NullPointerException("Null 'laf' argument.");    if (auxLookAndFeels == null)      {        auxLookAndFeels = new LookAndFeel[1];        auxLookAndFeels[0] = laf;        return;      }	    LookAndFeel[] temp = new LookAndFeel[auxLookAndFeels.length + 1];    System.arraycopy(auxLookAndFeels, 0, temp, 0, auxLookAndFeels.length);			     auxLookAndFeels = temp;    auxLookAndFeels[auxLookAndFeels.length - 1] = laf;  }      /**   * Removes a {@link LookAndFeel} (LAF) from the list of auxiliary LAFs.   *    * @param laf  the LAF to remove.   *    * @return <code>true</code> if the LAF was removed, and <code>false</code>   *         otherwise.   */  public static boolean removeAuxiliaryLookAndFeel(LookAndFeel laf)  {    if (auxLookAndFeels == null)      return false;    int count = auxLookAndFeels.length;    if (count == 1 && auxLookAndFeels[0] == laf)      {        auxLookAndFeels = null;        return true;      }    for (int i = 0; i < count; i++)      {        if (auxLookAndFeels[i] == laf)          {            LookAndFeel[] temp = new LookAndFeel[auxLookAndFeels.length - 1];            if (i == 0)              {                System.arraycopy(auxLookAndFeels, 1, temp, 0, count - 1);                }            else if (i == count - 1)              {                System.arraycopy(auxLookAndFeels, 0, temp, 0, count - 1);              }            else               {                System.arraycopy(auxLookAndFeels, 0, temp, 0, i);                System.arraycopy(auxLookAndFeels, i + 1, temp, i,                         count - i - 1);              }            auxLookAndFeels = temp;            return true;          }		      }    return false;  }  /**   * Returns an array (possibly <code>null</code>) containing the auxiliary   * {@link LookAndFeel}s that are in use.  These are used by the    * {@link javax.swing.plaf.multi.MultiLookAndFeel} class.   *    * @return The auxiliary look and feels (possibly <code>null</code>).   *    * @see #addAuxiliaryLookAndFeel(LookAndFeel)   */  public static LookAndFeel[] getAuxiliaryLookAndFeels()  {    return auxLookAndFeels;  }  /**   * Returns an object from the {@link UIDefaults} table for the current   * {@link LookAndFeel}.   *    * @param key  the key.   *    * @return The object.   */  public static Object get(Object key)  {    Object val = null;    if (userUIDefaults != null)      val = userUIDefaults.get(key);    if (val == null)      val = getLookAndFeelDefaults().get(key);    return val;  }  /**   * Returns an object from the {@link UIDefaults} table for the current   * {@link LookAndFeel}.   *    * @param key  the key.   *    * @return The object.   */  public static Object get(Object key, Locale locale)  {    Object val = null;    if (userUIDefaults != null)      val = userUIDefaults.get(key, locale);    if (val == null)      val = getLookAndFeelDefaults().get(key, locale);    return val;  }  /**   * Returns a boolean value from the defaults table,   * <code>false</code> if key is not present.   *   * @since 1.4   */  public static boolean getBoolean(Object key)  {

⌨️ 快捷键说明

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