1 /* MetalLookAndFeel.java
2    Copyright (C) 2002, 2005, 2006, Free Software Foundation, Inc.
3 
4 This file is part of GNU Classpath.
5 
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)
9 any later version.
10 
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.
15 
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
19 02110-1301 USA.
20 
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
24 combination.
25 
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. */
37 
38 
39 package javax.swing.plaf.metal;
40 
41 import gnu.classpath.SystemProperties;
42 
43 import java.awt.Color;
44 import java.awt.Font;
45 
46 import javax.swing.LookAndFeel;
47 import javax.swing.UIDefaults;
48 import javax.swing.UIManager;
49 import javax.swing.plaf.BorderUIResource;
50 import javax.swing.plaf.ColorUIResource;
51 import javax.swing.plaf.FontUIResource;
52 import javax.swing.plaf.InsetsUIResource;
53 import javax.swing.plaf.BorderUIResource.LineBorderUIResource;
54 import javax.swing.plaf.basic.BasicLookAndFeel;
55 
56 
57 /**
58  * A custom look and feel that is designed to look similar across different
59  * operating systems.  To install this look and feel, add the following code
60  * (or something similar) near the start of your application:</p>
61  * <pre>
62  * try
63  * {
64  * &nbsp;&nbsp;UIManager.setLookAndFeel(new MetalLookAndFeel());
65  * }
66  * catch (UnsupportedLookAndFeelException e)
67  * {
68  * &nbsp;&nbsp;e.printStackTrace();
69  * }</pre>
70  */
71 public class MetalLookAndFeel extends BasicLookAndFeel
72 {
73   private static final long serialVersionUID = 6680646159193457980L;
74 
75   /** The current theme. */
76   private static MetalTheme theme;
77 
78   /**
79    * Creates a new instance of the Metal look and feel.
80    */
MetalLookAndFeel()81   public MetalLookAndFeel()
82   {
83     // Nothing to do here.
84   }
85 
86   /**
87    * Sets the current theme to a new instance of {@link DefaultMetalTheme}.
88    */
createDefaultTheme()89   protected void createDefaultTheme()
90   {
91     getCurrentTheme();
92   }
93 
94   /**
95    * Returns <code>false</code> to indicate that this look and feel does not
96    * attempt to emulate the look and feel of native applications on the host
97    * platform.
98    *
99    * @return <code>false</code>.
100    */
isNativeLookAndFeel()101   public boolean isNativeLookAndFeel()
102   {
103     return false;
104   }
105 
106   /**
107    * Returns <code>true</code> to indicate that this look and feel is supported
108    * on all platforms.
109    *
110    * @return <code>true</code>.
111    */
isSupportedLookAndFeel()112   public boolean isSupportedLookAndFeel()
113   {
114     return true;
115   }
116 
117   /**
118    * Returns a string describing the look and feel.  In this case, the method
119    * returns "Metal look and feel".
120    *
121    * @return A string describing the look and feel.
122    */
getDescription()123   public String getDescription()
124   {
125     return "The Java(tm) Look and Feel";
126   }
127 
128   /**
129    * Returns the look and feel identifier.
130    *
131    * @return "MetalLookAndFeel".
132    */
getID()133   public String getID()
134   {
135     return "Metal";
136   }
137 
138   /**
139    * Returns the look and feel name.
140    *
141    * @return "MetalLookAndFeel".
142    */
getName()143   public String getName()
144   {
145     return "Metal";
146   }
147 
getDefaults()148   public UIDefaults getDefaults()
149   {
150     createDefaultTheme();
151     UIDefaults def = super.getDefaults();
152 
153     theme.addCustomEntriesToTable(def);
154     return def;
155   }
156 
157   /**
158    * Returns the accelerator foreground color from the installed theme.
159    *
160    * @return The accelerator foreground color.
161    */
getAcceleratorForeground()162   public static ColorUIResource getAcceleratorForeground()
163   {
164     if (theme != null)
165       return theme.getAcceleratorForeground();
166     return null;
167   }
168 
169   /**
170    * Returns the accelerator selected foreground color from the installed
171    * theme.
172    *
173    * @return The accelerator selected foreground color.
174    */
getAcceleratorSelectedForeground()175   public static ColorUIResource getAcceleratorSelectedForeground()
176   {
177     if (theme != null)
178       return theme.getAcceleratorSelectedForeground();
179     return null;
180   }
181 
182   /**
183    * Returns the color black from the installed theme.
184    *
185    * @return The color black.
186    */
getBlack()187   public static ColorUIResource getBlack()
188   {
189     if (theme != null)
190       return theme.getBlack();
191     return null;
192   }
193 
194   /**
195    * Returns the control color from the installed theme.
196    *
197    * @return The control color.
198    */
getControl()199   public static ColorUIResource getControl()
200   {
201     if (theme != null)
202       return theme.getControl();
203     return null;
204   }
205 
206   /**
207    * Returns the color used for dark shadows on controls, from the installed
208    * theme.
209    *
210    * @return The color used for dark shadows on controls.
211    */
getControlDarkShadow()212   public static ColorUIResource getControlDarkShadow()
213   {
214     if (theme != null)
215       return theme.getControlDarkShadow();
216     return null;
217   }
218 
219   /**
220    * Returns the color used for disabled controls, from the installed theme.
221    *
222    * @return The color used for disabled controls.
223    */
getControlDisabled()224   public static ColorUIResource getControlDisabled()
225   {
226     if (theme != null)
227       return theme.getControlDisabled();
228     return null;
229   }
230 
231   /**
232    * Returns the color used to draw highlights for controls, from the installed
233    * theme.
234    *
235    * @return The color used to draw highlights for controls.
236    */
getControlHighlight()237   public static ColorUIResource getControlHighlight()
238   {
239     if (theme != null)
240       return theme.getControlHighlight();
241     return null;
242   }
243 
244   /**
245    * Returns the color used to display control info, from the installed
246    * theme.
247    *
248    * @return The color used to display control info.
249    */
getControlInfo()250   public static ColorUIResource getControlInfo()
251   {
252     if (theme != null)
253       return theme.getControlInfo();
254     return null;
255   }
256 
257   /**
258    * Returns the color used to draw shadows for controls, from the installed
259    * theme.
260    *
261    * @return The color used to draw shadows for controls.
262    */
getControlShadow()263   public static ColorUIResource getControlShadow()
264   {
265     if (theme != null)
266       return theme.getControlShadow();
267     return null;
268   }
269 
270   /**
271    * Returns the color used for text on controls, from the installed theme.
272    *
273    * @return The color used for text on controls.
274    */
getControlTextColor()275   public static ColorUIResource getControlTextColor()
276   {
277     if (theme != null)
278       return theme.getControlTextColor();
279     return null;
280   }
281 
282   /**
283    * Returns the font used for text on controls, from the installed theme.
284    *
285    * @return The font used for text on controls.
286    */
getControlTextFont()287   public static FontUIResource getControlTextFont()
288   {
289     if (theme != null)
290       return theme.getControlTextFont();
291     return null;
292   }
293 
294   /**
295    * Returns the color used for the desktop background, from the installed
296    * theme.
297    *
298    * @return The color used for the desktop background.
299    */
getDesktopColor()300   public static ColorUIResource getDesktopColor()
301   {
302     if (theme != null)
303       return theme.getDesktopColor();
304     return null;
305   }
306 
307   /**
308    * Returns the color used to draw focus highlights, from the installed
309    * theme.
310    *
311    * @return The color used to draw focus highlights.
312    */
getFocusColor()313   public static ColorUIResource getFocusColor()
314   {
315     if (theme != null)
316       return theme.getFocusColor();
317     return null;
318   }
319 
320   /**
321    * Returns the color used to draw highlighted text, from the installed
322    * theme.
323    *
324    * @return The color used to draw highlighted text.
325    */
getHighlightedTextColor()326   public static ColorUIResource getHighlightedTextColor()
327   {
328     if (theme != null)
329       return theme.getHighlightedTextColor();
330     return null;
331   }
332 
333   /**
334    * Returns the color used to draw text on inactive controls, from the
335    * installed theme.
336    *
337    * @return The color used to draw text on inactive controls.
338    */
getInactiveControlTextColor()339   public static ColorUIResource getInactiveControlTextColor()
340   {
341     if (theme != null)
342       return theme.getInactiveControlTextColor();
343     return null;
344   }
345 
346   /**
347    * Returns the color used to draw inactive system text, from the installed
348    * theme.
349    *
350    * @return The color used to draw inactive system text.
351    */
getInactiveSystemTextColor()352   public static ColorUIResource getInactiveSystemTextColor()
353   {
354     if (theme != null)
355       return theme.getInactiveSystemTextColor();
356     return null;
357   }
358 
359   /**
360    * Returns the background color for menu items, from the installed theme.
361    *
362    * @return The background color for menu items.
363    *
364    * @see #getMenuSelectedBackground()
365    */
getMenuBackground()366   public static ColorUIResource getMenuBackground()
367   {
368     if (theme != null)
369       return theme.getMenuBackground();
370     return null;
371   }
372 
373   /**
374    * Returns the foreground color for disabled menu items, from the installed
375    * theme.
376    *
377    * @return The foreground color for disabled menu items.
378    *
379    * @see #getMenuForeground()
380    */
getMenuDisabledForeground()381   public static ColorUIResource getMenuDisabledForeground()
382   {
383     if (theme != null)
384       return theme.getMenuDisabledForeground();
385     return null;
386   }
387 
388   /**
389    * Returns the foreground color for menu items, from the installed theme.
390    *
391    * @return The foreground color for menu items.
392    *
393    * @see #getMenuDisabledForeground()
394    * @see #getMenuSelectedForeground()
395    */
getMenuForeground()396   public static ColorUIResource getMenuForeground()
397   {
398     if (theme != null)
399       return theme.getMenuForeground();
400     return null;
401   }
402 
403   /**
404    * Returns the background color for selected menu items, from the installed
405    * theme.
406    *
407    * @return The background color for selected menu items.
408    *
409    * @see #getMenuBackground()
410    */
getMenuSelectedBackground()411   public static ColorUIResource getMenuSelectedBackground()
412   {
413     if (theme != null)
414       return theme.getMenuSelectedBackground();
415     return null;
416   }
417 
418   /**
419    * Returns the foreground color for selected menu items, from the installed
420    * theme.
421    *
422    * @return The foreground color for selected menu items.
423    *
424    * @see #getMenuForeground()
425    */
getMenuSelectedForeground()426   public static ColorUIResource getMenuSelectedForeground()
427   {
428     if (theme != null)
429       return theme.getMenuSelectedForeground();
430     return null;
431   }
432 
433   /**
434    * Returns the font used for text in menus, from the installed theme.
435    *
436    * @return The font used for text in menus.
437    */
getMenuTextFont()438   public static FontUIResource getMenuTextFont()
439   {
440     if (theme != null)
441       return theme.getMenuTextFont();
442     return null;
443   }
444 
445   /**
446    * Returns the primary color for controls, from the installed theme.
447    *
448    * @return The primary color for controls.
449    */
getPrimaryControl()450   public static ColorUIResource getPrimaryControl()
451   {
452     if (theme != null)
453       return theme.getPrimaryControl();
454     return null;
455   }
456 
457   /**
458    * Returns the primary color for the dark shadow on controls, from the
459    * installed theme.
460    *
461    * @return The primary color for the dark shadow on controls.
462    */
getPrimaryControlDarkShadow()463   public static ColorUIResource getPrimaryControlDarkShadow()
464   {
465     if (theme != null)
466       return theme.getPrimaryControlDarkShadow();
467     return null;
468   }
469 
470   /**
471    * Returns the primary color for the highlight on controls, from the
472    * installed theme.
473    *
474    * @return The primary color for the highlight on controls.
475    */
getPrimaryControlHighlight()476   public static ColorUIResource getPrimaryControlHighlight()
477   {
478     if (theme != null)
479       return theme.getPrimaryControlHighlight();
480     return null;
481   }
482 
483   /**
484    * Returns the primary color for the information on controls, from the
485    * installed theme.
486    *
487    * @return The primary color for the information on controls.
488    */
getPrimaryControlInfo()489   public static ColorUIResource getPrimaryControlInfo()
490   {
491     if (theme != null)
492       return theme.getPrimaryControlInfo();
493     return null;
494   }
495 
496   /**
497    * Returns the primary color for the shadow on controls, from the installed
498    * theme.
499    *
500    * @return The primary color for the shadow on controls.
501    */
getPrimaryControlShadow()502   public static ColorUIResource getPrimaryControlShadow()
503   {
504     if (theme != null)
505       return theme.getPrimaryControlShadow();
506     return null;
507   }
508 
509   /**
510    * Returns the background color for separators, from the installed theme.
511    *
512    * @return The background color for separators.
513    */
getSeparatorBackground()514   public static ColorUIResource getSeparatorBackground()
515   {
516     if (theme != null)
517       return theme.getSeparatorBackground();
518     return null;
519   }
520 
521   /**
522    * Returns the foreground color for separators, from the installed theme.
523    *
524    * @return The foreground color for separators.
525    */
getSeparatorForeground()526   public static ColorUIResource getSeparatorForeground()
527   {
528     if (theme != null)
529       return theme.getSeparatorForeground();
530     return null;
531   }
532 
533   /**
534    * Returns the font used for sub text, from the installed theme.
535    *
536    * @return The font used for sub text.
537    */
getSubTextFont()538   public static FontUIResource getSubTextFont()
539   {
540     if (theme != null)
541       return theme.getSubTextFont();
542     return null;
543   }
544 
545   /**
546    * Returns the color used for system text, from the installed theme.
547    *
548    * @return The color used for system text.
549    */
getSystemTextColor()550   public static ColorUIResource getSystemTextColor()
551   {
552     if (theme != null)
553       return theme.getSystemTextColor();
554     return null;
555   }
556 
557   /**
558    * Returns the font used for system text, from the installed theme.
559    *
560    * @return The font used for system text.
561    */
getSystemTextFont()562   public static FontUIResource getSystemTextFont()
563   {
564     if (theme != null)
565       return theme.getSystemTextFont();
566     return null;
567   }
568 
569   /**
570    * Returns the color used to highlight text, from the installed theme.
571    *
572    * @return The color used to highlight text.
573    */
getTextHighlightColor()574   public static ColorUIResource getTextHighlightColor()
575   {
576     if (theme != null)
577       return theme.getTextHighlightColor();
578     return null;
579   }
580 
581   /**
582    * Returns the color used to display user text, from the installed theme.
583    *
584    * @return The color used to display user text.
585    */
getUserTextColor()586   public static ColorUIResource getUserTextColor()
587   {
588     if (theme != null)
589       return theme.getUserTextColor();
590     return null;
591   }
592 
593   /**
594    * Returns the font used for user text, obtained from the current theme.
595    *
596    * @return The font used for user text.
597    */
getUserTextFont()598   public static FontUIResource getUserTextFont()
599   {
600     if (theme != null)
601       return theme.getUserTextFont();
602     return null;
603   }
604 
605   /**
606    * Returns the color used for white, from the installed theme.
607    *
608    * @return The color used for white.
609    */
getWhite()610   public static ColorUIResource getWhite()
611   {
612     if (theme != null)
613       return theme.getWhite();
614     return null;
615   }
616 
617   /**
618    * Returns the window background color, from the installed theme.
619    *
620    * @return The window background color.
621    */
getWindowBackground()622   public static ColorUIResource getWindowBackground()
623   {
624     if (theme != null)
625       return theme.getWindowBackground();
626     return null;
627   }
628 
629   /**
630    * Returns the window title background color, from the installed theme.
631    *
632    * @return The window title background color.
633    */
getWindowTitleBackground()634   public static ColorUIResource getWindowTitleBackground()
635   {
636     if (theme != null)
637       return theme.getWindowTitleBackground();
638     return null;
639   }
640 
641   /**
642    * Returns the window title font from the current theme.
643    *
644    * @return The window title font.
645    *
646    * @see MetalTheme
647    */
getWindowTitleFont()648   public static FontUIResource getWindowTitleFont()
649   {
650     if (theme != null)
651       return theme.getWindowTitleFont();
652     return null;
653   }
654 
655   /**
656    * Returns the window title foreground color, from the installed theme.
657    *
658    * @return The window title foreground color.
659    */
getWindowTitleForeground()660   public static ColorUIResource getWindowTitleForeground()
661   {
662     if (theme != null)
663       return theme.getWindowTitleForeground();
664     return null;
665   }
666 
667   /**
668    * Returns the background color for an inactive window title, from the
669    * installed theme.
670    *
671    * @return The background color for an inactive window title.
672    */
getWindowTitleInactiveBackground()673   public static ColorUIResource getWindowTitleInactiveBackground()
674   {
675     if (theme != null)
676       return theme.getWindowTitleInactiveBackground();
677     return null;
678   }
679 
680   /**
681    * Returns the foreground color for an inactive window title, from the
682    * installed theme.
683    *
684    * @return The foreground color for an inactive window title.
685    */
getWindowTitleInactiveForeground()686   public static ColorUIResource getWindowTitleInactiveForeground()
687   {
688     if (theme != null)
689       return theme.getWindowTitleInactiveForeground();
690     return null;
691   }
692 
693   /**
694    * Sets the current theme for the look and feel.  Note that the theme must be
695    * set <em>before</em> the look and feel is installed.  To change the theme
696    * for an already running application that is using the
697    * {@link MetalLookAndFeel}, first set the theme with this method, then
698    * create a new instance of {@link MetalLookAndFeel} and install it in the
699    * usual way (see {@link UIManager#setLookAndFeel(LookAndFeel)}).
700    *
701    * @param theme  the theme (<code>null</code> not permitted).
702    *
703    * @throws NullPointerException if <code>theme</code> is <code>null</code>.
704    *
705    * @see #getCurrentTheme()
706    */
setCurrentTheme(MetalTheme theme)707   public static void setCurrentTheme(MetalTheme theme)
708   {
709     if (theme == null)
710       throw new NullPointerException("Null 'theme' not permitted.");
711     MetalLookAndFeel.theme = theme;
712   }
713 
714   /**
715    * Sets the ComponentUI classes for all Swing components to the Metal
716    * implementations.
717    *
718    * In particular this sets the following keys:
719    *
720    * <table>
721    * <tr>
722    * <th>Key</th><th>Value</th>
723    * </tr><tr>
724    * <td>ButtonUI</td><td>{@link MetalButtonUI}</td>
725    * </tr><tr>
726    * <td>CheckBoxUI</td><td>{@link MetalCheckBoxUI}</td>
727    * </tr><tr>
728    * <td>ComboBoxUI</td><td>{@link MetalComboBoxUI}</td>
729    * </tr><tr>
730    * <td>DesktopIconUI</td><td>{@link MetalDesktopIconUI}</td>
731    * </tr><tr>
732    * <td>InternalFrameUI</td><td>{@link MetalInternalFrameUI}</td>
733    * </tr><tr>
734    * <td>LabelUI</td><td>{@link MetalLabelUI}</td>
735    * </tr><tr>
736    * <td>PopupMenuSeparatorUI</td><td>{@link MetalPopupMenuSeparatorUI}</td>
737    * </tr><tr>
738    * <td>ProgressBarUI</td><td>{@link MetalProgressBarUI}</td>
739    * </tr><tr>
740    * <td>RadioButtonUI</td><td>{@link MetalRadioButtonUI}</td>
741    * </tr><tr>
742    * <td>RootPaneUI</td><td>{@link MetalRootPaneUI}</td>
743    * </tr><tr>
744    * <td>ScrollBarUI</td><td>{@link MetalScrollBarUI}</td>
745    * </tr><tr>
746    * <td>ScrollPaneUI</td><td>{@link MetalScrollPaneUI}</td>
747    * </tr><tr>
748    * <td>SeparatorUI</td><td>{@link MetalSeparatorUI}</td>
749    * </tr><tr>
750    * <td>SliderUI</td><td>{@link MetalSliderUI}</td>
751    * </tr><tr>
752    * <td>SplitPaneUI</td><td>{@link MetalSplitPaneUI}</td>
753    * </tr><tr>
754    * <td>TabbedPaneUI</td><td>{@link MetalTabbedPaneUI}</td>
755    * </tr><tr>
756    * <td>TextFieldUI</td><td>{@link MetalTextFieldUI}</td>
757    * </tr><tr>
758    * <td>ToggleButtonUI</td><td>{@link MetalToggleButtonUI}</td>
759    * </tr><tr>
760    * <td>ToolBarUI</td><td>{@link MetalToolBarUI}</td>
761    * </tr><tr>
762    * <td>ToolTipUI</td><td>{@link MetalToolTipUI}</td>
763    * </tr><tr>
764    * <td>TreeUI</td><td>{@link MetalTreeUI}</td>
765    * </tr><tr>
766    * </table>
767    *
768    * @param defaults the UIDefaults where the class defaults are added
769    */
initClassDefaults(UIDefaults defaults)770   protected void initClassDefaults(UIDefaults defaults)
771   {
772     super.initClassDefaults(defaults);
773 
774     // Variables
775     Object[] uiDefaults;
776     // Initialize Class Defaults
777     uiDefaults = new Object[] {
778       "ButtonUI", "javax.swing.plaf.metal.MetalButtonUI",
779       "CheckBoxUI", "javax.swing.plaf.metal.MetalCheckBoxUI",
780       "ComboBoxUI", "javax.swing.plaf.metal.MetalComboBoxUI",
781       "DesktopIconUI", "javax.swing.plaf.metal.MetalDesktopIconUI",
782       "FileChooserUI", "javax.swing.plaf.metal.MetalFileChooserUI",
783       "InternalFrameUI", "javax.swing.plaf.metal.MetalInternalFrameUI",
784       "LabelUI", "javax.swing.plaf.metal.MetalLabelUI",
785       "MenuBarUI", "javax.swing.plaf.metal.MetalMenuBarUI",
786       "PopupMenuSeparatorUI",
787       "javax.swing.plaf.metal.MetalPopupMenuSeparatorUI",
788       "ProgressBarUI", "javax.swing.plaf.metal.MetalProgressBarUI",
789       "RadioButtonUI", "javax.swing.plaf.metal.MetalRadioButtonUI",
790       "RootPaneUI", "javax.swing.plaf.metal.MetalRootPaneUI",
791       "ScrollBarUI", "javax.swing.plaf.metal.MetalScrollBarUI",
792       "ScrollPaneUI", "javax.swing.plaf.metal.MetalScrollPaneUI",
793       "SeparatorUI", "javax.swing.plaf.metal.MetalSeparatorUI",
794       "SliderUI", "javax.swing.plaf.metal.MetalSliderUI",
795       "SplitPaneUI", "javax.swing.plaf.metal.MetalSplitPaneUI",
796       "TabbedPaneUI", "javax.swing.plaf.metal.MetalTabbedPaneUI",
797       "TextFieldUI", "javax.swing.plaf.metal.MetalTextFieldUI",
798       "ToggleButtonUI", "javax.swing.plaf.metal.MetalToggleButtonUI",
799       "ToolBarUI", "javax.swing.plaf.metal.MetalToolBarUI",
800       "ToolTipUI", "javax.swing.plaf.metal.MetalToolTipUI",
801       "TreeUI", "javax.swing.plaf.metal.MetalTreeUI",
802     };
803     // Add Class Defaults to UI Defaults table
804     defaults.putDefaults(uiDefaults);
805   }
806 
807   /**
808    * Initializes the component defaults for the Metal Look &amp; Feel.
809    *
810    * In particular this sets the following keys (the colors are given
811    * as RGB hex values):
812    *
813    * <table>
814    * <tr>
815    * <th>Key</th><th>Value</th>
816    * </tr><tr>
817    * <td>Button.background</td><td>0xcccccc</td>
818    * </tr><tr>
819    * <td>Button.border</td><td>{@link MetalBorders#getButtonBorder()}</td>
820    * </tr><tr>
821    * <td>Button.font</td><td>{@link #getControlTextFont}</td>
822    * </tr><tr>
823    * <td>Button.margin</td><td><code>new java.awt.Insets(2, 14, 2, 14)</code>
824    * </td>
825    * </tr><tr>
826    * <td>CheckBox.background</td><td>0xcccccc</td>
827    * </tr><tr>
828    * <td>CheckBoxMenuItem.background</td><td>0xcccccc</td>
829    * </tr><tr>
830    * <td>ToolBar.background</td><td>0xcccccc</td>
831    * </tr><tr>
832    * <td>Panel.background</td><td>0xcccccc</td>
833    * </tr><tr>
834    * <td>Slider.background</td><td>0xcccccc</td>
835    * </tr><tr>
836    * <td>OptionPane.background</td><td>0xcccccc</td>
837    * </tr><tr>
838    * <td>ProgressBar.background</td><td>0xcccccc</td>
839    * </tr><tr>
840    * <td>TabbedPane.background</td><td>0xcccccc</td>
841    * </tr><tr>
842    * <td>Label.background</td><td>0xcccccc</td>
843    * </tr><tr>
844    * <td>Label.font</td><td>{@link #getControlTextFont}</td>
845    * </tr><tr>
846    * <td>Menu.background</td><td>0xcccccc</td>
847    * </tr><tr>
848    * <td>MenuBar.background</td><td>0xcccccc</td>
849    * </tr><tr>
850    * <td>MenuItem.background</td><td>0xcccccc</td>
851    * </tr><tr>
852    * <td>ScrollBar.background</td><td>0xcccccc</td>
853    * </tr><tr>
854    * <td>PopupMenu.border</td>
855    * <td><code>new javax.swing.plaf.metal.MetalBorders.PopupMenuBorder()</td>
856    * </tr><tr>
857    * </table>
858    *
859    * @param defaults the UIDefaults instance to which the values are added
860    */
initComponentDefaults(UIDefaults defaults)861   protected void initComponentDefaults(UIDefaults defaults)
862   {
863     super.initComponentDefaults(defaults);
864     Object[] myDefaults = new Object[] {
865       "Button.background", getControl(),
866       "Button.border", MetalBorders.getButtonBorder(),
867       "Button.darkShadow", getControlDarkShadow(),
868       "Button.disabledText", getInactiveControlTextColor(),
869       "Button.focus", getFocusColor(),
870       "Button.font", getControlTextFont(),
871       "Button.foreground", getControlTextColor(),
872       "Button.highlight", getControlHighlight(),
873       "Button.light", getControlHighlight(),
874       "Button.margin", new InsetsUIResource(2, 14, 2, 14),
875       "Button.select", getControlShadow(),
876       "Button.shadow", getControlShadow(),
877 
878       "CheckBox.background", getControl(),
879       "CheckBox.border", MetalBorders.getButtonBorder(),
880       "CheckBox.disabledText", getInactiveControlTextColor(),
881       "CheckBox.focus", getFocusColor(),
882       "CheckBox.font", getControlTextFont(),
883       "CheckBox.foreground", getControlTextColor(),
884       "CheckBox.icon",
885       new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalCheckBoxIcon"),
886       "CheckBox.checkIcon",
887       new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalCheckBoxIcon"),
888       "Checkbox.select", getControlShadow(),
889 
890       "CheckBoxMenuItem.acceleratorFont", new FontUIResource("Dialog", Font.PLAIN, 10),
891       "CheckBoxMenuItem.acceleratorForeground", getAcceleratorForeground(),
892       "CheckBoxMenuItem.acceleratorSelectionForeground", getAcceleratorSelectedForeground(),
893       "CheckBoxMenuItem.background", getMenuBackground(),
894       "CheckBoxMenuItem.borderPainted", Boolean.TRUE,
895       "CheckBoxMenuItem.commandSound", "sounds/MenuItemCommand.wav",
896       "CheckBoxMenuItem.checkIcon", MetalIconFactory.getCheckBoxMenuItemIcon(),
897       "CheckBoxMenuItem.disabledForeground", getMenuDisabledForeground(),
898       "CheckBoxMenuItem.font", getMenuTextFont(),
899       "CheckBoxMenuItem.foreground", getMenuForeground(),
900       "CheckBoxMenuItem.selectionBackground", getMenuSelectedBackground(),
901       "CheckBoxMenuItem.selectionForeground", getMenuSelectedForeground(),
902 
903       "ColorChooser.background", getControl(),
904       "ColorChooser.foreground", getControlTextColor(),
905       "ColorChooser.rgbBlueMnemonic", new Integer(0),
906       "ColorChooser.rgbGreenMnemonic", new Integer(0),
907       "ColorChooser.rgbRedMnemonic", new Integer(0),
908       "ColorChooser.swatchesDefaultRecentColor", getControl(),
909 
910       "ComboBox.background", getControl(),
911       "ComboBox.buttonBackground", getControl(),
912       "ComboBox.buttonDarkShadow", getControlDarkShadow(),
913       "ComboBox.buttonHighlight", getControlHighlight(),
914       "ComboBox.buttonShadow", getControlShadow(),
915       "ComboBox.disabledBackground", getControl(),
916       "ComboBox.disabledForeground", getInactiveSystemTextColor(),
917       "ComboBox.font", getControlTextFont(),
918       "ComboBox.foreground", getControlTextColor(),
919       "ComboBox.selectionBackground", getPrimaryControlShadow(),
920       "ComboBox.selectionForeground", getControlTextColor(),
921 
922       "Desktop.background", getDesktopColor(),
923 
924       "DesktopIcon.background", getControl(),
925       "DesktopIcon.foreground", getControlTextColor(),
926       "DesktopIcon.width", new Integer(160),
927       "DesktopIcon.border", MetalBorders.getDesktopIconBorder(),
928       "DesktopIcon.font", getControlTextFont(),
929 
930       "EditorPane.background", getWindowBackground(),
931       "EditorPane.caretForeground", getUserTextColor(),
932       "EditorPane.font", getControlTextFont(),
933       "EditorPane.foreground",  getUserTextColor(),
934       "EditorPane.inactiveForeground",  getInactiveSystemTextColor(),
935       "EditorPane.selectionBackground", getTextHighlightColor(),
936       "EditorPane.selectionForeground", getHighlightedTextColor(),
937 
938       "FormattedTextField.background", getWindowBackground(),
939       "FormattedTextField.border",
940       new BorderUIResource(MetalBorders.getTextFieldBorder()),
941       "FormattedTextField.caretForeground", getUserTextColor(),
942       "FormattedTextField.font", new FontUIResource("Dialog", Font.PLAIN, 12),
943       "FormattedTextField.foreground",  getUserTextColor(),
944       "FormattedTextField.inactiveBackground",  getControl(),
945       "FormattedTextField.inactiveForeground",  getInactiveSystemTextColor(),
946       "FormattedTextField.selectionBackground", getTextHighlightColor(),
947       "FormattedTextField.selectionForeground", getHighlightedTextColor(),
948 
949       "FileChooser.upFolderIcon",
950           MetalIconFactory.getFileChooserUpFolderIcon(),
951       "FileChooser.listViewIcon",
952           MetalIconFactory.getFileChooserListViewIcon(),
953       "FileChooser.newFolderIcon",
954           MetalIconFactory.getFileChooserNewFolderIcon(),
955       "FileChooser.homeFolderIcon",
956           MetalIconFactory.getFileChooserHomeFolderIcon(),
957       "FileChooser.detailsViewIcon",
958           MetalIconFactory.getFileChooserDetailViewIcon(),
959       "FileChooser.fileNameLabelMnemonic", new Integer(78),
960       "FileChooser.filesOfTypeLabelMnemonic", new Integer(84),
961       "FileChooser.lookInLabelMnemonic", new Integer(73),
962       "FileView.computerIcon", MetalIconFactory.getTreeComputerIcon(),
963       "FileView.directoryIcon", MetalIconFactory.getTreeFolderIcon(),
964       "FileView.fileIcon", MetalIconFactory.getTreeLeafIcon(),
965       "FileView.floppyDriveIcon", MetalIconFactory.getTreeFloppyDriveIcon(),
966       "FileView.hardDriveIcon", MetalIconFactory.getTreeHardDriveIcon(),
967 
968       "InternalFrame.activeTitleBackground", getWindowTitleBackground(),
969       "InternalFrame.activeTitleForeground", getWindowTitleForeground(),
970       "InternalFrame.border", new MetalBorders.InternalFrameBorder(),
971       "InternalFrame.borderColor", getControl(),
972       "InternalFrame.borderDarkShadow", getControlDarkShadow(),
973       "InternalFrame.borderHighlight", getControlHighlight(),
974       "InternalFrame.borderLight", getControlHighlight(),
975       "InternalFrame.borderShadow", getControlShadow(),
976       "InternalFrame.icon", MetalIconFactory.getInternalFrameDefaultMenuIcon(),
977       "InternalFrame.closeIcon",
978         MetalIconFactory.getInternalFrameCloseIcon(16),
979       "InternalFrame.closeSound", "sounds/FrameClose.wav",
980       "InternalFrame.inactiveTitleBackground", getWindowTitleInactiveBackground(),
981       "InternalFrame.inactiveTitleForeground", getWindowTitleInactiveForeground(),
982       "InternalFrame.maximizeIcon",
983         MetalIconFactory.getInternalFrameMaximizeIcon(16),
984       "InternalFrame.maximizeSound", "sounds/FrameMaximize.wav",
985       "InternalFrame.iconifyIcon",
986         MetalIconFactory.getInternalFrameMinimizeIcon(16),
987       "InternalFrame.minimizeSound", "sounds/FrameMinimize.wav",
988       "InternalFrame.paletteBorder", new MetalBorders.PaletteBorder(),
989       "InternalFrame.paletteCloseIcon", new MetalIconFactory.PaletteCloseIcon(),
990       "InternalFrame.paletteTitleHeight", new Integer(11),
991       "InternalFrame.restoreDownSound", "sounds/FrameRestoreDown.wav",
992       "InternalFrame.restoreUpSound", "sounds/FrameRestoreUp.wav",
993 
994       "Label.background", getControl(),
995       "Label.disabledForeground", getInactiveSystemTextColor(),
996       "Label.disabledShadow", getControlShadow(),
997       "Label.font", getControlTextFont(),
998       "Label.foreground", getSystemTextColor(),
999 
1000       "List.font", getControlTextFont(),
1001       "List.background", getWindowBackground(),
1002       "List.foreground", getUserTextColor(),
1003       "List.selectionBackground", getTextHighlightColor(),
1004       "List.selectionForeground", getHighlightedTextColor(),
1005       "List.focusCellHighlightBorder",
1006         new LineBorderUIResource(MetalLookAndFeel.getFocusColor()),
1007 
1008       "Menu.acceleratorFont", new FontUIResource("Dialog", Font.PLAIN, 10),
1009       "Menu.acceleratorForeground", getAcceleratorForeground(),
1010       "Menu.acceleratorSelectionForeground", getAcceleratorSelectedForeground(),
1011       "Menu.arrowIcon", MetalIconFactory.getMenuArrowIcon(),
1012       "Menu.background", getMenuBackground(),
1013       "Menu.border", new MetalBorders.MenuItemBorder(),
1014       "Menu.borderPainted", Boolean.TRUE,
1015       "MenuItem.commandSound", "sounds/MenuItemCommand.wav",
1016       "Menu.disabledForeground", getMenuDisabledForeground(),
1017       "Menu.font", getMenuTextFont(),
1018       "Menu.foreground", getMenuForeground(),
1019       "Menu.selectionBackground", getMenuSelectedBackground(),
1020       "Menu.selectionForeground", getMenuSelectedForeground(),
1021       "Menu.submenuPopupOffsetX", new Integer(-4),
1022       "Menu.submenuPopupOffsetY", new Integer(-3),
1023 
1024       "MenuBar.background", getMenuBackground(),
1025       "MenuBar.border", new MetalBorders.MenuBarBorder(),
1026       "MenuBar.font", getMenuTextFont(),
1027       "MenuBar.foreground", getMenuForeground(),
1028       "MenuBar.highlight", getControlHighlight(),
1029       "MenuBar.shadow", getControlShadow(),
1030 
1031       "MenuItem.acceleratorDelimiter", "-",
1032       "MenuItem.acceleratorFont", new FontUIResource("Dialog", Font.PLAIN, 10),
1033       "MenuItem.acceleratorForeground", getAcceleratorForeground(),
1034       "MenuItem.acceleratorSelectionForeground", getAcceleratorSelectedForeground(),
1035       "MenuItem.arrowIcon", MetalIconFactory.getMenuItemArrowIcon(),
1036       "MenuItem.background", getMenuBackground(),
1037       "MenuItem.border", new MetalBorders.MenuItemBorder(),
1038       "MenuItem.borderPainted", Boolean.TRUE,
1039       "MenuItem.disabledForeground", getMenuDisabledForeground(),
1040       "MenuItem.font", getMenuTextFont(),
1041       "MenuItem.foreground", getMenuForeground(),
1042       "MenuItem.selectionBackground", getMenuSelectedBackground(),
1043       "MenuItem.selectionForeground", getMenuSelectedForeground(),
1044 
1045       "OptionPane.background", getControl(),
1046       "OptionPane.errorSound", "sounds/OptionPaneError.wav",
1047       "OptionPane.informationSound", "sounds/OptionPaneInformation.wav",
1048       "OptionPane.questionSound", "sounds/OptionPaneQuestion.wav",
1049       "OptionPane.warningSound", "sounds/OptionPaneWarning.wav",
1050       "OptionPane.errorDialog.border.background", new ColorUIResource(153, 51, 51),
1051       "OptionPane.errorDialog.titlePane.background", new ColorUIResource(255, 153, 153),
1052       "OptionPane.errorDialog.titlePane.foreground", new ColorUIResource(51, 0, 0),
1053       "OptionPane.errorDialog.titlePane.shadow", new ColorUIResource(204, 102, 102),
1054       "OptionPane.foreground", getControlTextColor(),
1055       "OptionPane.messageForeground", getControlTextColor(),
1056       "OptionPane.questionDialog.border.background", new ColorUIResource(51, 102, 51),
1057       "OptionPane.questionDialog.titlePane.background", new ColorUIResource(153, 204, 153),
1058       "OptionPane.questionDialog.titlePane.foreground", new ColorUIResource(0, 51, 0),
1059       "OptionPane.questionDialog.titlePane.shadow", new ColorUIResource(102, 153, 102),
1060       "OptionPane.warningDialog.border.background", new ColorUIResource(153, 102, 51),
1061       "OptionPane.warningDialog.titlePane.background", new ColorUIResource(255, 204, 153),
1062       "OptionPane.warningDialog.titlePane.foreground", new ColorUIResource(102, 51, 0),
1063       "OptionPane.warningDialog.titlePane.shadow", new ColorUIResource(204, 153, 102),
1064 
1065       "Panel.background", getControl(),
1066       "Panel.foreground", getUserTextColor(),
1067 
1068       "PasswordField.background", getWindowBackground(),
1069       "PasswordField.border",
1070       new BorderUIResource(MetalBorders.getTextFieldBorder()),
1071       "PasswordField.caretForeground", getUserTextColor(),
1072       "PasswordField.foreground", getUserTextColor(),
1073       "PasswordField.font", new FontUIResource("Dialog", Font.PLAIN, 12),
1074       "PasswordField.inactiveBackground", getControl(),
1075       "PasswordField.inactiveForeground", getInactiveSystemTextColor(),
1076       "PasswordField.selectionBackground", getTextHighlightColor(),
1077       "PasswordField.selectionForeground", getHighlightedTextColor(),
1078 
1079       "PopupMenu.background", getMenuBackground(),
1080       "PopupMenu.border", new MetalBorders.PopupMenuBorder(),
1081       "PopupMenu.font", getMenuTextFont(),
1082       "PopupMenu.foreground", getMenuForeground(),
1083       "PopupMenu.popupSound", "sounds/PopupMenuPopup.wav",
1084 
1085       "ProgressBar.background", getControl(),
1086       "ProgressBar.border", new BorderUIResource.LineBorderUIResource(getControlDarkShadow(), 1),
1087       "ProgressBar.font", getControlTextFont(),
1088       "ProgressBar.foreground", getPrimaryControlShadow(),
1089       "ProgressBar.selectionBackground", getPrimaryControlDarkShadow(),
1090       "ProgressBar.selectionForeground", getControl(),
1091 
1092       "RadioButton.background", getControl(),
1093       "RadioButton.darkShadow", getControlDarkShadow(),
1094       "RadioButton.disabledText", getInactiveControlTextColor(),
1095       "RadioButton.icon",
1096       new UIDefaults.LazyValue()
1097       {
1098         public Object createValue(UIDefaults def)
1099           {
1100             return MetalIconFactory.getRadioButtonIcon();
1101           }
1102       },
1103       "RadioButton.focus", MetalLookAndFeel.getFocusColor(),
1104       "RadioButton.font", MetalLookAndFeel.getControlTextFont(),
1105       "RadioButton.foreground", getControlTextColor(),
1106       "RadioButton.highlight", getControlHighlight(),
1107       "RadioButton.light", getControlHighlight(),
1108       "RadioButton.select", getControlShadow(),
1109       "RadioButton.shadow", getControlShadow(),
1110 
1111       "RadioButtonMenuItem.acceleratorFont", new Font("Dialog", Font.PLAIN, 10),
1112       "RadioButtonMenuItem.acceleratorForeground", getAcceleratorForeground(),
1113       "RadioButtonMenuItem.acceleratorSelectionForeground", getAcceleratorSelectedForeground(),
1114       "RadioButtonMenuItem.background", getMenuBackground(),
1115       "RadioButtonMenuItem.border", new MetalBorders.MenuItemBorder(),
1116       "RadioButtonMenuItem.borderPainted", Boolean.TRUE,
1117       "RadioButtonMenuItem.checkIcon",
1118         MetalIconFactory.getRadioButtonMenuItemIcon(),
1119       "RadioButtonMenuItem.commandSound", "sounds/MenuItemCommand.wav",
1120       "RadioButtonMenuItem.disabledForeground", getMenuDisabledForeground(),
1121       "RadioButtonMenuItem.font", getMenuTextFont(),
1122       "RadioButtonMenuItem.foreground", getMenuForeground(),
1123       "RadioButtonMenuItem.margin", new InsetsUIResource(2, 2, 2, 2),
1124       "RadioButtonMenuItem.selectionBackground",
1125         MetalLookAndFeel.getMenuSelectedBackground(),
1126       "RadioButtonMenuItem.selectionForeground",
1127         MetalLookAndFeel.getMenuSelectedForeground(),
1128 
1129       "ScrollBar.allowsAbsolutePositioning", Boolean.TRUE,
1130       "ScrollBar.background", getControl(),
1131       "ScrollBar.darkShadow", getControlDarkShadow(),
1132       "ScrollBar.foreground", getControl(),
1133       "ScrollBar.highlight", getControlHighlight(),
1134       "ScrollBar.shadow", getControlShadow(),
1135       "ScrollBar.thumb", getPrimaryControlShadow(),
1136       "ScrollBar.thumbDarkShadow", getControlDarkShadow(),
1137       "ScrollBar.thumbHighlight", getPrimaryControl(),
1138       "ScrollBar.thumbShadow", getPrimaryControlDarkShadow(),
1139       "ScrollBar.track", getControl(),
1140       "ScrollBar.trackHighlight", getControlDarkShadow(),
1141       "ScrollBar.width", new Integer(17),
1142 
1143       "ScrollPane.background", getControl(),
1144       "ScrollPane.border", new MetalBorders.ScrollPaneBorder(),
1145       "ScrollPane.foreground", getControlTextColor(),
1146 
1147       "Separator.background", getSeparatorBackground(),
1148       "Separator.foreground", getSeparatorForeground(),
1149       "Separator.highlight", getControlHighlight(),
1150       "Separator.shadow", getControlShadow(),
1151 
1152       "Slider.background", getControl(),
1153       "Slider.focus", getFocusColor(),
1154       "Slider.focusInsets", new InsetsUIResource(0, 0, 0, 0),
1155       "Slider.foreground", getPrimaryControlShadow(),
1156       "Slider.highlight", getControlHighlight(),
1157       "Slider.horizontalThumbIcon",
1158       MetalIconFactory.getHorizontalSliderThumbIcon(),
1159       "Slider.majorTickLength", new Integer(6),
1160       "Slider.shadow", getControlShadow(),
1161       "Slider.trackWidth", new Integer(7),
1162       "Slider.verticalThumbIcon",
1163       MetalIconFactory.getVerticalSliderThumbIcon(),
1164 
1165       "Spinner.arrowButtonInsets", new InsetsUIResource(0, 0, 0, 0),
1166       "Spinner.background", getControl(),
1167       "Spinner.border", MetalBorders.getTextFieldBorder(),
1168       "Spinner.font", getControlTextFont(),
1169       "Spinner.foreground", getControl(),
1170 
1171       "SplitPane.background", getControl(),
1172       "SplitPane.darkShadow", getControlDarkShadow(),
1173       "SplitPane.dividerFocusColor", getPrimaryControl(),
1174       "SplitPane.dividerSize", new Integer(10),
1175       "SplitPane.highlight", getControlHighlight(),
1176       "SplitPane.shadow", getControlShadow(),
1177 
1178       "SplitPaneDivider.draggingColor", Color.DARK_GRAY,
1179 
1180       "TabbedPane.background", getControlShadow(),
1181       "TabbedPane.contentBorderInsets", new InsetsUIResource(2, 2, 3, 3),
1182       "TabbedPane.contentOpaque", Boolean.TRUE,
1183       "TabbedPane.darkShadow", getControlDarkShadow(),
1184       "TabbedPane.focus", getPrimaryControlDarkShadow(),
1185       "TabbedPane.font", getControlTextFont(),
1186       "TabbedPane.foreground", getControlTextColor(),
1187       "TabbedPane.highlight", getControlHighlight(),
1188       "TabbedPane.light", getControl(),
1189       "TabbedPane.selected", getControl(), // overridden in OceanTheme
1190       "TabbedPane.selectHighlight", getControlHighlight(),
1191       "TabbedPane.selectedTabPadInsets", new InsetsUIResource(2, 2, 2, 1),
1192       "TabbedPane.shadow", getControlShadow(),
1193       "TabbedPane.tabAreaBackground", getControl(), // overridden in OceanTheme
1194       "TabbedPane.tabAreaInsets", new InsetsUIResource(4, 2, 0, 6), // dito
1195       "TabbedPane.tabInsets", new InsetsUIResource(0, 9, 1, 9),
1196 
1197       // new properties in OceanTheme:
1198       // TabbedPane.contentAreaColor
1199       // TabbedPane.unselectedBackground
1200 
1201       "Table.background", getWindowBackground(),
1202       "Table.focusCellBackground", getWindowBackground(),
1203       "Table.focusCellForeground", getControlTextColor(),
1204       "Table.foreground", getControlTextColor(),
1205       "Table.focusCellHighlightBorder",
1206       new BorderUIResource.LineBorderUIResource(getFocusColor()),
1207       "Table.focusCellBackground", getWindowBackground(),
1208       "Table.gridColor", getControlDarkShadow(),
1209       "Table.selectionBackground", new ColorUIResource(204, 204, 255),
1210       "Table.selectionForeground", new ColorUIResource(0, 0, 0),
1211 
1212       "TableHeader.background", getControl(),
1213       "TableHeader.cellBorder", new MetalBorders.TableHeaderBorder(),
1214       "TableHeader.foreground", getControlTextColor(),
1215 
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(),
1223 
1224       "TextField.background", getWindowBackground(),
1225       "TextField.border",
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(),
1238 
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(),
1246 
1247       "TitledBorder.border", new LineBorderUIResource(getPrimaryControl(), 1),
1248       "TitledBorder.font", getControlTextFont(),
1249       "TitledBorder.titleColor", getSystemTextColor(),
1250 
1251       "ToggleButton.background", getControl(),
1252       "ToggleButton.border", MetalBorders.getToggleButtonBorder(),
1253       "ToggleButton.darkShadow", getControlDarkShadow(),
1254       "ToggleButton.disabledText", getInactiveControlTextColor(),
1255       "ToggleButton.focus", getFocusColor(),
1256       "ToggleButton.font", getControlTextFont(),
1257       "ToggleButton.foreground", getControlTextColor(),
1258       "ToggleButton.highlight", getControlHighlight(),
1259       "ToggleButton.light", getControlHighlight(),
1260       "ToggleButton.margin", new InsetsUIResource(2, 14, 2, 14),
1261       "ToggleButton.select", getControlShadow(),
1262       "ToggleButton.shadow", getControlShadow(),
1263 
1264       "ToolBar.background", getMenuBackground(),
1265       "ToolBar.darkShadow", getControlDarkShadow(),
1266       "ToolBar.dockingBackground", getMenuBackground(),
1267       "ToolBar.dockingForeground", getPrimaryControlDarkShadow(),
1268       "ToolBar.floatingBackground", getMenuBackground(),
1269       "ToolBar.floatingForeground", getPrimaryControl(),
1270       "ToolBar.font", getMenuTextFont(),
1271       "ToolBar.foreground", getMenuForeground(),
1272       "ToolBar.highlight", getControlHighlight(),
1273       "ToolBar.light", getControlHighlight(),
1274       "ToolBar.shadow", getControlShadow(),
1275       "ToolBar.border", new MetalBorders.ToolBarBorder(),
1276       "ToolBar.rolloverBorder", MetalBorders.getToolbarButtonBorder(),
1277       "ToolBar.nonrolloverBorder", MetalBorders.getToolbarButtonBorder(),
1278 
1279       "ToolTip.background", getPrimaryControl(),
1280       "ToolTip.backgroundInactive", getControl(),
1281       "ToolTip.border", new BorderUIResource.LineBorderUIResource(getPrimaryControlDarkShadow(), 1),
1282       "ToolTip.borderInactive", new BorderUIResource.LineBorderUIResource(getControlDarkShadow(), 1),
1283       "ToolTip.font", new FontUIResource("Dialog", Font.PLAIN, 12),
1284       "ToolTip.foreground", getPrimaryControlInfo(),
1285       "ToolTip.foregroundInactive", getControlDarkShadow(),
1286       "ToolTip.hideAccelerator", Boolean.FALSE,
1287 
1288       "Tree.background", getWindowBackground(),
1289       "Tree.closedIcon", MetalIconFactory.getTreeFolderIcon(),
1290       "Tree.collapsedIcon", MetalIconFactory.getTreeControlIcon(true),
1291       "Tree.expandedIcon", MetalIconFactory.getTreeControlIcon(false),
1292       "Tree.font", new FontUIResource("Dialog", Font.PLAIN, 12),
1293       "Tree.foreground", getUserTextColor(),
1294       "Tree.hash", getPrimaryControl(),
1295       "Tree.leafIcon", MetalIconFactory.getTreeLeafIcon(),
1296       "Tree.leftChildIndent", new Integer(7),
1297       "Tree.line", getPrimaryControl(),
1298       "Tree.openIcon", MetalIconFactory.getTreeFolderIcon(),
1299       "Tree.rightChildIndent", new Integer(13),
1300       "Tree.rowHeight", new Integer(0),
1301       "Tree.scrollsOnExpand", Boolean.TRUE,
1302       "Tree.selectionBackground", getTextHighlightColor(),
1303       "Tree.selectionBorder", new BorderUIResource.LineBorderUIResource(new Color(102, 102, 153)),
1304       "Tree.selectionBorderColor", getFocusColor(),
1305       "Tree.selectionForeground", getHighlightedTextColor(),
1306       "Tree.textBackground", getWindowBackground(),
1307       "Tree.textForeground", getUserTextColor(),
1308 
1309       "Viewport.background", getControl(),
1310       "Viewport.foreground", getUserTextColor()
1311     };
1312     defaults.putDefaults(myDefaults);
1313   }
1314 
1315   /**
1316    * Initializes the system color defaults.
1317    *
1318    * In particular this sets the following keys:
1319    *
1320    * <table>
1321    * <tr>
1322    * <th>Key</th><th>Value</th><th>Description</th>
1323    * </tr><tr>
1324    * <td>control</td><td>0xcccccc</td><td>The default color for components</td>
1325    * </tr>
1326    * </table>
1327    */
initSystemColorDefaults(UIDefaults defaults)1328   protected void initSystemColorDefaults(UIDefaults defaults)
1329   {
1330     super.initSystemColorDefaults(defaults);
1331     Object[] uiDefaults;
1332     uiDefaults = new Object[] {
1333       "control", new ColorUIResource(getControl()),
1334       "desktop", new ColorUIResource(getDesktopColor())
1335     };
1336     defaults.putDefaults(uiDefaults);
1337   }
1338 
1339   /**
1340    * Returns the current theme for the Metal look and feel.  The default is
1341    * an instance of {@link OceanTheme}.
1342    *
1343    * @return The current theme (never <code>null</code>).
1344    *
1345    * @see #setCurrentTheme(MetalTheme)
1346    */
getCurrentTheme()1347   public static MetalTheme getCurrentTheme()
1348   {
1349     if (theme == null)
1350       {
1351         // swing.metalTheme property documented here:
1352         // http://java.sun.com/j2se/1.5.0/docs/guide/swing/1.5/index.html
1353         if ("steel".equals(SystemProperties.getProperty("swing.metalTheme")))
1354           theme = new DefaultMetalTheme();
1355         else
1356           theme = new OceanTheme();
1357       }
1358     return theme;
1359   }
1360 
1361   /**
1362    * Returns <code>true</code> because the Metal look
1363    * and feel supports window decorations for toplevel
1364    * containers.
1365    *
1366    * @return <code>true</code>
1367    */
getSupportsWindowDecorations()1368   public boolean getSupportsWindowDecorations()
1369   {
1370     return true;
1371   }
1372 }
1373