1 /* MetalLookAndFeel.java
2 Copyright (C) 2002, 2005 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package javax.swing.plaf.metal;
41 import java.awt.Color;
44 import javax.swing.LookAndFeel;
45 import javax.swing.UIDefaults;
46 import javax.swing.UIManager;
47 import javax.swing.plaf.BorderUIResource;
48 import javax.swing.plaf.ColorUIResource;
49 import javax.swing.plaf.FontUIResource;
50 import javax.swing.plaf.InsetsUIResource;
51 import javax.swing.plaf.BorderUIResource.LineBorderUIResource;
52 import javax.swing.plaf.basic.BasicLookAndFeel;
56 * A custom look and feel that is designed to look similar across different
57 * operating systems. To install this look and feel, add the following code
58 * (or something similar) near the start of your application:</p>
62 * UIManager.setLookAndFeel(new MetalLookAndFeel());
64 * catch (UnsupportedLookAndFeelException e)
66 * e.printStackTrace();
69 public class MetalLookAndFeel extends BasicLookAndFeel
71 private static final long serialVersionUID = 6680646159193457980L;
73 /** The current theme. */
74 private static MetalTheme theme;
76 /** The look and feel defaults. */
77 private UIDefaults LAF_defaults;
80 * Creates a new instance of the Metal look and feel.
82 public MetalLookAndFeel()
88 * Sets the current theme to a new instance of {@link DefaultMetalTheme}.
90 protected void createDefaultTheme()
93 setCurrentTheme(new DefaultMetalTheme());
97 * Returns <code>false</code> to indicate that this look and feel does not
98 * attempt to emulate the look and feel of native applications on the host
101 * @return <code>false</code>.
103 public boolean isNativeLookAndFeel()
109 * Returns <code>true</code> to indicate that this look and feel is supported
112 * @return <code>true</code>.
114 public boolean isSupportedLookAndFeel()
120 * Returns a string describing the look and feel. In this case, the method
121 * returns "Metal look and feel".
123 * @return A string describing the look and feel.
125 public String getDescription()
127 return "The Java(tm) Look and Feel";
131 * Returns the look and feel identifier.
133 * @return "MetalLookAndFeel".
135 public String getID()
141 * Returns the look and feel name.
143 * @return "MetalLookAndFeel".
145 public String getName()
150 public UIDefaults getDefaults()
152 if (LAF_defaults == null)
154 LAF_defaults = super.getDefaults();
156 // add custom theme entries to the table
158 theme.addCustomEntriesToTable(LAF_defaults);
161 // Returns the default values for this look and feel.
166 * Returns the accelerator foreground color from the installed theme.
168 * @return The accelerator foreground color.
170 public static ColorUIResource getAcceleratorForeground()
173 return theme.getAcceleratorForeground();
178 * Returns the accelerator selected foreground color from the installed
181 * @return The accelerator selected foreground color.
183 public static ColorUIResource getAcceleratorSelectedForeground()
186 return theme.getAcceleratorSelectedForeground();
191 * Returns the color black from the installed theme.
193 * @return The color black.
195 public static ColorUIResource getBlack()
198 return theme.getBlack();
203 * Returns the control color from the installed theme.
205 * @return The control color.
207 public static ColorUIResource getControl()
210 return theme.getControl();
215 * Returns the color used for dark shadows on controls, from the installed
218 * @return The color used for dark shadows on controls.
220 public static ColorUIResource getControlDarkShadow()
223 return theme.getControlDarkShadow();
228 * Returns the color used for disabled controls, from the installed theme.
230 * @return The color used for disabled controls.
232 public static ColorUIResource getControlDisabled()
235 return theme.getControlDisabled();
240 * Returns the color used to draw highlights for controls, from the installed
243 * @return The color used to draw highlights for controls.
245 public static ColorUIResource getControlHighlight()
248 return theme.getControlHighlight();
253 * Returns the color used to display control info, from the installed
256 * @return The color used to display control info.
258 public static ColorUIResource getControlInfo()
261 return theme.getControlInfo();
266 * Returns the color used to draw shadows for controls, from the installed
269 * @return The color used to draw shadows for controls.
271 public static ColorUIResource getControlShadow()
274 return theme.getControlShadow();
279 * Returns the color used for text on controls, from the installed theme.
281 * @return The color used for text on controls.
283 public static ColorUIResource getControlTextColor()
286 return theme.getControlTextColor();
291 * Returns the font used for text on controls, from the installed theme.
293 * @return The font used for text on controls.
295 public static FontUIResource getControlTextFont()
298 return theme.getControlTextFont();
303 * Returns the color used for the desktop background, from the installed
306 * @return The color used for the desktop background.
308 public static ColorUIResource getDesktopColor()
311 return theme.getDesktopColor();
316 * Returns the color used to draw focus highlights, from the installed
319 * @return The color used to draw focus highlights.
321 public static ColorUIResource getFocusColor()
324 return theme.getFocusColor();
329 * Returns the color used to draw highlighted text, from the installed
332 * @return The color used to draw highlighted text.
334 public static ColorUIResource getHighlightedTextColor()
337 return theme.getHighlightedTextColor();
342 * Returns the color used to draw text on inactive controls, from the
345 * @return The color used to draw text on inactive controls.
347 public static ColorUIResource getInactiveControlTextColor()
350 return theme.getInactiveControlTextColor();
355 * Returns the color used to draw inactive system text, from the installed
358 * @return The color used to draw inactive system text.
360 public static ColorUIResource getInactiveSystemTextColor()
363 return theme.getInactiveSystemTextColor();
368 * Returns the background color for menu items, from the installed theme.
370 * @return The background color for menu items.
372 * @see #getMenuSelectedBackground()
374 public static ColorUIResource getMenuBackground()
377 return theme.getMenuBackground();
382 * Returns the foreground color for disabled menu items, from the installed
385 * @return The foreground color for disabled menu items.
387 * @see #getMenuForeground()
389 public static ColorUIResource getMenuDisabledForeground()
392 return theme.getMenuDisabledForeground();
397 * Returns the foreground color for menu items, from the installed theme.
399 * @return The foreground color for menu items.
401 * @see #getMenuDisabledForeground()
402 * @see #getMenuSelectedForeground()
404 public static ColorUIResource getMenuForeground()
407 return theme.getMenuForeground();
412 * Returns the background color for selected menu items, from the installed
415 * @return The background color for selected menu items.
417 * @see #getMenuBackground()
419 public static ColorUIResource getMenuSelectedBackground()
422 return theme.getMenuSelectedBackground();
427 * Returns the foreground color for selected menu items, from the installed
430 * @return The foreground color for selected menu items.
432 * @see #getMenuForeground()
434 public static ColorUIResource getMenuSelectedForeground()
437 return theme.getMenuSelectedForeground();
442 * Returns the font used for text in menus, from the installed theme.
444 * @return The font used for text in menus.
446 public static FontUIResource getMenuTextFont()
449 return theme.getMenuTextFont();
454 * Returns the primary color for controls, from the installed theme.
456 * @return The primary color for controls.
458 public static ColorUIResource getPrimaryControl()
461 return theme.getPrimaryControl();
466 * Returns the primary color for the dark shadow on controls, from the
469 * @return The primary color for the dark shadow on controls.
471 public static ColorUIResource getPrimaryControlDarkShadow()
474 return theme.getPrimaryControlDarkShadow();
479 * Returns the primary color for the highlight on controls, from the
482 * @return The primary color for the highlight on controls.
484 public static ColorUIResource getPrimaryControlHighlight()
487 return theme.getPrimaryControlHighlight();
492 * Returns the primary color for the information on controls, from the
495 * @return The primary color for the information on controls.
497 public static ColorUIResource getPrimaryControlInfo()
500 return theme.getPrimaryControlInfo();
505 * Returns the primary color for the shadow on controls, from the installed
508 * @return The primary color for the shadow on controls.
510 public static ColorUIResource getPrimaryControlShadow()
513 return theme.getPrimaryControlShadow();
518 * Returns the background color for separators, from the installed theme.
520 * @return The background color for separators.
522 public static ColorUIResource getSeparatorBackground()
525 return theme.getSeparatorBackground();
530 * Returns the foreground color for separators, from the installed theme.
532 * @return The foreground color for separators.
534 public static ColorUIResource getSeparatorForeground()
537 return theme.getSeparatorForeground();
542 * Returns the font used for sub text, from the installed theme.
544 * @return The font used for sub text.
546 public static FontUIResource getSubTextFont()
549 return theme.getSubTextFont();
554 * Returns the color used for system text, from the installed theme.
556 * @return The color used for system text.
558 public static ColorUIResource getSystemTextColor()
561 return theme.getSystemTextColor();
566 * Returns the font used for system text, from the installed theme.
568 * @return The font used for system text.
570 public static FontUIResource getSystemTextFont()
573 return theme.getSystemTextFont();
578 * Returns the color used to highlight text, from the installed theme.
580 * @return The color used to highlight text.
582 public static ColorUIResource getTextHighlightColor()
585 return theme.getTextHighlightColor();
590 * Returns the color used to display user text, from the installed theme.
592 * @return The color used to display user text.
594 public static ColorUIResource getUserTextColor()
597 return theme.getUserTextColor();
602 * Returns the font used for user text, obtained from the current theme.
604 * @return The font used for user text.
606 public static FontUIResource getUserTextFont()
609 return theme.getUserTextFont();
614 * Returns the color used for white, from the installed theme.
616 * @return The color used for white.
618 public static ColorUIResource getWhite()
621 return theme.getWhite();
626 * Returns the window background color, from the installed theme.
628 * @return The window background color.
630 public static ColorUIResource getWindowBackground()
633 return theme.getWindowBackground();
638 * Returns the window title background color, from the installed theme.
640 * @return The window title background color.
642 public static ColorUIResource getWindowTitleBackground()
645 return theme.getWindowTitleBackground();
650 * Returns the window title font from the current theme.
652 * @return The window title font.
656 public static FontUIResource getWindowTitleFont()
659 return theme.getWindowTitleFont();
664 * Returns the window title foreground color, from the installed theme.
666 * @return The window title foreground color.
668 public static ColorUIResource getWindowTitleForeground()
671 return theme.getWindowTitleForeground();
676 * Returns the background color for an inactive window title, from the
679 * @return The background color for an inactive window title.
681 public static ColorUIResource getWindowTitleInactiveBackground()
684 return theme.getWindowTitleInactiveBackground();
689 * Returns the foreground color for an inactive window title, from the
692 * @return The foreground color for an inactive window title.
694 public static ColorUIResource getWindowTitleInactiveForeground()
697 return theme.getWindowTitleInactiveForeground();
702 * Sets the current theme for the look and feel. Note that the theme must be
703 * set <em>before</em> the look and feel is installed. To change the theme
704 * for an already running application that is using the
705 * {@link MetalLookAndFeel}, first set the theme with this method, then
706 * create a new instance of {@link MetalLookAndFeel} and install it in the
707 * usual way (see {@link UIManager#setLookAndFeel(LookAndFeel)}).
709 * @param theme the theme (<code>null</code> not permitted).
711 * @throws NullPointerException if <code>theme</code> is <code>null</code>.
713 public static void setCurrentTheme(MetalTheme theme)
716 throw new NullPointerException("Null 'theme' not permitted.");
717 MetalLookAndFeel.theme = theme;
721 * Sets the ComponentUI classes for all Swing components to the Metal
724 * In particular this sets the following keys:
728 * <th>Key</th><th>Value</th>
730 * <td>ButtonUI</td><td>{@link MetalButtonUI}</td>
732 * <td>CheckBoxUI</td><td>{@link MetalCheckBoxUI}</td>
734 * <td>ComboBoxUI</td><td>{@link MetalComboBoxUI}</td>
736 * <td>DesktopIconUI</td><td>{@link MetalDesktopIconUI}</td>
738 * <td>InternalFrameUI</td><td>{@link MetalInternalFrameUI}</td>
740 * <td>LabelUI</td><td>{@link MetalLabelUI}</td>
742 * <td>PopupMenuSeparatorUI</td><td>{@link MetalPopupMenuSeparatorUI}</td>
744 * <td>ProgressBarUI</td><td>{@link MetalProgressBarUI}</td>
746 * <td>RadioButtonUI</td><td>{@link MetalRadioButtonUI}</td>
748 * <td>RootPaneUI</td><td>{@link MetalRootPaneUI}</td>
750 * <td>ScrollBarUI</td><td>{@link MetalScrollBarUI}</td>
752 * <td>ScrollPaneUI</td><td>{@link MetalScrollPaneUI}</td>
754 * <td>SeparatorUI</td><td>{@link MetalSeparatorUI}</td>
756 * <td>SliderUI</td><td>{@link MetalSliderUI}</td>
758 * <td>SplitPaneUI</td><td>{@link MetalSplitPaneUI}</td>
760 * <td>TabbedPaneUI</td><td>{@link MetalTabbedPaneUI}</td>
762 * <td>TextFieldUI</td><td>{@link MetalTextFieldUI}</td>
764 * <td>ToggleButtonUI</td><td>{@link MetalToggleButtonUI}</td>
766 * <td>ToolBarUI</td><td>{@link MetalToolBarUI}</td>
768 * <td>ToolTipUI</td><td>{@link MetalToolTipUI}</td>
770 * <td>TreeUI</td><td>{@link MetalTreeUI}</td>
774 * @param defaults the UIDefaults where the class defaults are added
776 protected void initClassDefaults(UIDefaults defaults)
778 super.initClassDefaults(defaults);
782 // Initialize Class Defaults
783 uiDefaults = new Object[] {
784 "ButtonUI", "javax.swing.plaf.metal.MetalButtonUI",
785 "CheckBoxUI", "javax.swing.plaf.metal.MetalCheckBoxUI",
786 "ComboBoxUI", "javax.swing.plaf.metal.MetalComboBoxUI",
787 "DesktopIconUI", "javax.swing.plaf.metal.MetalDesktopIconUI",
788 "FileChooserUI", "javax.swing.plaf.metal.MetalFileChooserUI",
789 "InternalFrameUI", "javax.swing.plaf.metal.MetalInternalFrameUI",
790 "LabelUI", "javax.swing.plaf.metal.MetalLabelUI",
791 "MenuBarUI", "javax.swing.plaf.metal.MetalMenuBarUI",
792 "PopupMenuSeparatorUI",
793 "javax.swing.plaf.metal.MetalPopupMenuSeparatorUI",
794 "ProgressBarUI", "javax.swing.plaf.metal.MetalProgressBarUI",
795 "RadioButtonUI", "javax.swing.plaf.metal.MetalRadioButtonUI",
796 "RootPaneUI", "javax.swing.plaf.metal.MetalRootPaneUI",
797 "ScrollBarUI", "javax.swing.plaf.metal.MetalScrollBarUI",
798 "ScrollPaneUI", "javax.swing.plaf.metal.MetalScrollPaneUI",
799 "SeparatorUI", "javax.swing.plaf.metal.MetalSeparatorUI",
800 "SliderUI", "javax.swing.plaf.metal.MetalSliderUI",
801 "SplitPaneUI", "javax.swing.plaf.metal.MetalSplitPaneUI",
802 "TabbedPaneUI", "javax.swing.plaf.metal.MetalTabbedPaneUI",
803 "TextFieldUI", "javax.swing.plaf.metal.MetalTextFieldUI",
804 "ToggleButtonUI", "javax.swing.plaf.metal.MetalToggleButtonUI",
805 "ToolBarUI", "javax.swing.plaf.metal.MetalToolBarUI",
806 "ToolTipUI", "javax.swing.plaf.metal.MetalToolTipUI",
807 "TreeUI", "javax.swing.plaf.metal.MetalTreeUI",
809 // Add Class Defaults to UI Defaults table
810 defaults.putDefaults(uiDefaults);
814 * Initializes the component defaults for the Metal Look & Feel.
816 * In particular this sets the following keys (the colors are given
817 * as RGB hex values):
821 * <th>Key</th><th>Value</th>
823 * <td>Button.background</td><td>0xcccccc</td>
825 * <td>Button.border</td><td>{@link MetalBorders#getButtonBorder()}</td>
827 * <td>Button.font</td><td>{@link #getControlTextFont}</td>
829 * <td>Button.margin</td><td><code>new java.awt.Insets(2, 14, 2, 14)</code>
832 * <td>CheckBox.background</td><td>0xcccccc</td>
834 * <td>CheckBoxMenuItem.background</td><td>0xcccccc</td>
836 * <td>ToolBar.background</td><td>0xcccccc</td>
838 * <td>Panel.background</td><td>0xcccccc</td>
840 * <td>Slider.background</td><td>0xcccccc</td>
842 * <td>OptionPane.background</td><td>0xcccccc</td>
844 * <td>ProgressBar.background</td><td>0xcccccc</td>
846 * <td>TabbedPane.background</td><td>0xcccccc</td>
848 * <td>Label.background</td><td>0xcccccc</td>
850 * <td>Label.font</td><td>{@link #getControlTextFont}</td>
852 * <td>Menu.background</td><td>0xcccccc</td>
854 * <td>MenuBar.background</td><td>0xcccccc</td>
856 * <td>MenuItem.background</td><td>0xcccccc</td>
858 * <td>ScrollBar.background</td><td>0xcccccc</td>
860 * <td>PopupMenu.border</td>
861 * <td><code>new javax.swing.plaf.metal.MetalBorders.PopupMenuBorder()</td>
865 * @param defaults the UIDefaults instance to which the values are added
867 protected void initComponentDefaults(UIDefaults defaults)
869 super.initComponentDefaults(defaults);
870 Object[] myDefaults = new Object[] {
871 "Button.background", getControl(),
872 "Button.border", MetalBorders.getButtonBorder(),
873 "Button.darkShadow", getControlDarkShadow(),
874 "Button.disabledText", getInactiveControlTextColor(),
875 "Button.focus", getFocusColor(),
876 "Button.font", getControlTextFont(),
877 "Button.foreground", getControlTextColor(),
878 "Button.highlight", getControlHighlight(),
879 "Button.light", getControlHighlight(),
880 "Button.margin", new InsetsUIResource(2, 14, 2, 14),
881 "Button.select", getControlShadow(),
882 "Button.shadow", getControlShadow(),
884 "CheckBox.background", getControl(),
885 "CheckBox.border", MetalBorders.getButtonBorder(),
886 "CheckBox.disabledText", getInactiveControlTextColor(),
887 "CheckBox.focus", getFocusColor(),
888 "CheckBox.font", new FontUIResource("Dialog", Font.BOLD, 12),
889 "CheckBox.foreground", getControlTextColor(),
891 new UIDefaults.ProxyLazyValue
892 ("javax.swing.plaf.metal.MetalCheckBoxIcon"),
893 "CheckBox.checkIcon",
894 new UIDefaults.ProxyLazyValue
895 ("javax.swing.plaf.metal.MetalCheckBoxIcon"),
896 "Checkbox.select", getControlShadow(),
898 "CheckBoxMenuItem.acceleratorFont", new FontUIResource("Dialog", Font.PLAIN, 10),
899 "CheckBoxMenuItem.acceleratorForeground", getAcceleratorForeground(),
900 "CheckBoxMenuItem.acceleratorSelectionForeground", getAcceleratorSelectedForeground(),
901 "CheckBoxMenuItem.background", getMenuBackground(),
902 "CheckBoxMenuItem.borderPainted", new Boolean(true),
903 "CheckBoxMenuItem.commandSound", "sounds/MenuItemCommand.wav",
904 "CheckBoxMenuItem.checkIcon", MetalIconFactory.getCheckBoxMenuItemIcon(),
905 "CheckBoxMenuItem.disabledForeground", getMenuDisabledForeground(),
906 "CheckBoxMenuItem.font", new FontUIResource("Dialog", Font.BOLD, 12),
907 "CheckBoxMenuItem.foreground", getMenuForeground(),
908 "CheckBoxMenuItem.selectionBackground", getMenuSelectedBackground(),
909 "CheckBoxMenuItem.selectionForeground", getMenuSelectedForeground(),
911 "ColorChooser.background", getControl(),
912 "ColorChooser.foreground", getControlTextColor(),
913 "ColorChooser.rgbBlueMnemonic", new Integer(0),
914 "ColorChooser.rgbGreenMnemonic", new Integer(0),
915 "ColorChooser.rgbRedMnemonic", new Integer(0),
916 "ColorChooser.swatchesDefaultRecentColor", getControl(),
918 "ComboBox.background", getControl(),
919 "ComboBox.buttonBackground", getControl(),
920 "ComboBox.buttonDarkShadow", getControlDarkShadow(),
921 "ComboBox.buttonHighlight", getControlHighlight(),
922 "ComboBox.buttonShadow", getControlShadow(),
923 "ComboBox.disabledBackground", getControl(),
924 "ComboBox.disabledForeground", getInactiveSystemTextColor(),
925 "ComboBox.font", new FontUIResource("Dialog", Font.BOLD, 12),
926 "ComboBox.foreground", getControlTextColor(),
927 "ComboBox.selectionBackground", getPrimaryControlShadow(),
928 "ComboBox.selectionForeground", getControlTextColor(),
930 "Desktop.background", getDesktopColor(),
932 "DesktopIcon.background", getControl(),
933 "DesktopIcon.foreground", getControlTextColor(),
934 "DesktopIcon.width", new Integer(160),
935 "DesktopIcon.border", MetalBorders.getDesktopIconBorder(),
937 "EditorPane.background", getWindowBackground(),
938 "EditorPane.caretForeground", getUserTextColor(),
939 "EditorPane.font", new FontUIResource("Dialog", Font.BOLD, 12),
940 "EditorPane.foreground", getUserTextColor(),
941 "EditorPane.inactiveForeground", getInactiveSystemTextColor(),
942 "EditorPane.selectionBackground", getTextHighlightColor(),
943 "EditorPane.selectionForeground", getHighlightedTextColor(),
945 "FormattedTextField.background", getWindowBackground(),
946 "FormattedTextField.border",
947 new BorderUIResource(MetalBorders.getTextFieldBorder()),
948 "FormattedTextField.caretForeground", getUserTextColor(),
949 "FormattedTextField.font", new FontUIResource("Dialog", Font.PLAIN, 12),
950 "FormattedTextField.foreground", getUserTextColor(),
951 "FormattedTextField.inactiveBackground", getControl(),
952 "FormattedTextField.inactiveForeground", getInactiveSystemTextColor(),
953 "FormattedTextField.selectionBackground", getTextHighlightColor(),
954 "FormattedTextField.selectionForeground", getHighlightedTextColor(),
956 "FileChooser.upFolderIcon",
957 MetalIconFactory.getFileChooserUpFolderIcon(),
958 "FileChooser.listViewIcon",
959 MetalIconFactory.getFileChooserListViewIcon(),
960 "FileChooser.newFolderIcon",
961 MetalIconFactory.getFileChooserNewFolderIcon(),
962 "FileChooser.homeFolderIcon",
963 MetalIconFactory.getFileChooserHomeFolderIcon(),
964 "FileChooser.detailsViewIcon",
965 MetalIconFactory.getFileChooserDetailViewIcon(),
966 "FileChooser.fileNameLabelMnemonic", new Integer(78),
967 "FileChooser.filesOfTypeLabelMnemonic",new Integer(84),
968 "FileChooser.lookInLabelMnemonic", new Integer(73),
969 "FileView.computerIcon", MetalIconFactory.getTreeComputerIcon(),
970 "FileView.directoryIcon", MetalIconFactory.getTreeFolderIcon(),
971 "FileView.fileIcon", MetalIconFactory.getTreeLeafIcon(),
972 "FileView.floppyDriveIcon", MetalIconFactory.getTreeFloppyDriveIcon(),
973 "FileView.hardDriveIcon", MetalIconFactory.getTreeHardDriveIcon(),
975 "InternalFrame.activeTitleBackground", getWindowTitleBackground(),
976 "InternalFrame.activeTitleForeground", getWindowTitleForeground(),
977 "InternalFrame.border", new MetalBorders.InternalFrameBorder(),
978 "InternalFrame.borderColor", getControl(),
979 "InternalFrame.borderDarkShadow", getControlDarkShadow(),
980 "InternalFrame.borderHighlight", getControlHighlight(),
981 "InternalFrame.borderLight", getControlHighlight(),
982 "InternalFrame.borderShadow", getControlShadow(),
983 "InternalFrame.icon", MetalIconFactory.getInternalFrameDefaultMenuIcon(),
984 "InternalFrame.closeIcon",
985 MetalIconFactory.getInternalFrameCloseIcon(16),
986 "InternalFrame.closeSound", "sounds/FrameClose.wav",
987 "InternalFrame.inactiveTitleBackground", getWindowTitleInactiveBackground(),
988 "InternalFrame.inactiveTitleForeground", getWindowTitleInactiveForeground(),
989 "InternalFrame.maximizeIcon",
990 MetalIconFactory.getInternalFrameMaximizeIcon(16),
991 "InternalFrame.maximizeSound", "sounds/FrameMaximize.wav",
992 "InternalFrame.iconifyIcon",
993 MetalIconFactory.getInternalFrameMinimizeIcon(16),
994 "InternalFrame.minimizeSound", "sounds/FrameMinimize.wav",
995 "InternalFrame.paletteBorder", new MetalBorders.PaletteBorder(),
996 "InternalFrame.paletteCloseIcon", new MetalIconFactory.PaletteCloseIcon(),
997 "InternalFrame.paletteTitleHeight", new Integer(11),
998 "InternalFrame.restoreDownSound", "sounds/FrameRestoreDown.wav",
999 "InternalFrame.restoreUpSound", "sounds/FrameRestoreUp.wav",
1001 "Label.background", getControl(),
1002 "Label.disabledForeground", getInactiveSystemTextColor(),
1003 "Label.disabledShadow", getControlShadow(),
1004 "Label.font", getControlTextFont(),
1005 "Label.foreground", getSystemTextColor(),
1007 "List.font", getControlTextFont(),
1008 "List.background", getWindowBackground(),
1009 "List.foreground", getUserTextColor(),
1010 "List.selectionBackground", getTextHighlightColor(),
1011 "List.selectionForeground", getHighlightedTextColor(),
1012 "List.focusCellHighlightBorder",
1013 new LineBorderUIResource(MetalLookAndFeel.getFocusColor()),
1015 "Menu.acceleratorFont", new FontUIResource("Dialog", Font.PLAIN, 10),
1016 "Menu.acceleratorForeground", getAcceleratorForeground(),
1017 "Menu.acceleratorSelectionForeground", getAcceleratorSelectedForeground(),
1018 "Menu.arrowIcon", MetalIconFactory.getMenuArrowIcon(),
1019 "Menu.background", getMenuBackground(),
1020 "Menu.border", new MetalBorders.MenuItemBorder(),
1021 "Menu.borderPainted", Boolean.TRUE,
1022 "MenuItem.commandSound", "sounds/MenuItemCommand.wav",
1023 "Menu.disabledForeground", getMenuDisabledForeground(),
1024 "Menu.font", getControlTextFont(),
1025 "Menu.foreground", getMenuForeground(),
1026 "Menu.selectionBackground", getMenuSelectedBackground(),
1027 "Menu.selectionForeground", getMenuSelectedForeground(),
1028 "Menu.submenuPopupOffsetX", new Integer(-4),
1029 "Menu.submenuPopupOffsetY", new Integer(-3),
1031 "MenuBar.background", getMenuBackground(),
1032 "MenuBar.border", new MetalBorders.MenuBarBorder(),
1033 "MenuBar.font", getControlTextFont(),
1034 "MenuBar.foreground", getMenuForeground(),
1035 "MenuBar.highlight", getControlHighlight(),
1036 "MenuBar.shadow", getControlShadow(),
1038 "MenuItem.acceleratorDelimiter", "-",
1039 "MenuItem.acceleratorFont", new FontUIResource("Dialog", Font.PLAIN, 10),
1040 "MenuItem.acceleratorForeground", getAcceleratorForeground(),
1041 "MenuItem.acceleratorSelectionForeground", getAcceleratorSelectedForeground(),
1042 "MenuItem.arrowIcon", MetalIconFactory.getMenuItemArrowIcon(),
1043 "MenuItem.background", getMenuBackground(),
1044 "MenuItem.border", new MetalBorders.MenuItemBorder(),
1045 "MenuItem.borderPainted", Boolean.TRUE,
1046 "MenuItem.disabledForeground", getMenuDisabledForeground(),
1047 "MenuItem.font", getControlTextFont(),
1048 "MenuItem.foreground", getMenuForeground(),
1049 "MenuItem.selectionBackground", getMenuSelectedBackground(),
1050 "MenuItem.selectionForeground", getMenuSelectedForeground(),
1052 "OptionPane.background", getControl(),
1053 "OptionPane.errorSound", "sounds/OptionPaneError.wav",
1054 "OptionPane.informationSound", "sounds/OptionPaneInformation.wav",
1055 "OptionPane.questionSound", "sounds/OptionPaneQuestion.wav",
1056 "OptionPane.warningSound", "sounds/OptionPaneWarning.wav",
1057 "OptionPane.errorDialog.border.background", new ColorUIResource(153, 51, 51),
1058 "OptionPane.errorDialog.titlePane.background", new ColorUIResource(255, 153, 153),
1059 "OptionPane.errorDialog.titlePane.foreground", new ColorUIResource(51, 0, 0),
1060 "OptionPane.errorDialog.titlePane.shadow", new ColorUIResource(204, 102, 102),
1061 "OptionPane.foreground", getControlTextColor(),
1062 "OptionPane.messageForeground", getControlTextColor(),
1063 "OptionPane.questionDialog.border.background", new ColorUIResource(51, 102, 51),
1064 "OptionPane.questionDialog.titlePane.background", new ColorUIResource(153, 204, 153),
1065 "OptionPane.questionDialog.titlePane.foreground", new ColorUIResource(0, 51, 0),
1066 "OptionPane.questionDialog.titlePane.shadow", new ColorUIResource(102, 153, 102),
1067 "OptionPane.warningDialog.border.background", new ColorUIResource(153, 102, 51),
1068 "OptionPane.warningDialog.titlePane.background", new ColorUIResource(255, 204, 153),
1069 "OptionPane.warningDialog.titlePane.foreground", new ColorUIResource(102, 51, 0),
1070 "OptionPane.warningDialog.titlePane.shadow", new ColorUIResource(204, 153, 102),
1072 "Panel.background", getControl(),
1073 "Panel.foreground", getUserTextColor(),
1075 "PasswordField.background", getWindowBackground(),
1076 "PasswordField.border",
1077 new BorderUIResource(MetalBorders.getTextFieldBorder()),
1078 "PasswordField.caretForeground", getUserTextColor(),
1079 "PasswordField.foreground", getUserTextColor(),
1080 "PasswordField.font", new FontUIResource("Dialog", Font.PLAIN, 12),
1081 "PasswordField.inactiveBackground", getControl(),
1082 "PasswordField.inactiveForeground", getInactiveSystemTextColor(),
1083 "PasswordField.selectionBackground", getTextHighlightColor(),
1084 "PasswordField.selectionForeground", getHighlightedTextColor(),
1086 "PopupMenu.background", getMenuBackground(),
1087 "PopupMenu.border", new MetalBorders.PopupMenuBorder(),
1088 "PopupMenu.font", new FontUIResource("Dialog", Font.BOLD, 12),
1089 "PopupMenu.foreground", getMenuForeground(),
1090 "PopupMenu.popupSound", "sounds/PopupMenuPopup.wav",
1092 "ProgressBar.background", getControl(),
1093 "ProgressBar.border", new BorderUIResource.LineBorderUIResource(getControlDarkShadow(), 1),
1094 "ProgressBar.font", new FontUIResource("Dialog", Font.BOLD, 12),
1095 "ProgressBar.foreground", getPrimaryControlShadow(),
1096 "ProgressBar.selectionBackground", getPrimaryControlDarkShadow(),
1097 "ProgressBar.selectionForeground", getControl(),
1099 "RadioButton.background", getControl(),
1100 "RadioButton.darkShadow", getControlDarkShadow(),
1101 "RadioButton.disabledText", getInactiveControlTextColor(),
1103 new UIDefaults.LazyValue()
1105 public Object createValue(UIDefaults def)
1107 return MetalIconFactory.getRadioButtonIcon();
1110 "RadioButton.focus", MetalLookAndFeel.getFocusColor(),
1111 "RadioButton.font", MetalLookAndFeel.getControlTextFont(),
1112 "RadioButton.foreground", getControlTextColor(),
1113 "RadioButton.highlight", getControlHighlight(),
1114 "RadioButton.light", getControlHighlight(),
1115 "RadioButton.select", getControlShadow(),
1116 "RadioButton.shadow", getControlShadow(),
1118 "RadioButtonMenuItem.acceleratorFont", new Font("Dialog", Font.PLAIN, 10),
1119 "RadioButtonMenuItem.acceleratorForeground", getAcceleratorForeground(),
1120 "RadioButtonMenuItem.acceleratorSelectionForeground", getAcceleratorSelectedForeground(),
1121 "RadioButtonMenuItem.background", getMenuBackground(),
1122 "RadioButtonMenuItem.border", new MetalBorders.MenuItemBorder(),
1123 "RadioButtonMenuItem.borderPainted", Boolean.TRUE,
1124 "RadioButtonMenuItem.checkIcon",
1125 MetalIconFactory.getRadioButtonMenuItemIcon(),
1126 "RadioButtonMenuItem.commandSound", "sounds/MenuItemCommand.wav",
1127 "RadioButtonMenuItem.disabledForeground", getMenuDisabledForeground(),
1128 "RadioButtonMenuItem.font", MetalLookAndFeel.getControlTextFont(),
1129 "RadioButtonMenuItem.foreground", getMenuForeground(),
1130 "RadioButtonMenuItem.margin", new InsetsUIResource(2, 2, 2, 2),
1131 "RadioButtonMenuItem.selectionBackground",
1132 MetalLookAndFeel.getMenuSelectedBackground(),
1133 "RadioButtonMenuItem.selectionForeground",
1134 MetalLookAndFeel.getMenuSelectedForeground(),
1136 "ScrollBar.allowsAbsolutePositioning", Boolean.TRUE,
1137 "ScrollBar.background", getControl(),
1138 "ScrollBar.darkShadow", getControlDarkShadow(),
1139 "ScrollBar.foreground", getControl(),
1140 "ScrollBar.highlight", getControlHighlight(),
1141 "ScrollBar.shadow", getControlShadow(),
1142 "ScrollBar.thumb", getPrimaryControlShadow(),
1143 "ScrollBar.thumbDarkShadow", getControlDarkShadow(),
1144 "ScrollBar.thumbHighlight", getPrimaryControl(),
1145 "ScrollBar.thumbShadow", getPrimaryControlDarkShadow(),
1146 "ScrollBar.track", getControl(),
1147 "ScrollBar.trackHighlight", getControlDarkShadow(),
1148 "ScrollBar.width", new Integer(17),
1150 "ScrollPane.background", getControl(),
1151 "ScrollPane.border", new MetalBorders.ScrollPaneBorder(),
1152 "ScrollPane.foreground", getControlTextColor(),
1154 "Separator.background", getSeparatorBackground(),
1155 "Separator.foreground", getSeparatorForeground(),
1156 "Separator.highlight", getControlHighlight(),
1157 "Separator.shadow", getControlShadow(),
1159 "Slider.background", getControl(),
1160 "Slider.focus", getFocusColor(),
1161 "Slider.focusInsets", new InsetsUIResource(0, 0, 0, 0),
1162 "Slider.foreground", getPrimaryControlShadow(),
1163 "Slider.highlight", getControlHighlight(),
1164 "Slider.horizontalThumbIcon",
1165 MetalIconFactory.getHorizontalSliderThumbIcon(),
1166 "Slider.majorTickLength", new Integer(6),
1167 "Slider.shadow", getControlShadow(),
1168 "Slider.trackWidth", new Integer(7),
1169 "Slider.verticalThumbIcon",
1170 MetalIconFactory.getVerticalSliderThumbIcon(),
1172 "Spinner.arrowButtonInsets", new InsetsUIResource(0, 0, 0, 0),
1173 "Spinner.background", getControl(),
1174 "Spinner.font", new FontUIResource("Dialog", Font.BOLD, 12),
1175 "Spinner.foreground", getControl(),
1177 "SplitPane.background", getControl(),
1178 "SplitPane.darkShadow", getControlDarkShadow(),
1179 "SplitPane.dividerFocusColor", getPrimaryControl(),
1180 "SplitPane.dividerSize", new Integer(10),
1181 "SplitPane.highlight", getControlHighlight(),
1182 "SplitPane.shadow", getControlShadow(),
1184 "SplitPaneDivider.draggingColor", Color.DARK_GRAY,
1186 "TabbedPane.background", getControlShadow(),
1187 "TabbedPane.darkShadow", getControlDarkShadow(),
1188 "TabbedPane.focus", getPrimaryControlDarkShadow(),
1189 "TabbedPane.font", new FontUIResource("Dialog", Font.BOLD, 12),
1190 "TabbedPane.foreground", getControlTextColor(),
1191 "TabbedPane.highlight", getControlHighlight(),
1192 "TabbedPane.light", getControl(),
1193 "TabbedPane.selected", getControl(),
1194 "TabbedPane.selectHighlight", getControlHighlight(),
1195 "TabbedPane.selectedTabPadInsets", new InsetsUIResource(2, 2, 2, 1),
1196 "TabbedPane.shadow", getControlShadow(),
1197 "TabbedPane.tabAreaBackground", getControl(),
1198 "TabbedPane.tabAreaInsets", new InsetsUIResource(4, 2, 0, 6),
1199 "TabbedPane.tabInsets", new InsetsUIResource(0, 9, 1, 9),
1201 "Table.background", getWindowBackground(),
1202 "Table.focusCellBackground", getWindowBackground(),
1203 "Table.focusCellForeground", getControlTextColor(),
1204 "Table.foreground", getControlTextColor(),
1205 "Table.focusCellHighlightBorder",
1206 new BorderUIResource.LineBorderUIResource(getControlShadow()),
1207 "Table.focusCellBackground", getWindowBackground(),
1208 "Table.gridColor", getControlDarkShadow(),
1209 "Table.selectionBackground", new ColorUIResource(204, 204, 255),
1210 "Table.selectionForeground", new ColorUIResource(0, 0, 0),
1212 "TableHeader.background", getControl(),
1213 "TableHeader.cellBorder", new MetalBorders.TableHeaderBorder(),
1214 "TableHeader.foreground", getControlTextColor(),
1216 "TextArea.background", getWindowBackground(),
1217 "TextArea.caretForeground", getUserTextColor(),
1218 "TextArea.font", new FontUIResource("Dialog", Font.PLAIN, 12),
1219 "TextArea.foreground", getUserTextColor(),
1220 "TextArea.inactiveForeground", getInactiveSystemTextColor(),
1221 "TextArea.selectionBackground", getTextHighlightColor(),
1222 "TextArea.selectionForeground", getHighlightedTextColor(),
1224 "TextField.background", getWindowBackground(),
1226 new BorderUIResource(MetalBorders.getTextFieldBorder()),
1227 "TextField.caretForeground", getUserTextColor(),
1228 "TextField.darkShadow", getControlDarkShadow(),
1229 "TextField.font", new FontUIResource("Dialog", Font.PLAIN, 12),
1230 "TextField.foreground", getUserTextColor(),
1231 "TextField.highlight", getControlHighlight(),
1232 "TextField.inactiveBackground", getControl(),
1233 "TextField.inactiveForeground", getInactiveSystemTextColor(),
1234 "TextField.light", getControlHighlight(),
1235 "TextField.selectionBackground", getTextHighlightColor(),
1236 "TextField.selectionForeground", getHighlightedTextColor(),
1237 "TextField.shadow", getControlShadow(),
1239 "TextPane.background", getWindowBackground(),
1240 "TextPane.caretForeground", getUserTextColor(),
1241 "TextPane.font", new FontUIResource("Dialog", Font.PLAIN, 12),
1242 "TextPane.foreground", getUserTextColor(),
1243 "TextPane.inactiveForeground", getInactiveSystemTextColor(),
1244 "TextPane.selectionBackground", getTextHighlightColor(),
1245 "TextPane.selectionForeground", getHighlightedTextColor(),
1247 "TitledBorder.font", new FontUIResource("Dialog", Font.BOLD, 12),
1248 "TitledBorder.titleColor", getSystemTextColor(),
1250 "ToggleButton.background", getControl(),
1251 "ToggleButton.border", MetalBorders.getToggleButtonBorder(),
1252 "ToggleButton.darkShadow", getControlDarkShadow(),
1253 "ToggleButton.disabledText", getInactiveControlTextColor(),
1254 "ToggleButton.focus", getFocusColor(),
1255 "ToggleButton.font", getControlTextFont(),
1256 "ToggleButton.foreground", getControlTextColor(),
1257 "ToggleButton.highlight", getControlHighlight(),
1258 "ToggleButton.light", getControlHighlight(),
1259 "ToggleButton.margin", new InsetsUIResource(2, 14, 2, 14),
1260 "ToggleButton.select", getControlShadow(),
1261 "ToggleButton.shadow", getControlShadow(),
1263 "ToolBar.background", getMenuBackground(),
1264 "ToolBar.darkShadow", getControlDarkShadow(),
1265 "ToolBar.dockingBackground", getMenuBackground(),
1266 "ToolBar.dockingForeground", getPrimaryControlDarkShadow(),
1267 "ToolBar.floatingBackground", getMenuBackground(),
1268 "ToolBar.floatingForeground", getPrimaryControl(),
1269 "ToolBar.font", new FontUIResource("Dialog", Font.BOLD, 12),
1270 "ToolBar.foreground", getMenuForeground(),
1271 "ToolBar.highlight", getControlHighlight(),
1272 "ToolBar.light", getControlHighlight(),
1273 "ToolBar.shadow", getControlShadow(),
1274 "ToolBar.border", new MetalBorders.ToolBarBorder(),
1276 "ToolTip.background", getPrimaryControl(),
1277 "ToolTip.backgroundInactive", getControl(),
1278 "ToolTip.border", new BorderUIResource.LineBorderUIResource(getPrimaryControlDarkShadow(), 1),
1279 "ToolTip.borderInactive", new BorderUIResource.LineBorderUIResource(getControlDarkShadow(), 1),
1280 "ToolTip.font", new FontUIResource("Dialog", Font.PLAIN, 12),
1281 "ToolTip.foreground", getPrimaryControlInfo(),
1282 "ToolTip.foregroundInactive", getControlDarkShadow(),
1283 "ToolTip.hideAccelerator", Boolean.FALSE,
1285 "Tree.background", getWindowBackground(),
1286 "Tree.closedIcon", MetalIconFactory.getTreeFolderIcon(),
1287 "Tree.collapsedIcon", MetalIconFactory.getTreeControlIcon(true),
1288 "Tree.expandedIcon", MetalIconFactory.getTreeControlIcon(false),
1289 "Tree.font", new FontUIResource("Dialog", Font.PLAIN, 12),
1290 "Tree.foreground", getUserTextColor(),
1291 "Tree.hash", getPrimaryControl(),
1292 "Tree.leafIcon", MetalIconFactory.getTreeLeafIcon(),
1293 "Tree.leftChildIndent", new Integer(7),
1294 "Tree.line", getPrimaryControl(),
1295 "Tree.openIcon", MetalIconFactory.getTreeFolderIcon(),
1296 "Tree.rightChildIndent", new Integer(13),
1297 "Tree.rowHeight", new Integer(0),
1298 "Tree.scrollsOnExpand", Boolean.TRUE,
1299 "Tree.selectionBackground", getTextHighlightColor(),
1300 "Tree.selectionBorder", new BorderUIResource.LineBorderUIResource(new Color(102, 102, 153)),
1301 "Tree.selectionBorderColor", getFocusColor(),
1302 "Tree.selectionForeground", getHighlightedTextColor(),
1303 "Tree.textBackground", getWindowBackground(),
1304 "Tree.textForeground", getUserTextColor(),
1306 "Viewport.background", getControl(),
1307 "Viewport.foreground", getUserTextColor()
1309 defaults.putDefaults(myDefaults);
1313 * Initializes the system color defaults.
1315 * In particular this sets the following keys:
1319 * <th>Key</th><th>Value</th><th>Description</th>
1321 * <td>control</td><td>0xcccccc</td><td>The default color for components</td>
1325 protected void initSystemColorDefaults(UIDefaults defaults)
1327 super.initSystemColorDefaults(defaults);
1328 Object[] uiDefaults;
1329 uiDefaults = new Object[] {
1330 "control", new ColorUIResource(getControl()),
1331 "desktop", new ColorUIResource(getDesktopColor())
1333 defaults.putDefaults(uiDefaults);
1337 * Returns the current theme setting for the Metal L&F.
1339 * @return the current theme setting for the Metal L&F
1341 public static MetalTheme getCurrentTheme()