1 /* MetalLookAndFeel.java
2 Copyright (C) 2002, 2005, 2006, 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 OceanTheme}.
90 protected void createDefaultTheme()
93 setCurrentTheme(new OceanTheme());
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 * @see #getCurrentTheme()
715 public static void setCurrentTheme(MetalTheme theme
)
718 throw new NullPointerException("Null 'theme' not permitted.");
719 MetalLookAndFeel
.theme
= theme
;
723 * Sets the ComponentUI classes for all Swing components to the Metal
726 * In particular this sets the following keys:
730 * <th>Key</th><th>Value</th>
732 * <td>ButtonUI</td><td>{@link MetalButtonUI}</td>
734 * <td>CheckBoxUI</td><td>{@link MetalCheckBoxUI}</td>
736 * <td>ComboBoxUI</td><td>{@link MetalComboBoxUI}</td>
738 * <td>DesktopIconUI</td><td>{@link MetalDesktopIconUI}</td>
740 * <td>InternalFrameUI</td><td>{@link MetalInternalFrameUI}</td>
742 * <td>LabelUI</td><td>{@link MetalLabelUI}</td>
744 * <td>PopupMenuSeparatorUI</td><td>{@link MetalPopupMenuSeparatorUI}</td>
746 * <td>ProgressBarUI</td><td>{@link MetalProgressBarUI}</td>
748 * <td>RadioButtonUI</td><td>{@link MetalRadioButtonUI}</td>
750 * <td>RootPaneUI</td><td>{@link MetalRootPaneUI}</td>
752 * <td>ScrollBarUI</td><td>{@link MetalScrollBarUI}</td>
754 * <td>ScrollPaneUI</td><td>{@link MetalScrollPaneUI}</td>
756 * <td>SeparatorUI</td><td>{@link MetalSeparatorUI}</td>
758 * <td>SliderUI</td><td>{@link MetalSliderUI}</td>
760 * <td>SplitPaneUI</td><td>{@link MetalSplitPaneUI}</td>
762 * <td>TabbedPaneUI</td><td>{@link MetalTabbedPaneUI}</td>
764 * <td>TextFieldUI</td><td>{@link MetalTextFieldUI}</td>
766 * <td>ToggleButtonUI</td><td>{@link MetalToggleButtonUI}</td>
768 * <td>ToolBarUI</td><td>{@link MetalToolBarUI}</td>
770 * <td>ToolTipUI</td><td>{@link MetalToolTipUI}</td>
772 * <td>TreeUI</td><td>{@link MetalTreeUI}</td>
776 * @param defaults the UIDefaults where the class defaults are added
778 protected void initClassDefaults(UIDefaults defaults
)
780 super.initClassDefaults(defaults
);
784 // Initialize Class Defaults
785 uiDefaults
= new Object
[] {
786 "ButtonUI", "javax.swing.plaf.metal.MetalButtonUI",
787 "CheckBoxUI", "javax.swing.plaf.metal.MetalCheckBoxUI",
788 "ComboBoxUI", "javax.swing.plaf.metal.MetalComboBoxUI",
789 "DesktopIconUI", "javax.swing.plaf.metal.MetalDesktopIconUI",
790 "FileChooserUI", "javax.swing.plaf.metal.MetalFileChooserUI",
791 "InternalFrameUI", "javax.swing.plaf.metal.MetalInternalFrameUI",
792 "LabelUI", "javax.swing.plaf.metal.MetalLabelUI",
793 "MenuBarUI", "javax.swing.plaf.metal.MetalMenuBarUI",
794 "PopupMenuSeparatorUI",
795 "javax.swing.plaf.metal.MetalPopupMenuSeparatorUI",
796 "ProgressBarUI", "javax.swing.plaf.metal.MetalProgressBarUI",
797 "RadioButtonUI", "javax.swing.plaf.metal.MetalRadioButtonUI",
798 "RootPaneUI", "javax.swing.plaf.metal.MetalRootPaneUI",
799 "ScrollBarUI", "javax.swing.plaf.metal.MetalScrollBarUI",
800 "ScrollPaneUI", "javax.swing.plaf.metal.MetalScrollPaneUI",
801 "SeparatorUI", "javax.swing.plaf.metal.MetalSeparatorUI",
802 "SliderUI", "javax.swing.plaf.metal.MetalSliderUI",
803 "SplitPaneUI", "javax.swing.plaf.metal.MetalSplitPaneUI",
804 "TabbedPaneUI", "javax.swing.plaf.metal.MetalTabbedPaneUI",
805 "TextFieldUI", "javax.swing.plaf.metal.MetalTextFieldUI",
806 "ToggleButtonUI", "javax.swing.plaf.metal.MetalToggleButtonUI",
807 "ToolBarUI", "javax.swing.plaf.metal.MetalToolBarUI",
808 "ToolTipUI", "javax.swing.plaf.metal.MetalToolTipUI",
809 "TreeUI", "javax.swing.plaf.metal.MetalTreeUI",
811 // Add Class Defaults to UI Defaults table
812 defaults
.putDefaults(uiDefaults
);
816 * Initializes the component defaults for the Metal Look & Feel.
818 * In particular this sets the following keys (the colors are given
819 * as RGB hex values):
823 * <th>Key</th><th>Value</th>
825 * <td>Button.background</td><td>0xcccccc</td>
827 * <td>Button.border</td><td>{@link MetalBorders#getButtonBorder()}</td>
829 * <td>Button.font</td><td>{@link #getControlTextFont}</td>
831 * <td>Button.margin</td><td><code>new java.awt.Insets(2, 14, 2, 14)</code>
834 * <td>CheckBox.background</td><td>0xcccccc</td>
836 * <td>CheckBoxMenuItem.background</td><td>0xcccccc</td>
838 * <td>ToolBar.background</td><td>0xcccccc</td>
840 * <td>Panel.background</td><td>0xcccccc</td>
842 * <td>Slider.background</td><td>0xcccccc</td>
844 * <td>OptionPane.background</td><td>0xcccccc</td>
846 * <td>ProgressBar.background</td><td>0xcccccc</td>
848 * <td>TabbedPane.background</td><td>0xcccccc</td>
850 * <td>Label.background</td><td>0xcccccc</td>
852 * <td>Label.font</td><td>{@link #getControlTextFont}</td>
854 * <td>Menu.background</td><td>0xcccccc</td>
856 * <td>MenuBar.background</td><td>0xcccccc</td>
858 * <td>MenuItem.background</td><td>0xcccccc</td>
860 * <td>ScrollBar.background</td><td>0xcccccc</td>
862 * <td>PopupMenu.border</td>
863 * <td><code>new javax.swing.plaf.metal.MetalBorders.PopupMenuBorder()</td>
867 * @param defaults the UIDefaults instance to which the values are added
869 protected void initComponentDefaults(UIDefaults defaults
)
871 super.initComponentDefaults(defaults
);
872 Object
[] myDefaults
= new Object
[] {
873 "Button.background", getControl(),
874 "Button.border", MetalBorders
.getButtonBorder(),
875 "Button.darkShadow", getControlDarkShadow(),
876 "Button.disabledText", getInactiveControlTextColor(),
877 "Button.focus", getFocusColor(),
878 "Button.font", getControlTextFont(),
879 "Button.foreground", getControlTextColor(),
880 "Button.highlight", getControlHighlight(),
881 "Button.light", getControlHighlight(),
882 "Button.margin", new InsetsUIResource(2, 14, 2, 14),
883 "Button.select", getControlShadow(),
884 "Button.shadow", getControlShadow(),
886 "CheckBox.background", getControl(),
887 "CheckBox.border", MetalBorders
.getButtonBorder(),
888 "CheckBox.disabledText", getInactiveControlTextColor(),
889 "CheckBox.focus", getFocusColor(),
890 "CheckBox.font", new FontUIResource("Dialog", Font
.BOLD
, 12),
891 "CheckBox.foreground", getControlTextColor(),
893 new UIDefaults
.ProxyLazyValue("javax.swing.plaf.metal.MetalCheckBoxIcon"),
894 "CheckBox.checkIcon",
895 new UIDefaults
.ProxyLazyValue("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", 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.border", MetalBorders
.getTextFieldBorder(),
1175 "Spinner.font", new FontUIResource("Dialog", Font
.BOLD
, 12),
1176 "Spinner.foreground", getControl(),
1178 "SplitPane.background", getControl(),
1179 "SplitPane.darkShadow", getControlDarkShadow(),
1180 "SplitPane.dividerFocusColor", getPrimaryControl(),
1181 "SplitPane.dividerSize", new Integer(10),
1182 "SplitPane.highlight", getControlHighlight(),
1183 "SplitPane.shadow", getControlShadow(),
1185 "SplitPaneDivider.draggingColor", Color
.DARK_GRAY
,
1187 "TabbedPane.background", getControlShadow(),
1188 "TabbedPane.contentBorderInsets", new InsetsUIResource(2, 2, 3, 3),
1189 "TabbedPane.contentOpaque", Boolean
.TRUE
,
1190 "TabbedPane.darkShadow", getControlDarkShadow(),
1191 "TabbedPane.focus", getPrimaryControlDarkShadow(),
1192 "TabbedPane.font", new FontUIResource("Dialog", Font
.BOLD
, 12),
1193 "TabbedPane.foreground", getControlTextColor(),
1194 "TabbedPane.highlight", getControlHighlight(),
1195 "TabbedPane.light", getControl(),
1196 "TabbedPane.selected", getControl(), // overridden in OceanTheme
1197 "TabbedPane.selectHighlight", getControlHighlight(),
1198 "TabbedPane.selectedTabPadInsets", new InsetsUIResource(2, 2, 2, 1),
1199 "TabbedPane.shadow", getControlShadow(),
1200 "TabbedPane.tabAreaBackground", getControl(), // overridden in OceanTheme
1201 "TabbedPane.tabAreaInsets", new InsetsUIResource(4, 2, 0, 6), // dito
1202 "TabbedPane.tabInsets", new InsetsUIResource(0, 9, 1, 9),
1204 // new properties in OceanTheme:
1205 // TabbedPane.contentAreaColor
1206 // TabbedPane.unselectedBackground
1208 "Table.background", getWindowBackground(),
1209 "Table.focusCellBackground", getWindowBackground(),
1210 "Table.focusCellForeground", getControlTextColor(),
1211 "Table.foreground", getControlTextColor(),
1212 "Table.focusCellHighlightBorder",
1213 new BorderUIResource
.LineBorderUIResource(getFocusColor()),
1214 "Table.focusCellBackground", getWindowBackground(),
1215 "Table.gridColor", getControlDarkShadow(),
1216 "Table.selectionBackground", new ColorUIResource(204, 204, 255),
1217 "Table.selectionForeground", new ColorUIResource(0, 0, 0),
1219 "TableHeader.background", getControl(),
1220 "TableHeader.cellBorder", new MetalBorders
.TableHeaderBorder(),
1221 "TableHeader.foreground", getControlTextColor(),
1223 "TextArea.background", getWindowBackground(),
1224 "TextArea.caretForeground", getUserTextColor(),
1225 "TextArea.font", new FontUIResource("Dialog", Font
.PLAIN
, 12),
1226 "TextArea.foreground", getUserTextColor(),
1227 "TextArea.inactiveForeground", getInactiveSystemTextColor(),
1228 "TextArea.selectionBackground", getTextHighlightColor(),
1229 "TextArea.selectionForeground", getHighlightedTextColor(),
1231 "TextField.background", getWindowBackground(),
1233 new BorderUIResource(MetalBorders
.getTextFieldBorder()),
1234 "TextField.caretForeground", getUserTextColor(),
1235 "TextField.darkShadow", getControlDarkShadow(),
1236 "TextField.font", new FontUIResource("Dialog", Font
.PLAIN
, 12),
1237 "TextField.foreground", getUserTextColor(),
1238 "TextField.highlight", getControlHighlight(),
1239 "TextField.inactiveBackground", getControl(),
1240 "TextField.inactiveForeground", getInactiveSystemTextColor(),
1241 "TextField.light", getControlHighlight(),
1242 "TextField.selectionBackground", getTextHighlightColor(),
1243 "TextField.selectionForeground", getHighlightedTextColor(),
1244 "TextField.shadow", getControlShadow(),
1246 "TextPane.background", getWindowBackground(),
1247 "TextPane.caretForeground", getUserTextColor(),
1248 "TextPane.font", new FontUIResource("Dialog", Font
.PLAIN
, 12),
1249 "TextPane.foreground", getUserTextColor(),
1250 "TextPane.inactiveForeground", getInactiveSystemTextColor(),
1251 "TextPane.selectionBackground", getTextHighlightColor(),
1252 "TextPane.selectionForeground", getHighlightedTextColor(),
1254 "TitledBorder.border", new LineBorderUIResource(getPrimaryControl(), 1),
1255 "TitledBorder.font", new FontUIResource("Dialog", Font
.BOLD
, 12),
1256 "TitledBorder.titleColor", getSystemTextColor(),
1258 "ToggleButton.background", getControl(),
1259 "ToggleButton.border", MetalBorders
.getToggleButtonBorder(),
1260 "ToggleButton.darkShadow", getControlDarkShadow(),
1261 "ToggleButton.disabledText", getInactiveControlTextColor(),
1262 "ToggleButton.focus", getFocusColor(),
1263 "ToggleButton.font", getControlTextFont(),
1264 "ToggleButton.foreground", getControlTextColor(),
1265 "ToggleButton.highlight", getControlHighlight(),
1266 "ToggleButton.light", getControlHighlight(),
1267 "ToggleButton.margin", new InsetsUIResource(2, 14, 2, 14),
1268 "ToggleButton.select", getControlShadow(),
1269 "ToggleButton.shadow", getControlShadow(),
1271 "ToolBar.background", getMenuBackground(),
1272 "ToolBar.darkShadow", getControlDarkShadow(),
1273 "ToolBar.dockingBackground", getMenuBackground(),
1274 "ToolBar.dockingForeground", getPrimaryControlDarkShadow(),
1275 "ToolBar.floatingBackground", getMenuBackground(),
1276 "ToolBar.floatingForeground", getPrimaryControl(),
1277 "ToolBar.font", new FontUIResource("Dialog", Font
.BOLD
, 12),
1278 "ToolBar.foreground", getMenuForeground(),
1279 "ToolBar.highlight", getControlHighlight(),
1280 "ToolBar.light", getControlHighlight(),
1281 "ToolBar.shadow", getControlShadow(),
1282 "ToolBar.border", new MetalBorders
.ToolBarBorder(),
1283 "ToolBar.rolloverBorder", MetalBorders
.getToolbarButtonBorder(),
1284 "ToolBar.nonrolloverBorder", MetalBorders
.getToolbarButtonBorder(),
1286 "ToolTip.background", getPrimaryControl(),
1287 "ToolTip.backgroundInactive", getControl(),
1288 "ToolTip.border", new BorderUIResource
.LineBorderUIResource(getPrimaryControlDarkShadow(), 1),
1289 "ToolTip.borderInactive", new BorderUIResource
.LineBorderUIResource(getControlDarkShadow(), 1),
1290 "ToolTip.font", new FontUIResource("Dialog", Font
.PLAIN
, 12),
1291 "ToolTip.foreground", getPrimaryControlInfo(),
1292 "ToolTip.foregroundInactive", getControlDarkShadow(),
1293 "ToolTip.hideAccelerator", Boolean
.FALSE
,
1295 "Tree.background", getWindowBackground(),
1296 "Tree.closedIcon", MetalIconFactory
.getTreeFolderIcon(),
1297 "Tree.collapsedIcon", MetalIconFactory
.getTreeControlIcon(true),
1298 "Tree.expandedIcon", MetalIconFactory
.getTreeControlIcon(false),
1299 "Tree.font", new FontUIResource("Dialog", Font
.PLAIN
, 12),
1300 "Tree.foreground", getUserTextColor(),
1301 "Tree.hash", getPrimaryControl(),
1302 "Tree.leafIcon", MetalIconFactory
.getTreeLeafIcon(),
1303 "Tree.leftChildIndent", new Integer(7),
1304 "Tree.line", getPrimaryControl(),
1305 "Tree.openIcon", MetalIconFactory
.getTreeFolderIcon(),
1306 "Tree.rightChildIndent", new Integer(13),
1307 "Tree.rowHeight", new Integer(0),
1308 "Tree.scrollsOnExpand", Boolean
.TRUE
,
1309 "Tree.selectionBackground", getTextHighlightColor(),
1310 "Tree.selectionBorder", new BorderUIResource
.LineBorderUIResource(new Color(102, 102, 153)),
1311 "Tree.selectionBorderColor", getFocusColor(),
1312 "Tree.selectionForeground", getHighlightedTextColor(),
1313 "Tree.textBackground", getWindowBackground(),
1314 "Tree.textForeground", getUserTextColor(),
1316 "Viewport.background", getControl(),
1317 "Viewport.foreground", getUserTextColor()
1319 defaults
.putDefaults(myDefaults
);
1323 * Initializes the system color defaults.
1325 * In particular this sets the following keys:
1329 * <th>Key</th><th>Value</th><th>Description</th>
1331 * <td>control</td><td>0xcccccc</td><td>The default color for components</td>
1335 protected void initSystemColorDefaults(UIDefaults defaults
)
1337 super.initSystemColorDefaults(defaults
);
1338 Object
[] uiDefaults
;
1339 uiDefaults
= new Object
[] {
1340 "control", new ColorUIResource(getControl()),
1341 "desktop", new ColorUIResource(getDesktopColor())
1343 defaults
.putDefaults(uiDefaults
);
1347 * Returns the current theme for the Metal look and feel. The default is
1348 * an instance of {@link OceanTheme}.
1350 * @return The current theme (never <code>null</code>).
1352 * @see #setCurrentTheme(MetalTheme)
1354 public static MetalTheme
getCurrentTheme()
1357 theme
= new OceanTheme();
1362 * Returns <code>true</code> because the Metal look
1363 * and feel supports window decorations for toplevel
1366 * @return <code>true</code>
1368 public boolean getSupportsWindowDecorations()