📄 basiclookandfeel.java
字号:
"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()); } /** * Populates {@code table} with the {@code name-color} pairs in * {@code systemColors}. Refer to * {@link #initSystemColorDefaults(UIDefaults)} for details on * the format of {@code systemColors}. * <p> * An entry is added to {@code table} for each of the {@code name-color} * pairs in {@code systemColors}. The entry key is * the {@code name} of the {@code name-color} pair. * <p> * The value of the entry corresponds to the {@code color} of the * {@code name-color} pair. The value of the entry is calculated * in one of two ways. With either approach the value is always a * {@code ColorUIResource}. * <p> * If {@code useNative} is {@code false}, the {@code color} is * created by using {@code Color.decode} to convert the {@code * String} into a {@code Color}. If {@code decode} can not convert * the {@code String} into a {@code Color} ({@code * NumberFormatException} is thrown) then a {@code * ColorUIResource} of black is used. * <p> * If {@code useNative} is {@code true}, the {@code color} is the * value of the field in {@code SystemColor} with the same name as * the {@code name} of the {@code name-color} pair. If the field * is not valid, a {@code ColorUIResource} of black is used. * * @param table the {@code UIDefaults} object the values are added to * @param systemColors array of {@code name-color} pairs as described * in {@link #initSystemColorDefaults(UIDefaults)} * @param useNative whether the color is obtained from {@code SystemColor} * or {@code Color.decode} * @throws NullPointerException if {@code systemColors} is {@code null}; or * {@code systemColors} is not empty, and {@code table} is * {@code null}; or one of the * names of the {@code name-color} pairs is {@code null}; or * {@code useNative} is {@code false} and one of the * {@code colors} of the {@code name-color} pairs is {@code null} * @throws ArrayIndexOutOfBoundsException if {@code useNative} is * {@code false} and {@code systemColors.length} is odd * * @see #initSystemColorDefaults(javax.swing.UIDefaults) * @see java.awt.SystemColor * @see java.awt.Color#decode(String) */ 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" ); } /** * Populates {@code table} with the defaults for the basic look and * feel. * * @param table the {@code UIDefaults} to add the values to * @throws NullPointerException if {@code table} is {@code null} */ protected void initComponentDefaults(UIDefaults table) { initResourceBundle(table); // *** Shared Integers Integer fiveHundred = new Integer(500); // *** Shared Longs Long oneThousand = new Long(1000); // *** Shared Fonts Integer twelve = new Integer(12); Integer fontPlain = new Integer(Font.PLAIN); Integer fontBold = new Integer(Font.BOLD); Object dialogPlain12 = new SwingLazyValue( "javax.swing.plaf.FontUIResource", null, new Object[] {Font.DIALOG, fontPlain, twelve}); Object serifPlain12 = new SwingLazyValue( "javax.swing.plaf.FontUIResource", null, new Object[] {Font.SERIF, fontPlain, twelve}); Object sansSerifPlain12 = new SwingLazyValue( "javax.swing.plaf.FontUIResource", null, new Object[] {Font.SANS_SERIF, fontPlain, twelve}); Object monospacedPlain12 = new SwingLazyValue( "javax.swing.plaf.FontUIResource", null, new Object[] {Font.MONOSPACED, fontPlain, twelve}); Object dialogBold12 = new SwingLazyValue( "javax.swing.plaf.FontUIResource", null, new Object[] {Font.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); Color control = table.getColor("control"); Color controlDkShadow = table.getColor("controlDkShadow"); Color controlHighlight = table.getColor("controlHighlight"); Color controlLtHighlight = table.getColor("controlLtHighlight"); Color controlShadow = table.getColor("controlShadow"); Color controlText = table.getColor("controlText"); Color menu = table.getColor("menu"); Color menuText = table.getColor("menuText"); Color textHighlight = table.getColor("textHighlight"); Color textHighlightText = table.getColor("textHighlightText"); Color textInactiveText = table.getColor("textInactiveText"); Color textText = table.getColor("textText"); Color window = table.getColor("window"); // *** Shared Insets InsetsUIResource zeroInsets = new InsetsUIResource(0,0,0,0); InsetsUIResource twoInsets = new InsetsUIResource(2,2,2,2); InsetsUIResource threeInsets = new InsetsUIResource(3,3,3,3); // *** Shared Borders Object marginBorder = new SwingLazyValue( "javax.swing.plaf.basic.BasicBorders$MarginBorder"); Object etchedBorder = new SwingLazyValue( "javax.swing.plaf.BorderUIResource", "getEtchedBorderUIResource"); Object loweredBevelBorder = new SwingLazyValue( "javax.swing.plaf.BorderUIResource", "getLoweredBevelBorderUIResource"); Object popupMenuBorder = new SwingLazyValue( "javax.swing.plaf.basic.BasicBorders", "getInternalFrameBorder"); Object blackLineBorder = new SwingLazyValue( "javax.swing.plaf.BorderUIResource", "getBlackLineBorderUIResource"); Object focusCellHighlightBorder = new SwingLazyValue( "javax.swing.plaf.BorderUIResource$LineBorderUIResource", null, new Object[] {yellow}); Object tableHeaderBorder = new SwingLazyValue( "javax.swing.plaf.BorderUIResource$BevelBorderUIResource", null, new Object[] { new Integer(BevelBorder.RAISED), controlLtHighlight, control, controlDkShadow, controlShadow }); // *** Button value objects Object buttonBorder = new SwingLazyValue( "javax.swing.plaf.basic.BasicBorders", "getButtonBorder"); Object buttonToggleBorder = new SwingLazyValue( "javax.swing.plaf.basic.BasicBorders", "getToggleButtonBorder"); Object radioButtonBorder = new SwingLazyValue( "javax.swing.plaf.basic.BasicBorders", "getRadioButtonBorder"); // *** FileChooser / FileView value objects Object newFolderIcon = SwingUtilities2.makeIcon(getClass(), BasicLookAndFeel.class, "icons/NewFolder.gif"); Object upFolderIcon = SwingUtilities2.makeIcon(getClass(), BasicLookAndFeel.class, "icons/UpFolder.gif"); Object homeFolderIcon = SwingUtilities2.makeIcon(getClass(), BasicLookAndFeel.class, "icons/HomeFolder.gif"); Object detailsViewIcon = SwingUtilities2.makeIcon(getClass(), BasicLookAndFeel.class, "icons/DetailsView.gif"); Object listViewIcon = SwingUtilities2.makeIcon(getClass(), BasicLookAndFeel.class, "icons/ListView.gif"); Object directoryIcon = SwingUtilities2.makeIcon(getClass(), BasicLookAndFeel.class, "icons/Directory.gif"); Object fileIcon = SwingUtilities2.makeIcon(getClass(), BasicLookAndFeel.class, "icons/File.gif"); Object computerIcon = SwingUtilities2.makeIcon(getClass(), BasicLookAndFeel.class, "icons/Computer.gif"); Object hardDriveIcon = SwingUtilities2.makeIcon(getClass(), BasicLookAndFeel.class, "icons/HardDrive.gif"); Object floppyDriveIcon = SwingUtilities2.makeIcon(getClass(), BasicLookAndFeel.class, "icons/FloppyDrive.gif"); // *** InternalFrame value objects Object internalFrameBorder = new SwingLazyValue( "javax.swing.plaf.basic.BasicBorders", "getInternalFrameBorder"); // *** List value objects Object listCellRendererActiveValue = new UIDefaults.ActiveValue() { public Object createValue(UIDefaults table) { return new DefaultListCellRenderer.UIResource(); } }; // *** Menus value objects Object menuBarBorder = new SwingLazyValue( "javax.swing.plaf.basic.BasicBorders", "getMenuBarBorder"); Object menuItemCheckIcon = new SwingLazyValue( "javax.swing.plaf.basic.BasicIconFactory", "getMenuItemCheckIcon"); Object menuItemArrowIcon = new SwingLazyValue( "javax.swing.plaf.basic.BasicIconFactory", "getMenuItemArrowIcon"); Object menuArrowIcon = new SwingLazyValue( "javax.swing.plaf.basic.BasicIconFactory", "getMenuArrowIcon"); Object checkBoxIcon = new SwingLazyValue( "javax.swing.plaf.basic.BasicIconFactory",
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -