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

📄 basiclookandfeel.java

📁 java jdk 1.4的源码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/* * @(#)BasicLookAndFeel.java	1.208 03/01/23 * * Copyright 2003 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */package javax.swing.plaf.basic;import java.awt.Font;import java.awt.Color;import java.awt.SystemColor;import java.awt.event.*;import java.awt.Insets;import java.awt.Component;import java.awt.Container;import java.awt.FocusTraversalPolicy;import java.net.URL;import java.io.*;import java.awt.Dimension;import java.awt.KeyboardFocusManager;import java.util.*;import java.lang.reflect.*;import javax.sound.sampled.*;import javax.swing.LookAndFeel;import javax.swing.AbstractAction;import javax.swing.Action;import javax.swing.ActionMap;import javax.swing.BorderFactory;import javax.swing.JComponent;import javax.swing.ImageIcon;import javax.swing.UIDefaults;import javax.swing.UIManager;import javax.swing.KeyStroke;import javax.swing.JTextField;import javax.swing.DefaultListCellRenderer;import javax.swing.FocusManager;import javax.swing.LayoutFocusTraversalPolicy;import javax.swing.SwingUtilities;import javax.swing.border.*;import javax.swing.plaf.*;import javax.swing.text.JTextComponent;import javax.swing.text.DefaultEditorKit;/** * Implements the a standard base LookAndFeel class from which * standard desktop LookAndFeel classes (JLF, Mac, Windows, etc.) * can be derived.  This class cannot be instantiated directly, * however the UI classes "Basic" defines can be. * <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}. * * @version 1.208 01/23/03 * @author unattributed */public abstract class BasicLookAndFeel extends LookAndFeel implements Serializable{    /**     * Lock used when manipulating clipPlaying.     */    private Object audioLock = new Object();    /**     * The Clip that is currently playing (set in AudioAction).     */    private Clip clipPlaying;    public UIDefaults getDefaults() {	UIDefaults table = new UIDefaults();	initClassDefaults(table);	initSystemColorDefaults(table);	initComponentDefaults(table);	return table;    }    /**     * Initialize the uiClassID to BasicComponentUI mapping.     * The JComponent classes define their own uiClassID constants     * (see AbstractComponent.getUIClassID).  This table must     * map those constants to a BasicComponentUI class of the     * appropriate type.     *     * @see #getDefaults     */    protected void initClassDefaults(UIDefaults table)    {	String basicPackageName = "javax.swing.plaf.basic.";	Object[] uiDefaults = {		   "ButtonUI", basicPackageName + "BasicButtonUI",		 "CheckBoxUI", basicPackageName + "BasicCheckBoxUI",             "ColorChooserUI", basicPackageName + "BasicColorChooserUI",       "FormattedTextFieldUI", basicPackageName + "BasicFormattedTextFieldUI",		  "MenuBarUI", basicPackageName + "BasicMenuBarUI",		     "MenuUI", basicPackageName + "BasicMenuUI",		 "MenuItemUI", basicPackageName + "BasicMenuItemUI",	 "CheckBoxMenuItemUI", basicPackageName + "BasicCheckBoxMenuItemUI",      "RadioButtonMenuItemUI", basicPackageName + "BasicRadioButtonMenuItemUI",	      "RadioButtonUI", basicPackageName + "BasicRadioButtonUI",	     "ToggleButtonUI", basicPackageName + "BasicToggleButtonUI",		"PopupMenuUI", basicPackageName + "BasicPopupMenuUI",	      "ProgressBarUI", basicPackageName + "BasicProgressBarUI",		"ScrollBarUI", basicPackageName + "BasicScrollBarUI",	       "ScrollPaneUI", basicPackageName + "BasicScrollPaneUI",		"SplitPaneUI", basicPackageName + "BasicSplitPaneUI",		   "SliderUI", basicPackageName + "BasicSliderUI",		"SeparatorUI", basicPackageName + "BasicSeparatorUI",		  "SpinnerUI", basicPackageName + "BasicSpinnerUI",	 "ToolBarSeparatorUI", basicPackageName + "BasicToolBarSeparatorUI",       "PopupMenuSeparatorUI", basicPackageName + "BasicPopupMenuSeparatorUI",	       "TabbedPaneUI", basicPackageName + "BasicTabbedPaneUI",		 "TextAreaUI", basicPackageName + "BasicTextAreaUI",		"TextFieldUI", basicPackageName + "BasicTextFieldUI",	    "PasswordFieldUI", basicPackageName + "BasicPasswordFieldUI",		 "TextPaneUI", basicPackageName + "BasicTextPaneUI",               "EditorPaneUI", basicPackageName + "BasicEditorPaneUI",		     "TreeUI", basicPackageName + "BasicTreeUI",		    "LabelUI", basicPackageName + "BasicLabelUI",		     "ListUI", basicPackageName + "BasicListUI",		  "ToolBarUI", basicPackageName + "BasicToolBarUI",		  "ToolTipUI", basicPackageName + "BasicToolTipUI",		 "ComboBoxUI", basicPackageName + "BasicComboBoxUI",		    "TableUI", basicPackageName + "BasicTableUI",	      "TableHeaderUI", basicPackageName + "BasicTableHeaderUI",	    "InternalFrameUI", basicPackageName + "BasicInternalFrameUI",	      "DesktopPaneUI", basicPackageName + "BasicDesktopPaneUI",	      "DesktopIconUI", basicPackageName + "BasicDesktopIconUI",	       "OptionPaneUI", basicPackageName + "BasicOptionPaneUI",	            "PanelUI", basicPackageName + "BasicPanelUI",		 "ViewportUI", basicPackageName + "BasicViewportUI",		 "RootPaneUI", basicPackageName + "BasicRootPaneUI",	};	table.putDefaults(uiDefaults);    }    /**     * Load the SystemColors into the defaults table.  The keys     * for SystemColor defaults are the same as the names of     * the public fields in SystemColor.  If the table is being     * created on a native Windows platform we use the SystemColor     * values, otherwise we create color objects whose values match     * the defaults Windows95 colors.     */    protected void initSystemColorDefaults(UIDefaults table)    {	String[] defaultSystemColors = {  	        "desktop", "#005C5C", /* Color of the desktop background */	  "activeCaption", "#000080", /* Color for captions (title bars) when they are active. */      "activeCaptionText", "#FFFFFF", /* Text color for text in captions (title bars). */    "activeCaptionBorder", "#C0C0C0", /* Border color for caption (title bar) window borders. */        "inactiveCaption", "#808080", /* Color for captions (title bars) when not active. */    "inactiveCaptionText", "#C0C0C0", /* Text color for text in inactive captions (title bars). */  "inactiveCaptionBorder", "#C0C0C0", /* Border color for inactive caption (title bar) window borders. */	         "window", "#FFFFFF", /* Default color for the interior of windows */	   "windowBorder", "#000000", /* ??? */	     "windowText", "#000000", /* ??? */		   "menu", "#C0C0C0", /* Background color for menus */	       "menuText", "#000000", /* Text color for menus  */		   "text", "#C0C0C0", /* Text background color */	       "textText", "#000000", /* Text foreground color */	  "textHighlight", "#000080", /* Text background color when selected */      "textHighlightText", "#FFFFFF", /* Text color when selected */       "textInactiveText", "#808080", /* Text color when disabled */	        "control", "#C0C0C0", /* Default color for controls (buttons, sliders, etc) */	    "controlText", "#000000", /* Default color for text in controls */       "controlHighlight", "#C0C0C0", /* Specular highlight (opposite of the shadow) */     "controlLtHighlight", "#FFFFFF", /* Highlight color for controls */	  "controlShadow", "#808080", /* Shadow color for controls */        "controlDkShadow", "#000000", /* Dark shadow color for controls */	      "scrollbar", "#E0E0E0", /* Scrollbar background (usually the "track") */		   "info", "#FFFFE1", /* ??? */	       "infoText", "#000000"  /* ??? */	};	loadSystemColors(table, defaultSystemColors, isNativeLookAndFeel());    }    /**     * If this is the native look and feel the initial values for the     * system color properties are the same as the SystemColor constants.     * If not we use the integer color values in the <code>systemColors</code>     * argument.     */    protected void loadSystemColors(UIDefaults table, String[] systemColors, boolean useNative)    {	/* PENDING(hmuller) We don't load the system colors below because	 * they're not reliable.  Hopefully we'll be able to do better in	 * a future version of AWT.	 */	if (useNative) {	    for(int i = 0; i < systemColors.length; i += 2) {		Color color = Color.black;		try {		    String name = systemColors[i];		    color = (Color)(SystemColor.class.getField(name).get(null));		} catch (Exception e) {		}		table.put(systemColors[i], new ColorUIResource(color));	    }	} else {	    for(int i = 0; i < systemColors.length; i += 2) {		Color color = Color.black;		try {		    color = Color.decode(systemColors[i + 1]);		}		catch(NumberFormatException e) {		    e.printStackTrace();		}		table.put(systemColors[i], new ColorUIResource(color));	    }	}    }    /**     * Initialize the defaults table with the name of the ResourceBundle     * used for getting localized defaults.  Also initialize the default     * locale used when no locale is passed into UIDefaults.get().  The     * default locale should generally not be relied upon. It is here for     * compatability with releases prior to 1.4.     */    private void initResourceBundle(UIDefaults table) {        table.setDefaultLocale( Locale.getDefault() );        table.addResourceBundle( "com.sun.swing.internal.plaf.basic.resources.basic" );    }    protected void initComponentDefaults(UIDefaults table)    {        initResourceBundle(table);	// *** Shared Integers	Integer fiveHundred = new Integer(500);	// *** Shared Fonts	Integer twelve = new Integer(12);	Integer fontPlain = new Integer(Font.PLAIN);	Integer fontBold = new Integer(Font.BOLD);	Object dialogPlain12 = new UIDefaults.ProxyLazyValue(			  "javax.swing.plaf.FontUIResource",			  null,			  new Object[] {"Dialog", fontPlain, twelve});	Object serifPlain12 = new UIDefaults.ProxyLazyValue(			  "javax.swing.plaf.FontUIResource",			  null,			  new Object[] {"Serif", fontPlain, twelve});	Object sansSerifPlain12 =  new UIDefaults.ProxyLazyValue(			  "javax.swing.plaf.FontUIResource",			  null,			  new Object[] {"SansSerif", fontPlain, twelve});	Object monospacedPlain12 = new UIDefaults.ProxyLazyValue(			  "javax.swing.plaf.FontUIResource",			  null,			  new Object[] {"MonoSpaced", fontPlain, twelve});	Object dialogBold12 = new UIDefaults.ProxyLazyValue(			  "javax.swing.plaf.FontUIResource",			  null,			  new Object[] {"Dialog", fontBold, twelve});	// *** Shared Colors	ColorUIResource red = new ColorUIResource(Color.red);	ColorUIResource black = new ColorUIResource(Color.black);        ColorUIResource white = new ColorUIResource(Color.white);	ColorUIResource yellow = new ColorUIResource(Color.yellow);        ColorUIResource gray = new ColorUIResource(Color.gray);	ColorUIResource lightGray = new ColorUIResource(Color.lightGray);	ColorUIResource darkGray = new ColorUIResource(Color.darkGray);	ColorUIResource scrollBarTrack = new ColorUIResource(224, 224, 224);        // *** Shared Insets        InsetsUIResource zeroInsets = new InsetsUIResource(0,0,0,0);        // *** Shared Borders	Object marginBorder = new UIDefaults.ProxyLazyValue(			  "javax.swing.plaf.basic.BasicBorders$MarginBorder");	Object etchedBorder = new UIDefaults.ProxyLazyValue(			  "javax.swing.plaf.BorderUIResource",			  "getEtchedBorderUIResource");        Object loweredBevelBorder = new UIDefaults.ProxyLazyValue(			  "javax.swing.plaf.BorderUIResource",			  "getLoweredBevelBorderUIResource");		Object popupMenuBorder = new UIDefaults.ProxyLazyValue(			  "javax.swing.plaf.basic.BasicBorders",			  "getInternalFrameBorder");        Object blackLineBorder = new UIDefaults.ProxyLazyValue(			  "javax.swing.plaf.BorderUIResource",			  "getBlackLineBorderUIResource");	Object focusCellHighlightBorder = new UIDefaults.ProxyLazyValue(			  "javax.swing.plaf.BorderUIResource$LineBorderUIResource",			  null,			  new Object[] {yellow});	Object tableHeaderBorder = new UIDefaults.ProxyLazyValue(			  "javax.swing.plaf.BorderUIResource$BevelBorderUIResource",			  null,			  new Object[] { new Integer(BevelBorder.RAISED),

⌨️ 快捷键说明

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