KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > swing > plaf > metal > MetalLookAndFeel


1 /*
2  * @(#)MetalLookAndFeel.java 1.182 04/04/02
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package javax.swing.plaf.metal;
9
10 import java.awt.*;
11 import javax.swing.plaf.*;
12 import javax.swing.*;
13 import javax.swing.plaf.basic.*;
14 import javax.swing.border.*;
15 import javax.swing.text.JTextComponent JavaDoc;
16 import javax.swing.text.DefaultEditorKit JavaDoc;
17 import java.util.*;
18
19 import java.awt.Font JavaDoc;
20 import java.awt.Color JavaDoc;
21 import java.awt.SystemColor JavaDoc;
22 import java.awt.event.KeyEvent JavaDoc;
23 import java.awt.event.InputEvent JavaDoc;
24 import java.lang.reflect.*;
25 import java.net.URL JavaDoc;
26 import java.io.Serializable JavaDoc;
27
28 import java.security.AccessController JavaDoc;
29 import java.security.PrivilegedAction JavaDoc;
30 import sun.awt.AppContext;
31 import sun.security.action.GetPropertyAction;
32 import sun.swing.SwingLazyValue;
33
34
35 /**
36  * Implements the Java look and feel (codename: Metal).
37  * <p>
38  * By default metal uses bold fonts for many controls. To make all
39  * controls (with the exception of the internal frame title bars and
40  * client decorated frame title bars) use plain fonts you can do either of
41  * the following:
42  * <ul>
43  * <li>Set the system property <code>swing.boldMetal</code> to
44  * <code>false</code>. For example,
45  * <code>java&nbsp;-Dswing.boldMetal=false&nbsp;MyApp</code>.
46  * <li>Set the defaults property <code>swing.boldMetal</code> to
47  * <code>Boolean.FALSE</code>. For example:
48  * <code>UIManager.put("swing.boldMetal",&nbsp;Boolean.FALSE);</code>
49  * </ul>
50  * The defaults property <code>swing.boldMetal</code>, if set,
51  * takes precendence over the system property of the same name. After
52  * setting this defaults property you need to re-install the
53  * <code>MetalLookAndFeel</code>, as well as update the UI
54  * of any previously created widgets. Otherwise the results are undefined.
55  * These lines of code show you how to accomplish this:
56  * <pre>
57  * // turn off bold fonts
58  * UIManager.put("swing.boldMetal", Boolean.FALSE);
59  *
60  * // re-install the Metal Look and Feel
61  * UIManager.setLookAndFeel(new MetalLookAndFeel());
62  *
63  * // only needed to update existing widgets
64  * SwingUtilities.updateComponentTreeUI(rootComponent);
65  * </pre>
66  * <p>
67  * <strong>Warning:</strong>
68  * Serialized objects of this class will not be compatible with
69  * future Swing releases. The current serialization support is
70  * appropriate for short term storage or RMI between applications running
71  * the same version of Swing. As of 1.4, support for long term storage
72  * of all JavaBeans<sup><font size="-2">TM</font></sup>
73  * has been added to the <code>java.beans</code> package.
74  * Please see {@link java.beans.XMLEncoder}.
75  *
76  * @version @(#)MetalLookAndFeel.java 1.182 04/04/02
77  * @author Steve Wilson
78  */

79 public class MetalLookAndFeel extends BasicLookAndFeel
80 {
81
82     private static boolean METAL_LOOK_AND_FEEL_INITED = false;
83
84     private static MetalTheme JavaDoc currentTheme;
85     private static boolean isOnlyOneContext = true;
86     private static AppContext cachedAppContext;
87
88     /**
89      * True if checked for windows yet.
90      */

91     private static boolean checkedWindows;
92     /**
93      * True if running on Windows.
94      */

95     private static boolean isWindows;
96
97     /**
98      * Set to true first time we've checked swing.useSystemFontSettings.
99      */

100     private static boolean checkedSystemFontSettings;
101
102     /**
103      * True indicates we should use system fonts, unless the developer has
104      * specified otherwise with Application.useSystemFontSettings.
105      */

106     private static boolean useSystemFonts;
107
108
109     /**
110      * Returns true if running on Windows.
111      */

112     static boolean isWindows() {
113         if (!checkedWindows) {
114             String JavaDoc osName = (String JavaDoc)AccessController.doPrivileged(
115                 new GetPropertyAction("os.name"));
116             if (osName != null && osName.indexOf("Windows") != -1) {
117                 isWindows = true;
118                 String JavaDoc systemFonts = (String JavaDoc)AccessController.doPrivileged(
119                     new GetPropertyAction("swing.useSystemFontSettings"));
120                 useSystemFonts = (systemFonts != null &&
121                                (Boolean.valueOf(systemFonts).booleanValue()));
122             }
123             checkedWindows = true;
124         }
125         return isWindows;
126     }
127
128     /**
129      * Returns true if system fonts should be used, this is only useful
130      * for windows.
131      */

132     static boolean useSystemFonts() {
133         if (isWindows() && useSystemFonts) {
134             if (METAL_LOOK_AND_FEEL_INITED) {
135                 Object JavaDoc value = UIManager.get(
136                                  "Application.useSystemFontSettings");
137
138                 return (value == null || Boolean.TRUE.equals(value));
139             }
140             // If an instanceof MetalLookAndFeel hasn't been inited yet, we
141
// don't want to trigger loading of a UI by asking the UIManager
142
// for a property, assume the user wants system fonts. This will
143
// be properly adjusted when install is invoked on the
144
// MetalTheme
145
return true;
146         }
147         return false;
148     }
149
150     /**
151      * Returns true if the high contrast theme should be used as the default
152      * theme.
153      */

154     private static boolean useHighContrastTheme() {
155         if (isWindows() && useSystemFonts()) {
156             Boolean JavaDoc highContrast = (Boolean JavaDoc)Toolkit.getDefaultToolkit().
157                                   getDesktopProperty("win.highContrast.on");
158
159             return (highContrast == null) ? false : highContrast.
160                                             booleanValue();
161         }
162         return false;
163     }
164
165     /**
166      * Returns true if we're using the Ocean Theme.
167      */

168     static boolean usingOcean() {
169         return (getCurrentTheme() instanceof OceanTheme JavaDoc);
170     }
171
172     public String JavaDoc getName() {
173         return "Metal";
174     }
175
176     public String JavaDoc getID() {
177         return "Metal";
178     }
179
180     public String JavaDoc getDescription() {
181         return "The Java(tm) Look and Feel";
182     }
183
184     
185     public boolean isNativeLookAndFeel() {
186         return false;
187     }
188
189
190     public boolean isSupportedLookAndFeel() {
191         return true;
192     }
193     
194     /**
195      * Returns true if the <code>LookAndFeel</code> returned
196      * <code>RootPaneUI</code> instances support providing Window decorations
197      * in a <code>JRootPane</code>.
198      * <p>
199      * This implementation returns true, since it does support providing
200      * these border and window title pane decorations.
201      *
202      * @return True if the RootPaneUI instances created support client side
203      * decorations
204      * @see JDialog#setDefaultLookAndFeelDecorated
205      * @see JFrame#setDefaultLookAndFeelDecorated
206      * @see JRootPane#setWindowDecorationStyle
207      * @since 1.4
208      */

209     public boolean getSupportsWindowDecorations() {
210         return true;
211     }
212
213     /**
214      * Creates the mapping from
215      * UI class IDs to <code>ComponentUI</code> classes,
216      * putting the ID-<code>ComponentUI</code> pairs
217      * in the passed-in defaults table.
218      * Each <code>JComponent</code> class
219      * specifies its own UI class ID string.
220      * For example,
221      * <code>JButton</code> has the UI class ID "ButtonUI",
222      * which this method maps to "javax.swing.plaf.metal.MetalButtonUI".
223      *
224      * @see BasicLookAndFeel#getDefaults
225      * @see javax.swing.JComponent#getUIClassID
226      */

227     protected void initClassDefaults(UIDefaults table)
228     {
229         super.initClassDefaults(table);
230         final String JavaDoc metalPackageName = "javax.swing.plaf.metal.";
231
232         Object JavaDoc[] uiDefaults = {
233                    "ButtonUI", metalPackageName + "MetalButtonUI",
234                  "CheckBoxUI", metalPackageName + "MetalCheckBoxUI",
235                  "ComboBoxUI", metalPackageName + "MetalComboBoxUI",
236               "DesktopIconUI", metalPackageName + "MetalDesktopIconUI",
237               "FileChooserUI", metalPackageName + "MetalFileChooserUI",
238             "InternalFrameUI", metalPackageName + "MetalInternalFrameUI",
239                     "LabelUI", metalPackageName + "MetalLabelUI",
240        "PopupMenuSeparatorUI", metalPackageName + "MetalPopupMenuSeparatorUI",
241               "ProgressBarUI", metalPackageName + "MetalProgressBarUI",
242               "RadioButtonUI", metalPackageName + "MetalRadioButtonUI",
243                 "ScrollBarUI", metalPackageName + "MetalScrollBarUI",
244                "ScrollPaneUI", metalPackageName + "MetalScrollPaneUI",
245                 "SeparatorUI", metalPackageName + "MetalSeparatorUI",
246                    "SliderUI", metalPackageName + "MetalSliderUI",
247                 "SplitPaneUI", metalPackageName + "MetalSplitPaneUI",
248                "TabbedPaneUI", metalPackageName + "MetalTabbedPaneUI",
249                 "TextFieldUI", metalPackageName + "MetalTextFieldUI",
250              "ToggleButtonUI", metalPackageName + "MetalToggleButtonUI",
251                   "ToolBarUI", metalPackageName + "MetalToolBarUI",
252                   "ToolTipUI", metalPackageName + "MetalToolTipUI",
253                      "TreeUI", metalPackageName + "MetalTreeUI",
254                  "RootPaneUI", metalPackageName + "MetalRootPaneUI",
255         };
256
257         table.putDefaults(uiDefaults);
258     }
259
260     /**
261      * Load the SystemColors into the defaults table. The keys
262      * for SystemColor defaults are the same as the names of
263      * the public fields in SystemColor.
264      */

265     protected void initSystemColorDefaults(UIDefaults table)
266     {
267         MetalTheme JavaDoc theme = getCurrentTheme();
268         Color JavaDoc control = theme.getControl();
269         Object JavaDoc[] systemColors = {
270                 "desktop", theme.getDesktopColor(), /* Color of the desktop background */
271           "activeCaption", theme.getWindowTitleBackground(), /* Color for captions (title bars) when they are active. */
272       "activeCaptionText", theme.getWindowTitleForeground(), /* Text color for text in captions (title bars). */
273     "activeCaptionBorder", theme.getPrimaryControlShadow(), /* Border color for caption (title bar) window borders. */
274         "inactiveCaption", theme.getWindowTitleInactiveBackground(), /* Color for captions (title bars) when not active. */
275     "inactiveCaptionText", theme.getWindowTitleInactiveForeground(), /* Text color for text in inactive captions (title bars). */
276   "inactiveCaptionBorder", theme.getControlShadow(), /* Border color for inactive caption (title bar) window borders. */
277                  "window", theme.getWindowBackground(), /* Default color for the interior of windows */
278            "windowBorder", control, /* ??? */
279              "windowText", theme.getUserTextColor(), /* ??? */
280                    "menu", theme.getMenuBackground(), /* Background color for menus */
281                "menuText", theme.getMenuForeground(), /* Text color for menus */
282                    "text", theme.getWindowBackground(), /* Text background color */
283                "textText", theme.getUserTextColor(), /* Text foreground color */
284           "textHighlight", theme.getTextHighlightColor(), /* Text background color when selected */
285       "textHighlightText", theme.getHighlightedTextColor(), /* Text color when selected */
286        "textInactiveText", theme.getInactiveSystemTextColor(), /* Text color when disabled */
287                 "control", control, /* Default color for controls (buttons, sliders, etc) */
288             "controlText", theme.getControlTextColor(), /* Default color for text in controls */
289        "controlHighlight", theme.getControlHighlight(), /* Specular highlight (opposite of the shadow) */
290      "controlLtHighlight", theme.getControlHighlight(), /* Highlight color for controls */
291           "controlShadow", theme.getControlShadow(), /* Shadow color for controls */
292         "controlDkShadow", theme.getControlDarkShadow(), /* Dark shadow color for controls */
293               "scrollbar", control, /* Scrollbar background (usually the "track") */
294                    "info", theme.getPrimaryControl(), /* ToolTip Background */
295                "infoText", theme.getPrimaryControlInfo() /* ToolTip Text */
296         };
297
298         table.putDefaults(systemColors);
299     }
300
301     /**
302      * Initialize the defaults table with the name of the ResourceBundle
303      * used for getting localized defaults.
304      */

305     private void initResourceBundle(UIDefaults table) {
306         table.addResourceBundle( "com.sun.swing.internal.plaf.metal.resources.metal" );
307     }
308
309     protected void initComponentDefaults(UIDefaults table) {
310         super.initComponentDefaults( table );
311
312         initResourceBundle(table);
313
314         Color JavaDoc acceleratorForeground = getAcceleratorForeground();
315         Color JavaDoc acceleratorSelectedForeground = getAcceleratorSelectedForeground();
316         Color JavaDoc control = getControl();
317         Color JavaDoc controlHighlight = getControlHighlight();
318         Color JavaDoc controlShadow = getControlShadow();
319         Color JavaDoc controlDarkShadow = getControlDarkShadow();
320         Color JavaDoc controlTextColor = getControlTextColor();
321         Color JavaDoc focusColor = getFocusColor();
322         Color JavaDoc inactiveControlTextColor = getInactiveControlTextColor();
323         Color JavaDoc menuBackground = getMenuBackground();
324         Color JavaDoc menuSelectedBackground = getMenuSelectedBackground();
325         Color JavaDoc menuDisabledForeground = getMenuDisabledForeground();
326         Color JavaDoc menuSelectedForeground = getMenuSelectedForeground();
327         Color JavaDoc primaryControl = getPrimaryControl();
328         Color JavaDoc primaryControlDarkShadow = getPrimaryControlDarkShadow();
329         Color JavaDoc primaryControlShadow = getPrimaryControlShadow();
330         Color JavaDoc systemTextColor = getSystemTextColor();
331
332         Insets zeroInsets = new InsetsUIResource(0, 0, 0, 0);
333
334         Integer JavaDoc zero = new Integer JavaDoc(0);
335
336     Object JavaDoc textFieldBorder =
337         new SwingLazyValue("javax.swing.plaf.metal.MetalBorders",
338                       "getTextFieldBorder");
339
340         Object JavaDoc dialogBorder = new MetalLazyValue(
341                           "javax.swing.plaf.metal.MetalBorders$DialogBorder");
342
343         Object JavaDoc questionDialogBorder = new MetalLazyValue(
344                   "javax.swing.plaf.metal.MetalBorders$QuestionDialogBorder");
345
346     Object JavaDoc fieldInputMap = new UIDefaults.LazyInputMap(new Object JavaDoc[] {
347                "ctrl C", DefaultEditorKit.copyAction,
348                "ctrl V", DefaultEditorKit.pasteAction,
349                "ctrl X", DefaultEditorKit.cutAction,
350                  "COPY", DefaultEditorKit.copyAction,
351                 "PASTE", DefaultEditorKit.pasteAction,
352                   "CUT", DefaultEditorKit.cutAction,
353                "shift LEFT", DefaultEditorKit.selectionBackwardAction,
354                     "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction,
355               "shift RIGHT", DefaultEditorKit.selectionForwardAction,
356            "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction,
357             "ctrl LEFT", DefaultEditorKit.previousWordAction,
358              "ctrl KP_LEFT", DefaultEditorKit.previousWordAction,
359                "ctrl RIGHT", DefaultEditorKit.nextWordAction,
360             "ctrl KP_RIGHT", DefaultEditorKit.nextWordAction,
361           "ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
362            "ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction,
363          "ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction,
364           "ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction,
365                "ctrl A", DefaultEditorKit.selectAllAction,
366                  "HOME", DefaultEditorKit.beginLineAction,
367                   "END", DefaultEditorKit.endLineAction,
368                "shift HOME", DefaultEditorKit.selectionBeginLineAction,
369                 "shift END", DefaultEditorKit.selectionEndLineAction,
370                        "BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
371                            "ctrl H", DefaultEditorKit.deletePrevCharAction,
372                            "DELETE", DefaultEditorKit.deleteNextCharAction,
373                             "RIGHT", DefaultEditorKit.forwardAction,
374                              "LEFT", DefaultEditorKit.backwardAction,
375                          "KP_RIGHT", DefaultEditorKit.forwardAction,
376                           "KP_LEFT", DefaultEditorKit.backwardAction,
377                 "ENTER", JTextField.notifyAction,
378           "ctrl BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/,
379                    "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
380     });
381
382         Object JavaDoc passwordInputMap = new UIDefaults.LazyInputMap(new Object JavaDoc[] {
383                            "ctrl C", DefaultEditorKit.copyAction,
384                            "ctrl V", DefaultEditorKit.pasteAction,
385                            "ctrl X", DefaultEditorKit.cutAction,
386                              "COPY", DefaultEditorKit.copyAction,
387                             "PASTE", DefaultEditorKit.pasteAction,
388                               "CUT", DefaultEditorKit.cutAction,
389                        "shift LEFT", DefaultEditorKit.selectionBackwardAction,
390                     "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction,
391                       "shift RIGHT", DefaultEditorKit.selectionForwardAction,
392                    "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction,
393                         "ctrl LEFT", DefaultEditorKit.beginLineAction,
394                      "ctrl KP_LEFT", DefaultEditorKit.beginLineAction,
395                        "ctrl RIGHT", DefaultEditorKit.endLineAction,
396                     "ctrl KP_RIGHT", DefaultEditorKit.endLineAction,
397                   "ctrl shift LEFT", DefaultEditorKit.selectionBeginLineAction,
398                "ctrl shift KP_LEFT", DefaultEditorKit.selectionBeginLineAction,
399                  "ctrl shift RIGHT", DefaultEditorKit.selectionEndLineAction,
400               "ctrl shift KP_RIGHT", DefaultEditorKit.selectionEndLineAction,
401                            "ctrl A", DefaultEditorKit.selectAllAction,
402                              "HOME", DefaultEditorKit.beginLineAction,
403                               "END", DefaultEditorKit.endLineAction,
404                        "shift HOME", DefaultEditorKit.selectionBeginLineAction,
405                         "shift END", DefaultEditorKit.selectionEndLineAction,
406                        "BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
407                            "ctrl H", DefaultEditorKit.deletePrevCharAction,
408                            "DELETE", DefaultEditorKit.deleteNextCharAction,
409                             "RIGHT", DefaultEditorKit.forwardAction,
410                              "LEFT", DefaultEditorKit.backwardAction,
411                          "KP_RIGHT", DefaultEditorKit.forwardAction,
412                           "KP_LEFT", DefaultEditorKit.backwardAction,
413                             "ENTER", JTextField.notifyAction,
414                   "ctrl BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/,
415                    "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
416         });
417
418     Object JavaDoc multilineInputMap = new UIDefaults.LazyInputMap(new Object JavaDoc[] {
419                "ctrl C", DefaultEditorKit.copyAction,
420                "ctrl V", DefaultEditorKit.pasteAction,
421                "ctrl X", DefaultEditorKit.cutAction,
422                  "COPY", DefaultEditorKit.copyAction,
423                 "PASTE", DefaultEditorKit.pasteAction,
424                   "CUT", DefaultEditorKit.cutAction,
425                "shift LEFT", DefaultEditorKit.selectionBackwardAction,
426                     "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction,
427               "shift RIGHT", DefaultEditorKit.selectionForwardAction,
428            "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction,
429             "ctrl LEFT", DefaultEditorKit.previousWordAction,
430              "ctrl KP_LEFT", DefaultEditorKit.previousWordAction,
431                "ctrl RIGHT", DefaultEditorKit.nextWordAction,
432             "ctrl KP_RIGHT", DefaultEditorKit.nextWordAction,
433           "ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
434            "ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction,
435          "ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction,
436           "ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction,
437                "ctrl A", DefaultEditorKit.selectAllAction,
438                  "HOME", DefaultEditorKit.beginLineAction,
439                   "END", DefaultEditorKit.endLineAction,
440                "shift HOME", DefaultEditorKit.selectionBeginLineAction,
441                 "shift END", DefaultEditorKit.selectionEndLineAction,
442
443                    "UP", DefaultEditorKit.upAction,
444                 "KP_UP", DefaultEditorKit.upAction,
445                  "DOWN", DefaultEditorKit.downAction,
446               "KP_DOWN", DefaultEditorKit.downAction,
447               "PAGE_UP", DefaultEditorKit.pageUpAction,
448             "PAGE_DOWN", DefaultEditorKit.pageDownAction,
449             "shift PAGE_UP", "selection-page-up",
450               "shift PAGE_DOWN", "selection-page-down",
451            "ctrl shift PAGE_UP", "selection-page-left",
452          "ctrl shift PAGE_DOWN", "selection-page-right",
453              "shift UP", DefaultEditorKit.selectionUpAction,
454               "shift KP_UP", DefaultEditorKit.selectionUpAction,
455                "shift DOWN", DefaultEditorKit.selectionDownAction,
456             "shift KP_DOWN", DefaultEditorKit.selectionDownAction,
457                 "ENTER", DefaultEditorKit.insertBreakAction,
458                        "BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
459                            "ctrl H", DefaultEditorKit.deletePrevCharAction,
460                            "DELETE", DefaultEditorKit.deleteNextCharAction,
461                             "RIGHT", DefaultEditorKit.forwardAction,
462                              "LEFT", DefaultEditorKit.backwardAction,
463                          "KP_RIGHT", DefaultEditorKit.forwardAction,
464                           "KP_LEFT", DefaultEditorKit.backwardAction,
465                   "TAB", DefaultEditorKit.insertTabAction,
466           "ctrl BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/,
467             "ctrl HOME", DefaultEditorKit.beginAction,
468              "ctrl END", DefaultEditorKit.endAction,
469           "ctrl shift HOME", DefaultEditorKit.selectionBeginAction,
470            "ctrl shift END", DefaultEditorKit.selectionEndAction,
471                            "ctrl T", "next-link-action",
472                      "ctrl shift T", "previous-link-action",
473                        "ctrl SPACE", "activate-link-action",
474                    "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
475     });
476
477         Object JavaDoc scrollPaneBorder = new SwingLazyValue("javax.swing.plaf.metal.MetalBorders$ScrollPaneBorder");
478         Object JavaDoc buttonBorder =
479                 new SwingLazyValue("javax.swing.plaf.metal.MetalBorders",
480                       "getButtonBorder");
481   
482         Object JavaDoc toggleButtonBorder =
483         new SwingLazyValue("javax.swing.plaf.metal.MetalBorders",
484                       "getToggleButtonBorder");
485
486         Object JavaDoc titledBorderBorder =
487         new SwingLazyValue(
488               "javax.swing.plaf.BorderUIResource$LineBorderUIResource",
489               new Object JavaDoc[] {controlShadow});
490
491         Object JavaDoc desktopIconBorder =
492         new SwingLazyValue(
493               "javax.swing.plaf.metal.MetalBorders",
494               "getDesktopIconBorder");
495
496         Object JavaDoc menuBarBorder =
497         new SwingLazyValue(
498               "javax.swing.plaf.metal.MetalBorders$MenuBarBorder");
499
500         Object JavaDoc popupMenuBorder =
501         new SwingLazyValue(
502              "javax.swing.plaf.metal.MetalBorders$PopupMenuBorder");
503         Object JavaDoc menuItemBorder =
504         new SwingLazyValue(
505              "javax.swing.plaf.metal.MetalBorders$MenuItemBorder");
506
507     Object JavaDoc menuItemAcceleratorDelimiter = new String JavaDoc("-");
508         Object JavaDoc toolBarBorder = new SwingLazyValue("javax.swing.plaf.metal.MetalBorders$ToolBarBorder");
509
510     Object JavaDoc progressBarBorder = new SwingLazyValue(
511               "javax.swing.plaf.BorderUIResource$LineBorderUIResource",
512               new Object JavaDoc[] {controlDarkShadow, new Integer JavaDoc(1)});
513
514         Object JavaDoc toolTipBorder = new SwingLazyValue(
515               "javax.swing.plaf.BorderUIResource$LineBorderUIResource",
516               new Object JavaDoc[] {primaryControlDarkShadow});
517
518         Object JavaDoc toolTipBorderInactive = new SwingLazyValue(
519               "javax.swing.plaf.BorderUIResource$LineBorderUIResource",
520               new Object JavaDoc[] {controlDarkShadow});
521
522         Object JavaDoc focusCellHighlightBorder = new SwingLazyValue(
523               "javax.swing.plaf.BorderUIResource$LineBorderUIResource",
524               new Object JavaDoc[] {focusColor});
525
526         Object JavaDoc tabbedPaneTabAreaInsets = new InsetsUIResource(4, 2, 0, 6);
527
528         Object JavaDoc tabbedPaneTabInsets = new InsetsUIResource(0, 9, 1, 9);
529
530     final Object JavaDoc[] internalFrameIconArgs = new Object JavaDoc[1];
531     internalFrameIconArgs[0] = new Integer JavaDoc(16);
532
533     Object JavaDoc[] defaultCueList = new Object JavaDoc[] {
534         "OptionPane.errorSound",
535         "OptionPane.informationSound",
536         "OptionPane.questionSound",
537         "OptionPane.warningSound" };
538
539         MetalTheme JavaDoc theme = getCurrentTheme();
540         Object JavaDoc menuTextValue = new FontActiveValue(theme,
541                                                    MetalTheme.MENU_TEXT_FONT);
542         Object JavaDoc controlTextValue = new FontActiveValue(theme,
543                                MetalTheme.CONTROL_TEXT_FONT);
544         Object JavaDoc userTextValue = new FontActiveValue(theme,
545                                                    MetalTheme.USER_TEXT_FONT);
546         Object JavaDoc windowTitleValue = new FontActiveValue(theme,
547                                MetalTheme.WINDOW_TITLE_FONT);
548         Object JavaDoc subTextValue = new FontActiveValue(theme,
549                                                   MetalTheme.SUB_TEXT_FONT);
550         Object JavaDoc systemTextValue = new FontActiveValue(theme,
551                                                  MetalTheme.SYSTEM_TEXT_FONT);
552         //
553
// DEFAULTS TABLE
554
//
555

556         Object JavaDoc[] defaults = {
557         // *** Auditory Feedback
558
"AuditoryCues.defaultCueList", defaultCueList,
559         // this key defines which of the various cues to render
560
// This is disabled until sound bugs can be resolved.
561
"AuditoryCues.playList", null, // defaultCueList,
562

563             // Text (Note: many are inherited)
564
"TextField.border", textFieldBorder,
565         "TextField.font", userTextValue,
566
567             "PasswordField.border", textFieldBorder,
568             // passwordField.font should actually map to
569
// win.ansiFixed.font.height on windows.
570
"PasswordField.font", userTextValue,
571
572             // TextArea.font should actually map to win.ansiFixed.font.height
573
// on windows.
574
"TextArea.font", userTextValue,
575
576         "TextPane.background", table.get("window"),
577             "TextPane.font", userTextValue,
578
579         "EditorPane.background", table.get("window"),
580         "EditorPane.font", userTextValue,
581
582         "TextField.focusInputMap", fieldInputMap,
583         "PasswordField.focusInputMap", passwordInputMap,
584         "TextArea.focusInputMap", multilineInputMap,
585         "TextPane.focusInputMap", multilineInputMap,
586         "EditorPane.focusInputMap", multilineInputMap,
587
588             // FormattedTextFields
589
"FormattedTextField.border", textFieldBorder,
590             "FormattedTextField.font", userTextValue,
591             "FormattedTextField.focusInputMap",
592               new UIDefaults.LazyInputMap(new Object JavaDoc[] {
593                "ctrl C", DefaultEditorKit.copyAction,
594                "ctrl V", DefaultEditorKit.pasteAction,
595                "ctrl X", DefaultEditorKit.cutAction,
596                  "COPY", DefaultEditorKit.copyAction,
597                 "PASTE", DefaultEditorKit.pasteAction,
598                   "CUT", DefaultEditorKit.cutAction,
599                "shift LEFT", DefaultEditorKit.selectionBackwardAction,
600                     "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction,
601               "shift RIGHT", DefaultEditorKit.selectionForwardAction,
602            "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction,
603             "ctrl LEFT", DefaultEditorKit.previousWordAction,
604              "ctrl KP_LEFT", DefaultEditorKit.previousWordAction,
605                "ctrl RIGHT", DefaultEditorKit.nextWordAction,
606             "ctrl KP_RIGHT", DefaultEditorKit.nextWordAction,
607           "ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
608            "ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction,
609          "ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction,
610           "ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction,
611                "ctrl A", DefaultEditorKit.selectAllAction,
612                  "HOME", DefaultEditorKit.beginLineAction,
613                   "END", DefaultEditorKit.endLineAction,
614                "shift HOME", DefaultEditorKit.selectionBeginLineAction,
615                 "shift END", DefaultEditorKit.selectionEndLineAction,
616                        "BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
617                            "ctrl H", DefaultEditorKit.deletePrevCharAction,
618                            "DELETE", DefaultEditorKit.deleteNextCharAction,
619                             "RIGHT", DefaultEditorKit.forwardAction,
620                              "LEFT", DefaultEditorKit.backwardAction,
621                          "KP_RIGHT", DefaultEditorKit.forwardAction,
622                           "KP_LEFT", DefaultEditorKit.backwardAction,
623                 "ENTER", JTextField.notifyAction,
624           "ctrl BACK_SLASH", "unselect",
625                    "control shift O", "toggle-componentOrientation",
626                            "ESCAPE", "reset-field-edit",
627                                "UP", "increment",
628                             "KP_UP", "increment",
629                              "DOWN", "decrement",
630                           "KP_DOWN", "decrement",
631               }),
632             
633
634             // Buttons
635
"Button.defaultButtonFollowsFocus", Boolean.FALSE,
636             "Button.disabledText", inactiveControlTextColor,
637             "Button.select", controlShadow,
638             "Button.border", buttonBorder,
639             "Button.font", controlTextValue,
640             "Button.focus", focusColor,
641             "Button.focusInputMap", new UIDefaults.LazyInputMap(new Object JavaDoc[] {
642                           "SPACE", "pressed",
643                  "released SPACE", "released"
644               }),
645
646             "CheckBox.disabledText", inactiveControlTextColor,
647             "Checkbox.select", controlShadow,
648             "CheckBox.font", controlTextValue,
649             "CheckBox.focus", focusColor,
650             "CheckBox.icon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getCheckBoxIcon"),
651         "CheckBox.focusInputMap",
652            new UIDefaults.LazyInputMap(new Object JavaDoc[] {
653                     "SPACE", "pressed",
654                    "released SPACE", "released"
655          }),
656
657             "RadioButton.disabledText", inactiveControlTextColor,
658             "RadioButton.select", controlShadow,
659             "RadioButton.icon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getRadioButtonIcon"),
660             "RadioButton.font", controlTextValue,
661             "RadioButton.focus", focusColor,
662         "RadioButton.focusInputMap",
663            new UIDefaults.LazyInputMap(new Object JavaDoc[] {
664                           "SPACE", "pressed",
665                  "released SPACE", "released"
666           }),
667
668             "ToggleButton.select", controlShadow,
669             "ToggleButton.disabledText", inactiveControlTextColor,
670             "ToggleButton.focus", focusColor,
671             "ToggleButton.border", toggleButtonBorder,
672             "ToggleButton.font", controlTextValue,
673         "ToggleButton.focusInputMap",
674           new UIDefaults.LazyInputMap(new Object JavaDoc[] {
675                     "SPACE", "pressed",
676                    "released SPACE", "released"
677             }),
678
679
680             // File View
681
"FileView.directoryIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getTreeFolderIcon"),
682             "FileView.fileIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getTreeLeafIcon"),
683             "FileView.computerIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getTreeComputerIcon"),
684             "FileView.hardDriveIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getTreeHardDriveIcon"),
685             "FileView.floppyDriveIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getTreeFloppyDriveIcon"),
686
687             // File Chooser
688
"FileChooser.detailsViewIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getFileChooserDetailViewIcon"),
689             "FileChooser.homeFolderIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getFileChooserHomeFolderIcon"),
690             "FileChooser.listViewIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getFileChooserListViewIcon"),
691             "FileChooser.newFolderIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getFileChooserNewFolderIcon"),
692             "FileChooser.upFolderIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getFileChooserUpFolderIcon"),
693
694             "FileChooser.lookInLabelMnemonic", new Integer JavaDoc(KeyEvent.VK_I),
695             "FileChooser.fileNameLabelMnemonic", new Integer JavaDoc(KeyEvent.VK_N),
696             "FileChooser.filesOfTypeLabelMnemonic", new Integer JavaDoc(KeyEvent.VK_T),
697         "FileChooser.usesSingleFilePane", Boolean.TRUE,
698         "FileChooser.ancestorInputMap",
699            new UIDefaults.LazyInputMap(new Object JavaDoc[] {
700              "ESCAPE", "cancelSelection",
701              "F2", "editFileName",
702              "F5", "refresh",
703              "BACK_SPACE", "Go Up",
704              "ENTER", "approveSelection"
705          }),
706
707
708             // ToolTip
709
"ToolTip.font", systemTextValue,
710             "ToolTip.border", toolTipBorder,
711             "ToolTip.borderInactive", toolTipBorderInactive,
712             "ToolTip.backgroundInactive", control,
713             "ToolTip.foregroundInactive", controlDarkShadow,
714             "ToolTip.hideAccelerator", Boolean.FALSE,
715  
716             // Slider Defaults
717
"Slider.border", null,
718             "Slider.foreground", primaryControlShadow,
719             "Slider.focus", focusColor,
720         "Slider.focusInsets", zeroInsets,
721             "Slider.trackWidth", new Integer JavaDoc( 7 ),
722             "Slider.majorTickLength", new Integer JavaDoc( 6 ),
723             "Slider.horizontalThumbIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getHorizontalSliderThumbIcon"),
724             "Slider.verticalThumbIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getVerticalSliderThumbIcon"),
725         "Slider.focusInputMap",
726            new UIDefaults.LazyInputMap(new Object JavaDoc[] {
727                "RIGHT", "positiveUnitIncrement",
728             "KP_RIGHT", "positiveUnitIncrement",
729                 "DOWN", "negativeUnitIncrement",
730              "KP_DOWN", "negativeUnitIncrement",
731            "PAGE_DOWN", "negativeBlockIncrement",
732           "ctrl PAGE_DOWN", "negativeBlockIncrement",
733                 "LEFT", "negativeUnitIncrement",
734              "KP_LEFT", "negativeUnitIncrement",
735                   "UP", "positiveUnitIncrement",
736                "KP_UP", "positiveUnitIncrement",
737              "PAGE_UP", "positiveBlockIncrement",
738                 "ctrl PAGE_UP", "positiveBlockIncrement",
739                 "HOME", "minScroll",
740                  "END", "maxScroll"
741          }),
742
743             // Progress Bar
744
"ProgressBar.font", controlTextValue,
745             "ProgressBar.foreground", primaryControlShadow,
746         "ProgressBar.selectionBackground", primaryControlDarkShadow,
747         "ProgressBar.border", progressBarBorder,
748             "ProgressBar.cellSpacing", zero,
749             "ProgressBar.cellLength", new Integer JavaDoc(1),
750
751             // Combo Box
752
"ComboBox.background", control,
753             "ComboBox.foreground", controlTextColor,
754             "ComboBox.selectionBackground", primaryControlShadow,
755             "ComboBox.selectionForeground", controlTextColor,
756             "ComboBox.font", controlTextValue,
757         "ComboBox.ancestorInputMap", new UIDefaults.LazyInputMap(new Object JavaDoc[] {
758              "ESCAPE", "hidePopup",
759             "PAGE_UP", "pageUpPassThrough",
760           "PAGE_DOWN", "pageDownPassThrough",
761                "HOME", "homePassThrough",
762                 "END", "endPassThrough",
763                "DOWN", "selectNext",
764             "KP_DOWN", "selectNext",
765            "alt DOWN", "togglePopup",
766         "alt KP_DOWN", "togglePopup",
767              "alt UP", "togglePopup",
768           "alt KP_UP", "togglePopup",
769               "SPACE", "spacePopup",
770              "ENTER", "enterPressed",
771                  "UP", "selectPrevious",
772               "KP_UP", "selectPrevious"
773           }),
774
775             // Internal Frame Defaults
776
"InternalFrame.icon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getInternalFrameDefaultMenuIcon"),
777             "InternalFrame.border", new SwingLazyValue("javax.swing.plaf.metal.MetalBorders$InternalFrameBorder"),
778             "InternalFrame.optionDialogBorder", new SwingLazyValue("javax.swing.plaf.metal.MetalBorders$OptionDialogBorder"),
779             "InternalFrame.paletteBorder", new SwingLazyValue("javax.swing.plaf.metal.MetalBorders$PaletteBorder"),
780         "InternalFrame.paletteTitleHeight", new Integer JavaDoc(11),
781         "InternalFrame.paletteCloseIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory$PaletteCloseIcon"),
782             "InternalFrame.closeIcon",
783                   new SwingLazyValue(
784                      "javax.swing.plaf.metal.MetalIconFactory",
785                      "getInternalFrameCloseIcon",
786                      internalFrameIconArgs),
787             "InternalFrame.maximizeIcon",
788                   new SwingLazyValue(
789                      "javax.swing.plaf.metal.MetalIconFactory",
790                      "getInternalFrameMaximizeIcon",
791                      internalFrameIconArgs),
792             "InternalFrame.iconifyIcon",
793                   new SwingLazyValue(
794                      "javax.swing.plaf.metal.MetalIconFactory",
795                      "getInternalFrameMinimizeIcon",
796                      internalFrameIconArgs),
797             "InternalFrame.minimizeIcon",
798                   new SwingLazyValue(
799                      "javax.swing.plaf.metal.MetalIconFactory",
800                      "getInternalFrameAltMaximizeIcon",
801                      internalFrameIconArgs),
802             "InternalFrame.titleFont", windowTitleValue,
803         "InternalFrame.windowBindings", null,
804         // Internal Frame Auditory Cue Mappings
805
"InternalFrame.closeSound", "sounds/FrameClose.wav",
806             "InternalFrame.maximizeSound", "sounds/FrameMaximize.wav",
807             "InternalFrame.minimizeSound", "sounds/FrameMinimize.wav",
808             "InternalFrame.restoreDownSound", "sounds/FrameRestoreDown.wav",
809             "InternalFrame.restoreUpSound", "sounds/FrameRestoreUp.wav",
810
811             // Desktop Icon
812
"DesktopIcon.border", desktopIconBorder,
813             "DesktopIcon.font", controlTextValue,
814             "DesktopIcon.foreground", controlTextColor,
815             "DesktopIcon.background", control,
816             "DesktopIcon.width", new Integer JavaDoc(160),
817
818         "Desktop.ancestorInputMap",
819            new UIDefaults.LazyInputMap(new Object JavaDoc[] {
820          "ctrl F5", "restore",
821          "ctrl F4", "close",
822          "ctrl F7", "move",
823          "ctrl F8", "resize",
824            "RIGHT", "right",
825         "KP_RIGHT", "right",
826              "shift RIGHT", "shrinkRight",
827           "shift KP_RIGHT", "shrinkRight",
828             "LEFT", "left",
829          "KP_LEFT", "left",
830               "shift LEFT", "shrinkLeft",
831            "shift KP_LEFT", "shrinkLeft",
832               "UP", "up",
833            "KP_UP", "up",
834                 "shift UP", "shrinkUp",
835              "shift KP_UP", "shrinkUp",
836             "DOWN", "down",
837          "KP_DOWN", "down",
838               "shift DOWN", "shrinkDown",
839            "shift KP_DOWN", "shrinkDown",
840           "ESCAPE", "escape",
841          "ctrl F9", "minimize",
842         "ctrl F10", "maximize",
843          "ctrl F6", "selectNextFrame",
844         "ctrl TAB", "selectNextFrame",
845          "ctrl alt F6", "selectNextFrame",
846        "shift ctrl alt F6", "selectPreviousFrame",
847                 "ctrl F12", "navigateNext",
848            "shift ctrl F12", "navigatePrevious"
849           }),
850
851             // Titled Border
852
"TitledBorder.font", controlTextValue,
853             "TitledBorder.titleColor", systemTextColor,
854             "TitledBorder.border", titledBorderBorder,
855
856             // Label
857
"Label.font", controlTextValue,
858             "Label.foreground", systemTextColor,
859             "Label.disabledForeground", getInactiveSystemTextColor(),
860
861             // List
862
"List.font", controlTextValue,
863             "List.focusCellHighlightBorder", focusCellHighlightBorder,
864         "List.focusInputMap",
865            new UIDefaults.LazyInputMap(new Object JavaDoc[] {
866                            "ctrl C", "copy",
867                            "ctrl V", "paste",
868                            "ctrl X", "cut",
869                              "COPY", "copy",
870                             "PASTE", "paste",
871                               "CUT", "cut",
872                        "UP", "selectPreviousRow",
873                     "KP_UP", "selectPreviousRow",
874                  "shift UP", "selectPreviousRowExtendSelection",
875               "shift KP_UP", "selectPreviousRowExtendSelection",
876                     "ctrl shift UP", "selectPreviousRowExtendSelection",
877                  "ctrl shift KP_UP", "selectPreviousRowExtendSelection",
878                           "ctrl UP", "selectPreviousRowChangeLead",
879                        "ctrl KP_UP", "selectPreviousRowChangeLead",
880                      "DOWN", "selectNextRow",
881                   "KP_DOWN", "selectNextRow",
882                "shift DOWN", "selectNextRowExtendSelection",
883             "shift KP_DOWN", "selectNextRowExtendSelection",
884                   "ctrl shift DOWN", "selectNextRowExtendSelection",
885                "ctrl shift KP_DOWN", "selectNextRowExtendSelection",
886                         "ctrl DOWN", "selectNextRowChangeLead",
887                      "ctrl KP_DOWN", "selectNextRowChangeLead",
888                      "LEFT", "selectPreviousColumn",
889                   "KP_LEFT", "selectPreviousColumn",
890                "shift LEFT", "selectPreviousColumnExtendSelection",
891             "shift KP_LEFT", "selectPreviousColumnExtendSelection",
892                   "ctrl shift LEFT", "selectPreviousColumnExtendSelection",
893                "ctrl shift KP_LEFT", "selectPreviousColumnExtendSelection",
894                         "ctrl LEFT", "selectPreviousColumnChangeLead",
895                      "ctrl KP_LEFT", "selectPreviousColumnChangeLead",
896                     "RIGHT", "selectNextColumn",
897                  "KP_RIGHT", "selectNextColumn",
898               "shift RIGHT", "selectNextColumnExtendSelection",
899            "shift KP_RIGHT", "selectNextColumnExtendSelection",
900                  "ctrl shift RIGHT", "selectNextColumnExtendSelection",
901               "ctrl shift KP_RIGHT", "selectNextColumnExtendSelection",
902                        "ctrl RIGHT", "selectNextColumnChangeLead",
903                     "ctrl KP_RIGHT", "selectNextColumnChangeLead",
904                      "HOME", "selectFirstRow",
905                "shift HOME", "selectFirstRowExtendSelection",
906                   "ctrl shift HOME", "selectFirstRowExtendSelection",
907                         "ctrl HOME", "selectFirstRowChangeLead",
908                       "END", "selectLastRow",
909                 "shift END", "selectLastRowExtendSelection",
910                    "ctrl shift END", "selectLastRowExtendSelection",
911                          "ctrl END", "selectLastRowChangeLead",
912                   "PAGE_UP", "scrollUp",
913             "shift PAGE_UP", "scrollUpExtendSelection",
914                "ctrl shift PAGE_UP", "scrollUpExtendSelection",
915                      "ctrl PAGE_UP", "scrollUpChangeLead",
916                 "PAGE_DOWN", "scrollDown",
917           "shift PAGE_DOWN", "scrollDownExtendSelection",
918              "ctrl shift PAGE_DOWN", "scrollDownExtendSelection",
919                    "ctrl PAGE_DOWN", "scrollDownChangeLead",
920                    "ctrl A", "selectAll",
921                "ctrl SLASH", "selectAll",
922           "ctrl BACK_SLASH", "clearSelection",
923                             "SPACE", "addToSelection",
924                        "ctrl SPACE", "toggleAndAnchor",
925                       "shift SPACE", "extendTo",
926                  "ctrl shift SPACE", "moveSelectionTo"
927          }),
928
929             // ScrollBar
930
"ScrollBar.background", control,
931             "ScrollBar.highlight", controlHighlight,
932             "ScrollBar.shadow", controlShadow,
933             "ScrollBar.darkShadow", controlDarkShadow,
934             "ScrollBar.thumb", primaryControlShadow,
935             "ScrollBar.thumbShadow", primaryControlDarkShadow,
936             "ScrollBar.thumbHighlight", primaryControl,
937             "ScrollBar.width", new Integer JavaDoc( 17 ),
938         "ScrollBar.allowsAbsolutePositioning", Boolean.TRUE,
939         "ScrollBar.ancestorInputMap",
940            new UIDefaults.LazyInputMap(new Object JavaDoc[] {
941                "RIGHT", "positiveUnitIncrement",
942             "KP_RIGHT", "positiveUnitIncrement",
943                 "DOWN", "positiveUnitIncrement",
944              "KP_DOWN", "positiveUnitIncrement",
945            "PAGE_DOWN", "positiveBlockIncrement",
946                 "LEFT", "negativeUnitIncrement",
947              "KP_LEFT", "negativeUnitIncrement",
948                   "UP", "negativeUnitIncrement",
949                "KP_UP", "negativeUnitIncrement",
950              "PAGE_UP", "negativeBlockIncrement",
951                 "HOME", "minScroll",
952                  "END", "maxScroll"
953          }),
954
955         // ScrollPane
956
"ScrollPane.border", scrollPaneBorder,
957         "ScrollPane.ancestorInputMap",
958            new UIDefaults.LazyInputMap(new Object JavaDoc[] {
959                    "RIGHT", "unitScrollRight",
960                 "KP_RIGHT", "unitScrollRight",
961                     "DOWN", "unitScrollDown",
962                  "KP_DOWN", "unitScrollDown",
963                     "LEFT", "unitScrollLeft",
964                  "KP_LEFT", "unitScrollLeft",
965                       "UP", "unitScrollUp",
966                    "KP_UP", "unitScrollUp",
967                  "PAGE_UP", "scrollUp",
968                "PAGE_DOWN", "scrollDown",
969             "ctrl PAGE_UP", "scrollLeft",
970           "ctrl PAGE_DOWN", "scrollRight",
971                "ctrl HOME", "scrollHome",
972                 "ctrl END", "scrollEnd"
973          }),
974
975             // Tabbed Pane
976
"TabbedPane.font", controlTextValue,
977             "TabbedPane.tabAreaBackground", control,
978             "TabbedPane.background", controlShadow,
979             "TabbedPane.light", control,
980             "TabbedPane.focus", primaryControlDarkShadow,
981             "TabbedPane.selected", control,
982             "TabbedPane.selectHighlight", controlHighlight,
983             "TabbedPane.tabAreaInsets", tabbedPaneTabAreaInsets,
984             "TabbedPane.tabInsets", tabbedPaneTabInsets,
985         "TabbedPane.focusInputMap",
986           new UIDefaults.LazyInputMap(new Object JavaDoc[] {
987                  "RIGHT", "navigateRight",
988                   "KP_RIGHT", "navigateRight",
989                       "LEFT", "navigateLeft",
990                    "KP_LEFT", "navigateLeft",
991                         "UP", "navigateUp",
992                      "KP_UP", "navigateUp",
993                       "DOWN", "navigateDown",
994                    "KP_DOWN", "navigateDown",
995                  "ctrl DOWN", "requestFocusForVisibleComponent",
996               "ctrl KP_DOWN", "requestFocusForVisibleComponent",
997         }),
998         "TabbedPane.ancestorInputMap",
999            new UIDefaults.LazyInputMap(new Object JavaDoc[] {
1000           "ctrl PAGE_DOWN", "navigatePageDown",
1001                 "ctrl PAGE_UP", "navigatePageUp",
1002                      "ctrl UP", "requestFocus",
1003                   "ctrl KP_UP", "requestFocus",
1004         }),
1005            
1006            // Table
1007
"Table.font", userTextValue,
1008            "Table.focusCellHighlightBorder", focusCellHighlightBorder,
1009            "Table.scrollPaneBorder", scrollPaneBorder,
1010            "Table.gridColor", controlShadow, // grid line color
1011
"Table.ancestorInputMap",
1012           new UIDefaults.LazyInputMap(new Object JavaDoc[] {
1013                               "ctrl C", "copy",
1014                               "ctrl V", "paste",
1015                               "ctrl X", "cut",
1016                                 "COPY", "copy",
1017                                "PASTE", "paste",
1018                                  "CUT", "cut",
1019                        "RIGHT", "selectNextColumn",
1020                     "KP_RIGHT", "selectNextColumn",
1021                          "shift RIGHT", "selectNextColumnExtendSelection",
1022                       "shift KP_RIGHT", "selectNextColumnExtendSelection",
1023                     "ctrl shift RIGHT", "selectNextColumnExtendSelection",
1024                  "ctrl shift KP_RIGHT", "selectNextColumnExtendSelection",
1025                           "ctrl RIGHT", "selectNextColumnChangeLead",
1026                        "ctrl KP_RIGHT", "selectNextColumnChangeLead",
1027                         "LEFT", "selectPreviousColumn",
1028                      "KP_LEFT", "selectPreviousColumn",
1029                           "shift LEFT", "selectPreviousColumnExtendSelection",
1030                        "shift KP_LEFT", "selectPreviousColumnExtendSelection",
1031                      "ctrl shift LEFT", "selectPreviousColumnExtendSelection",
1032                   "ctrl shift KP_LEFT", "selectPreviousColumnExtendSelection",
1033                            "ctrl LEFT", "selectPreviousColumnChangeLead",
1034                         "ctrl KP_LEFT", "selectPreviousColumnChangeLead",
1035                         "DOWN", "selectNextRow",
1036                      "KP_DOWN", "selectNextRow",
1037                           "shift DOWN", "selectNextRowExtendSelection",
1038                        "shift KP_DOWN", "selectNextRowExtendSelection",
1039                      "ctrl shift DOWN", "selectNextRowExtendSelection",
1040                   "ctrl shift KP_DOWN", "selectNextRowExtendSelection",
1041                            "ctrl DOWN", "selectNextRowChangeLead",
1042                         "ctrl KP_DOWN", "selectNextRowChangeLead",
1043                           "UP", "selectPreviousRow",
1044                        "KP_UP", "selectPreviousRow",
1045                             "shift UP", "selectPreviousRowExtendSelection",
1046                          "shift KP_UP", "selectPreviousRowExtendSelection",
1047                        "ctrl shift UP", "selectPreviousRowExtendSelection",
1048                     "ctrl shift KP_UP", "selectPreviousRowExtendSelection",
1049                              "ctrl UP", "selectPreviousRowChangeLead",
1050                           "ctrl KP_UP", "selectPreviousRowChangeLead",
1051                                 "HOME", "selectFirstColumn",
1052                           "shift HOME", "selectFirstColumnExtendSelection",
1053                      "ctrl shift HOME", "selectFirstRowExtendSelection",
1054                            "ctrl HOME", "selectFirstRow",
1055                                  "END", "selectLastColumn",
1056                            "shift END", "selectLastColumnExtendSelection",
1057                       "ctrl shift END", "selectLastRowExtendSelection",
1058                             "ctrl END", "selectLastRow",
1059                      "PAGE_UP", "scrollUpChangeSelection",
1060                        "shift PAGE_UP", "scrollUpExtendSelection",
1061                   "ctrl shift PAGE_UP", "scrollLeftExtendSelection",
1062                         "ctrl PAGE_UP", "scrollLeftChangeSelection",
1063                    "PAGE_DOWN", "scrollDownChangeSelection",
1064              "shift PAGE_DOWN", "scrollDownExtendSelection",
1065                 "ctrl shift PAGE_DOWN", "scrollRightExtendSelection",
1066               "ctrl PAGE_DOWN", "scrollRightChangeSelection",
1067                          "TAB", "selectNextColumnCell",
1068                    "shift TAB", "selectPreviousColumnCell",
1069                        "ENTER", "selectNextRowCell",
1070                  "shift ENTER", "selectPreviousRowCell",
1071                       "ctrl A", "selectAll",
1072                           "ctrl SLASH", "selectAll",
1073                      "ctrl BACK_SLASH", "clearSelection",
1074                       "ESCAPE", "cancel",
1075                           "F2", "startEditing",
1076                                "SPACE", "addToSelection",
1077                           "ctrl SPACE", "toggleAndAnchor",
1078                          "shift SPACE", "extendTo",
1079                     "ctrl shift SPACE", "moveSelectionTo"
1080         }),
1081
1082        "TableHeader.font", userTextValue,
1083        "TableHeader.cellBorder", new SwingLazyValue(
1084                      "javax.swing.plaf.metal.MetalBorders$TableHeaderBorder"),
1085
1086            // MenuBar
1087
"MenuBar.border", menuBarBorder,
1088            "MenuBar.font", menuTextValue,
1089        "MenuBar.windowBindings", new Object JavaDoc[] {
1090        "F10", "takeFocus" },
1091
1092            // Menu
1093
"Menu.border", menuItemBorder,
1094            "Menu.borderPainted", Boolean.TRUE,
1095        "Menu.menuPopupOffsetX", zero,
1096        "Menu.menuPopupOffsetY", zero,
1097        "Menu.submenuPopupOffsetX", new Integer JavaDoc(-4),
1098        "Menu.submenuPopupOffsetY", new Integer JavaDoc(-3),
1099            "Menu.font", menuTextValue,
1100            "Menu.selectionForeground", menuSelectedForeground,
1101            "Menu.selectionBackground", menuSelectedBackground,
1102            "Menu.disabledForeground", menuDisabledForeground,
1103            "Menu.acceleratorFont", subTextValue,
1104            "Menu.acceleratorForeground", acceleratorForeground,
1105            "Menu.acceleratorSelectionForeground", acceleratorSelectedForeground,
1106            "Menu.checkIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getMenuItemCheckIcon"),
1107            "Menu.arrowIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getMenuArrowIcon"),
1108
1109            // Menu Item
1110
"MenuItem.border", menuItemBorder,
1111            "MenuItem.borderPainted", Boolean.TRUE,
1112            "MenuItem.font", menuTextValue,
1113            "MenuItem.selectionForeground", menuSelectedForeground,
1114            "MenuItem.selectionBackground", menuSelectedBackground,
1115            "MenuItem.disabledForeground", menuDisabledForeground,
1116            "MenuItem.acceleratorFont", subTextValue,
1117            "MenuItem.acceleratorForeground", acceleratorForeground,
1118            "MenuItem.acceleratorSelectionForeground", acceleratorSelectedForeground,
1119        "MenuItem.acceleratorDelimiter", menuItemAcceleratorDelimiter,
1120            "MenuItem.checkIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getMenuItemCheckIcon"),
1121            "MenuItem.arrowIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getMenuItemArrowIcon"),
1122             // Menu Item Auditory Cue Mapping
1123
"MenuItem.commandSound", "sounds/MenuItemCommand.wav",
1124
1125        // OptionPane.
1126
"OptionPane.windowBindings", new Object JavaDoc[] {
1127        "ESCAPE", "close" },
1128        // Option Pane Auditory Cue Mappings
1129
"OptionPane.informationSound", "sounds/OptionPaneInformation.wav",
1130            "OptionPane.warningSound", "sounds/OptionPaneWarning.wav",
1131            "OptionPane.errorSound", "sounds/OptionPaneError.wav",
1132            "OptionPane.questionSound", "sounds/OptionPaneQuestion.wav",
1133
1134            // Option Pane Special Dialog Colors, used when MetalRootPaneUI
1135
// is providing window manipulation widgets.
1136
"OptionPane.errorDialog.border.background",
1137                        new ColorUIResource(153, 51, 51),
1138            "OptionPane.errorDialog.titlePane.foreground",
1139                        new ColorUIResource(51, 0, 0),
1140            "OptionPane.errorDialog.titlePane.background",
1141                        new ColorUIResource(255, 153, 153),
1142            "OptionPane.errorDialog.titlePane.shadow",
1143                        new ColorUIResource(204, 102, 102),
1144            "OptionPane.questionDialog.border.background",
1145                        new ColorUIResource(51, 102, 51),
1146            "OptionPane.questionDialog.titlePane.foreground",
1147                        new ColorUIResource(0, 51, 0),
1148            "OptionPane.questionDialog.titlePane.background",
1149                        new ColorUIResource(153, 204, 153),
1150            "OptionPane.questionDialog.titlePane.shadow",
1151                        new ColorUIResource(102, 153, 102),
1152            "OptionPane.warningDialog.border.background",
1153                        new ColorUIResource(153, 102, 51),
1154            "OptionPane.warningDialog.titlePane.foreground",
1155                        new ColorUIResource(102, 51, 0),
1156            "OptionPane.warningDialog.titlePane.background",
1157                        new ColorUIResource(255, 204, 153),
1158            "OptionPane.warningDialog.titlePane.shadow",
1159                        new ColorUIResource(204, 153, 102),
1160            // OptionPane fonts are defined below
1161

1162            // Separator
1163
"Separator.background", getSeparatorBackground(),
1164            "Separator.foreground", getSeparatorForeground(),
1165
1166            // Popup Menu
1167
"PopupMenu.border", popupMenuBorder,
1168             // Popup Menu Auditory Cue Mappings
1169
"PopupMenu.popupSound", "sounds/PopupMenuPopup.wav",
1170            "PopupMenu.font", menuTextValue,
1171
1172            // CB & RB Menu Item
1173
"CheckBoxMenuItem.border", menuItemBorder,
1174            "CheckBoxMenuItem.borderPainted", Boolean.TRUE,
1175            "CheckBoxMenuItem.font", menuTextValue,
1176            "CheckBoxMenuItem.selectionForeground", menuSelectedForeground,
1177            "CheckBoxMenuItem.selectionBackground", menuSelectedBackground,
1178            "CheckBoxMenuItem.disabledForeground", menuDisabledForeground,
1179            "CheckBoxMenuItem.acceleratorFont", subTextValue,
1180            "CheckBoxMenuItem.acceleratorForeground", acceleratorForeground,
1181            "CheckBoxMenuItem.acceleratorSelectionForeground", acceleratorSelectedForeground,
1182            "CheckBoxMenuItem.checkIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getCheckBoxMenuItemIcon"),
1183            "CheckBoxMenuItem.arrowIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getMenuItemArrowIcon"),
1184        "CheckBoxMenuItem.commandSound", "sounds/MenuItemCommand.wav",
1185
1186            "RadioButtonMenuItem.border", menuItemBorder,
1187            "RadioButtonMenuItem.borderPainted", Boolean.TRUE,
1188            "RadioButtonMenuItem.font", menuTextValue,
1189            "RadioButtonMenuItem.selectionForeground", menuSelectedForeground,
1190            "RadioButtonMenuItem.selectionBackground", menuSelectedBackground,
1191            "RadioButtonMenuItem.disabledForeground", menuDisabledForeground,
1192            "RadioButtonMenuItem.acceleratorFont", subTextValue,
1193            "RadioButtonMenuItem.acceleratorForeground", acceleratorForeground,
1194            "RadioButtonMenuItem.acceleratorSelectionForeground", acceleratorSelectedForeground,
1195            "RadioButtonMenuItem.checkIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getRadioButtonMenuItemIcon"),
1196            "RadioButtonMenuItem.arrowIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getMenuItemArrowIcon"),
1197        "RadioButtonMenuItem.commandSound", "sounds/MenuItemCommand.wav",
1198
1199            "Spinner.ancestorInputMap",
1200           new UIDefaults.LazyInputMap(new Object JavaDoc[] {
1201                               "UP", "increment",
1202                            "KP_UP", "increment",
1203                             "DOWN", "decrement",
1204                          "KP_DOWN", "decrement",
1205               }),
1206        "Spinner.arrowButtonInsets", zeroInsets,
1207        "Spinner.border", textFieldBorder,
1208        "Spinner.arrowButtonBorder", buttonBorder,
1209            "Spinner.font", controlTextValue,
1210
1211        // SplitPane
1212

1213        "SplitPane.dividerSize", new Integer JavaDoc(10),
1214        "SplitPane.ancestorInputMap",
1215           new UIDefaults.LazyInputMap(new Object JavaDoc[] {
1216                "UP", "negativeIncrement",
1217              "DOWN", "positiveIncrement",
1218              "LEFT", "negativeIncrement",
1219             "RIGHT", "positiveIncrement",
1220             "KP_UP", "negativeIncrement",
1221           "KP_DOWN", "positiveIncrement",
1222           "KP_LEFT", "negativeIncrement",
1223          "KP_RIGHT", "positiveIncrement",
1224              "HOME", "selectMin",
1225               "END", "selectMax",
1226                "F8", "startResize",
1227                "F6", "toggleFocus",
1228          "ctrl TAB", "focusOutForward",
1229        "ctrl shift TAB", "focusOutBackward"
1230         }),
1231            "SplitPane.centerOneTouchButtons", Boolean.FALSE,
1232            "SplitPane.dividerFocusColor", primaryControl,
1233
1234            // Tree
1235
// Tree.font was mapped to system font pre 1.4.1
1236
"Tree.font", userTextValue,
1237            "Tree.textBackground", getWindowBackground(),
1238            "Tree.selectionBorderColor", focusColor,
1239            "Tree.openIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getTreeFolderIcon"),
1240            "Tree.closedIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getTreeFolderIcon"),
1241            "Tree.leafIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getTreeLeafIcon"),
1242            "Tree.expandedIcon", new SwingLazyValue(
1243                     "javax.swing.plaf.metal.MetalIconFactory",
1244                     "getTreeControlIcon",
1245                     new Object JavaDoc[] {Boolean.valueOf(MetalIconFactory.DARK)}),
1246            "Tree.collapsedIcon", new SwingLazyValue(
1247                     "javax.swing.plaf.metal.MetalIconFactory",
1248                     "getTreeControlIcon",
1249                     new Object JavaDoc[] {Boolean.valueOf( MetalIconFactory.LIGHT )}),
1250
1251            "Tree.line", primaryControl, // horiz lines
1252
"Tree.hash", primaryControl, // legs
1253
"Tree.rowHeight", zero,
1254        "Tree.focusInputMap",
1255           new UIDefaults.LazyInputMap(new Object JavaDoc[] {
1256                                    "ADD", "expand",
1257                               "SUBTRACT", "collapse",
1258                                 "ctrl C", "copy",
1259                                 "ctrl V", "paste",
1260                                 "ctrl X", "cut",
1261                                   "COPY", "copy",
1262                                  "PASTE", "paste",
1263                                    "CUT", "cut",
1264                             "UP", "selectPrevious",
1265                          "KP_UP", "selectPrevious",
1266                       "shift UP", "selectPreviousExtendSelection",
1267                    "shift KP_UP", "selectPreviousExtendSelection",
1268                          "ctrl shift UP", "selectPreviousExtendSelection",
1269                       "ctrl shift KP_UP", "selectPreviousExtendSelection",
1270                                "ctrl UP", "selectPreviousChangeLead",
1271                             "ctrl KP_UP", "selectPreviousChangeLead",
1272                           "DOWN", "selectNext",
1273                        "KP_DOWN", "selectNext",
1274                     "shift DOWN", "selectNextExtendSelection",
1275                  "shift KP_DOWN", "selectNextExtendSelection",
1276                        "ctrl shift DOWN", "selectNextExtendSelection",
1277                     "ctrl shift KP_DOWN", "selectNextExtendSelection",
1278                              "ctrl DOWN", "selectNextChangeLead",
1279                           "ctrl KP_DOWN", "selectNextChangeLead",
1280                          "RIGHT", "selectChild",
1281                       "KP_RIGHT", "selectChild",
1282                           "LEFT", "selectParent",
1283                        "KP_LEFT", "selectParent",
1284                        "PAGE_UP", "scrollUpChangeSelection",
1285                  "shift PAGE_UP", "scrollUpExtendSelection",
1286                     "ctrl shift PAGE_UP", "scrollUpExtendSelection",
1287                           "ctrl PAGE_UP", "scrollUpChangeLead",
1288                      "PAGE_DOWN", "scrollDownChangeSelection",
1289                "shift PAGE_DOWN", "scrollDownExtendSelection",
1290                   "ctrl shift PAGE_DOWN", "scrollDownExtendSelection",
1291                         "ctrl PAGE_DOWN", "scrollDownChangeLead",
1292                           "HOME", "selectFirst",
1293                     "shift HOME", "selectFirstExtendSelection",
1294                        "ctrl shift HOME", "selectFirstExtendSelection",
1295                              "ctrl HOME", "selectFirstChangeLead",
1296                            "END", "selectLast",
1297                      "shift END", "selectLastExtendSelection",
1298                         "ctrl shift END", "selectLastExtendSelection",
1299                               "ctrl END", "selectLastChangeLead",
1300                             "F2", "startEditing",
1301                         "ctrl A", "selectAll",
1302                     "ctrl SLASH", "selectAll",
1303                "ctrl BACK_SLASH", "clearSelection",
1304                      "ctrl LEFT", "scrollLeft",
1305                   "ctrl KP_LEFT", "scrollLeft",
1306                     "ctrl RIGHT", "scrollRight",
1307                  "ctrl KP_RIGHT", "scrollRight",
1308                                  "SPACE", "addToSelection",
1309                             "ctrl SPACE", "toggleAndAnchor",
1310                            "shift SPACE", "extendTo",
1311                       "ctrl shift SPACE", "moveSelectionTo"
1312         }),
1313        "Tree.ancestorInputMap",
1314           new UIDefaults.LazyInputMap(new Object JavaDoc[] {
1315             "ESCAPE", "cancel"
1316         }),
1317
1318            // ToolBar
1319
"ToolBar.border", toolBarBorder,
1320            "ToolBar.background", menuBackground,
1321            "ToolBar.foreground", getMenuForeground(),
1322            "ToolBar.font", menuTextValue,
1323            "ToolBar.dockingBackground", menuBackground,
1324            "ToolBar.floatingBackground", menuBackground,
1325            "ToolBar.dockingForeground", primaryControlDarkShadow,
1326            "ToolBar.floatingForeground", primaryControl,
1327            "ToolBar.rolloverBorder", new MetalLazyValue(
1328                         "javax.swing.plaf.metal.MetalBorders",
1329                         "getToolBarRolloverBorder"),
1330            "ToolBar.nonrolloverBorder", new MetalLazyValue(
1331                         "javax.swing.plaf.metal.MetalBorders",
1332                         "getToolBarNonrolloverBorder"),
1333        "ToolBar.ancestorInputMap",
1334           new UIDefaults.LazyInputMap(new Object JavaDoc[] {
1335                "UP", "navigateUp",
1336             "KP_UP", "navigateUp",
1337              "DOWN", "navigateDown",
1338           "KP_DOWN", "navigateDown",
1339              "LEFT", "navigateLeft",
1340           "KP_LEFT", "navigateLeft",
1341             "RIGHT", "navigateRight",
1342          "KP_RIGHT", "navigateRight"
1343         }),
1344
1345            // RootPane
1346
"RootPane.frameBorder", new MetalLazyValue(
1347                      "javax.swing.plaf.metal.MetalBorders$FrameBorder"),
1348            "RootPane.plainDialogBorder", dialogBorder,
1349            "RootPane.informationDialogBorder", dialogBorder,
1350            "RootPane.errorDialogBorder", new MetalLazyValue(
1351                      "javax.swing.plaf.metal.MetalBorders$ErrorDialogBorder"),
1352            "RootPane.colorChooserDialogBorder", questionDialogBorder,
1353            "RootPane.fileChooserDialogBorder", questionDialogBorder,
1354            "RootPane.questionDialogBorder", questionDialogBorder,
1355            "RootPane.warningDialogBorder", new MetalLazyValue(
1356                    "javax.swing.plaf.metal.MetalBorders$WarningDialogBorder"),
1357        // These bindings are only enabled when there is a default
1358
// button set on the rootpane.
1359
"RootPane.defaultButtonWindowKeyBindings", new Object JavaDoc[] {
1360                     "ENTER", "press",
1361            "released ENTER", "release",
1362                "ctrl ENTER", "press",
1363           "ctrl released ENTER", "release"
1364          },
1365        };
1366
1367        table.putDefaults(defaults);
1368
1369        if (isWindows() && useSystemFonts() && theme.isSystemTheme()) {
1370            Toolkit kit = Toolkit.getDefaultToolkit();
1371            Object JavaDoc messageFont = new MetalFontDesktopProperty JavaDoc(
1372                              "win.messagebox.font.height", kit, MetalTheme.
1373                              CONTROL_TEXT_FONT);
1374
1375            defaults = new Object JavaDoc[] {
1376                "OptionPane.messageFont", messageFont,
1377                "OptionPane.buttonFont", messageFont,
1378            };
1379            table.putDefaults(defaults);
1380        }
1381    }
1382
1383    protected void createDefaultTheme() {
1384        getCurrentTheme();
1385    }
1386
1387    public UIDefaults getDefaults() {
1388        // PENDING: move this to initialize when API changes are allowed
1389
METAL_LOOK_AND_FEEL_INITED = true;
1390
1391        createDefaultTheme();
1392        UIDefaults table = super.getDefaults();
1393        currentTheme.addCustomEntriesToTable(table);
1394        currentTheme.install();
1395        return table;
1396    }
1397
1398    /**
1399     * <p>
1400     * Invoked when the user attempts an invalid operation,
1401     * such as pasting into an uneditable <code>JTextField</code>
1402     * that has focus.
1403     * </p>
1404     * <p>
1405     * If the user has enabled visual error indication on
1406     * the desktop, this method will flash the caption bar
1407     * of the active window. The user can also set the
1408     * property awt.visualbell=true to achieve the same
1409     * results.
1410     * </p>
1411     *
1412     * @param component Component the error occured in, may be
1413     * null indicating the error condition is
1414     * not directly associated with a
1415     * <code>Component</code>.
1416     *
1417     * @see javax.swing.LookAndFeel#provideErrorFeedback
1418     */

1419    public void provideErrorFeedback(Component JavaDoc component) {
1420    super.provideErrorFeedback(component);
1421    }
1422
1423    /**
1424     * Set the theme to be used by <code>MetalLookAndFeel</code>.
1425     * This may not be null.
1426     * <br>
1427     * After setting the theme, you need to re-install the
1428     * <code>MetalLookAndFeel</code>, as well as update the UI
1429     * of any previously created widgets. Otherwise the results are undefined.
1430     * These lines of code show you how to accomplish this:
1431     * <pre>
1432     * // turn off bold fonts
1433     * MetalLookAndFeel.setCurrentTheme(theme);
1434     *
1435     * // re-install the Metal Look and Feel
1436     * UIManager.setLookAndFeel(new MetalLookAndFeel());
1437     *
1438     * // only needed to update existing widgets
1439     * SwingUtilities.updateComponentTreeUI(rootComponent);
1440     * </pre>
1441     *
1442     * @param theme the theme to be used, non-null
1443     * @throws NullPointerException if given a null parameter
1444     * @see #getCurrentTheme
1445     */

1446    public static void setCurrentTheme(MetalTheme JavaDoc theme) {
1447        // NOTE: because you need to recreate the look and feel after
1448
// this step, we don't bother blowing away any potential windows
1449
// values.
1450
if (theme == null) {
1451            throw new NullPointerException JavaDoc("Can't have null theme");
1452        }
1453        currentTheme = theme;
1454    cachedAppContext = AppContext.getAppContext();
1455    cachedAppContext.put( "currentMetalTheme", theme );
1456    }
1457
1458    /**
1459     * Return the theme currently being used by <code>MetalLookAndFeel</code>.
1460     * This will always be non-null, as it will set the current theme if one
1461     * hasn't been set already.
1462     *
1463     * @return the current theme
1464     * @see #setCurrentTheme
1465     * @since 1.5
1466     */

1467    public static MetalTheme JavaDoc getCurrentTheme() {
1468        AppContext context = AppContext.getAppContext();
1469
1470    if ( cachedAppContext != context ) {
1471        currentTheme = (MetalTheme JavaDoc)context.get( "currentMetalTheme" );
1472            if (currentTheme == null) {
1473                // This will happen in two cases:
1474
// . When MetalLookAndFeel is first being initialized.
1475
// . When a new AppContext has been created that hasn't
1476
// triggered UIManager to load a LAF. Rather than invoke
1477
// a method on the UIManager, which would trigger the loading
1478
// of a potentially different LAF, we directly set the
1479
// Theme here.
1480
if (useHighContrastTheme()) {
1481                    currentTheme = new MetalHighContrastTheme JavaDoc();
1482                }
1483                else {
1484                    // Create the default theme. We prefer Ocean, but will
1485
// use DefaultMetalTheme if told to.
1486
String JavaDoc theme = (String JavaDoc)AccessController.doPrivileged(
1487                                   new GetPropertyAction("swing.metalTheme"));
1488                    if ("steel".equals(theme)) {
1489                        currentTheme = new DefaultMetalTheme JavaDoc();
1490                    }
1491                    else {
1492                        currentTheme = new OceanTheme JavaDoc();
1493                    }
1494                }
1495                setCurrentTheme(currentTheme);
1496            }
1497        cachedAppContext = context;
1498    }
1499
1500    return currentTheme;
1501    }
1502
1503    /**
1504     * Returns an <code>Icon</code> with a disabled appearance.
1505     * This method is used to generate a disabled <code>Icon</code> when
1506     * one has not been specified. For example, if you create a
1507     * <code>JButton</code> and only specify an <code>Icon</code> via
1508     * <code>setIcon</code> this method will be called to generate the
1509     * disabled <code>Icon</code>. If null is passed as <code>icon</code>
1510     * this method returns null.
1511     * <p>
1512     * Some look and feels might not render the disabled Icon, in which
1513     * case they will ignore this.
1514     *
1515     * @param component JComponent that will display the Icon, may be null
1516     * @param icon Icon to generate disable icon from.
1517     * @return Disabled icon, or null if a suitable Icon can not be
1518     * generated.
1519     * @since 1.5
1520     */

1521    public Icon getDisabledIcon(JComponent component, Icon icon) {
1522        if ((icon instanceof ImageIcon) && MetalLookAndFeel.usingOcean()) {
1523            return MetalUtils.getOceanDisabledButtonIcon(
1524                                  ((ImageIcon)icon).getImage());
1525        }
1526        return super.getDisabledIcon(component, icon);
1527    }
1528
1529    /**
1530     * Returns an <code>Icon</code> for use by disabled
1531     * components that are also selected. This method is used to generate an
1532     * <code>Icon</code> for components that are in both the disabled and
1533     * selected states but do not have a specific <code>Icon</code> for this
1534     * state. For example, if you create a <code>JButton</code> and only
1535     * specify an <code>Icon</code> via <code>setIcon</code> this method
1536     * will be called to generate the disabled and selected
1537     * <code>Icon</code>. If null is passed as <code>icon</code> this method
1538     * returns null.
1539     * <p>
1540     * Some look and feels might not render the disabled and selected Icon,
1541     * in which case they will ignore this.
1542     *
1543     * @param component JComponent that will display the Icon, may be null
1544     * @param icon Icon to generate disabled and selected icon from.
1545     * @return Disabled and Selected icon, or null if a suitable Icon can not
1546     * be generated.
1547     * @since 1.5
1548     */

1549    public Icon getDisabledSelectedIcon(JComponent component, Icon icon) {
1550        if ((icon instanceof ImageIcon) && MetalLookAndFeel.usingOcean()) {
1551            return MetalUtils.getOceanDisabledButtonIcon(
1552                                  ((ImageIcon)icon).getImage());
1553        }
1554        return super.getDisabledSelectedIcon(component, icon);
1555    }
1556
1557    public static FontUIResource getControlTextFont() { return getCurrentTheme().getControlTextFont();}
1558    public static FontUIResource getSystemTextFont() { return getCurrentTheme().getSystemTextFont();}
1559    public static FontUIResource getUserTextFont() { return getCurrentTheme().getUserTextFont();}
1560    public static FontUIResource getMenuTextFont() { return getCurrentTheme().getMenuTextFont();}
1561    public static FontUIResource getWindowTitleFont() { return getCurrentTheme().getWindowTitleFont();}
1562    public static FontUIResource getSubTextFont() { return getCurrentTheme().getSubTextFont();}
1563
1564    public static ColorUIResource getDesktopColor() { return getCurrentTheme().getDesktopColor(); }
1565    public static ColorUIResource getFocusColor() { return getCurrentTheme().getFocusColor(); }
1566
1567    public static ColorUIResource getWhite() { return getCurrentTheme().getWhite(); }
1568    public static ColorUIResource getBlack() { return getCurrentTheme().getBlack(); }
1569    public static ColorUIResource getControl() { return getCurrentTheme().getControl(); }
1570    public static ColorUIResource getControlShadow() { return getCurrentTheme().getControlShadow(); }
1571    public static ColorUIResource getControlDarkShadow() { return getCurrentTheme().getControlDarkShadow(); }
1572    public static ColorUIResource getControlInfo() { return getCurrentTheme().getControlInfo(); }
1573    public static ColorUIResource getControlHighlight() { return getCurrentTheme().getControlHighlight(); }
1574    public static ColorUIResource getControlDisabled() { return getCurrentTheme().getControlDisabled(); }
1575
1576    public static ColorUIResource getPrimaryControl() { return getCurrentTheme().getPrimaryControl(); }
1577    public static ColorUIResource getPrimaryControlShadow() { return getCurrentTheme().getPrimaryControlShadow(); }
1578    public static ColorUIResource getPrimaryControlDarkShadow() { return getCurrentTheme().getPrimaryControlDarkShadow(); }
1579    public static ColorUIResource getPrimaryControlInfo() { return getCurrentTheme().getPrimaryControlInfo(); }
1580    public static ColorUIResource getPrimaryControlHighlight() { return getCurrentTheme().getPrimaryControlHighlight(); }
1581
1582    public static ColorUIResource getSystemTextColor() { return getCurrentTheme().getSystemTextColor(); }
1583    public static ColorUIResource getControlTextColor() { return getCurrentTheme().getControlTextColor(); }
1584    public static ColorUIResource getInactiveControlTextColor() { return getCurrentTheme().getInactiveControlTextColor(); }
1585    public static ColorUIResource getInactiveSystemTextColor() { return getCurrentTheme().getInactiveSystemTextColor(); }
1586    public static ColorUIResource getUserTextColor() { return getCurrentTheme().getUserTextColor(); }
1587    public static ColorUIResource getTextHighlightColor() { return getCurrentTheme().getTextHighlightColor(); }
1588    public static ColorUIResource getHighlightedTextColor() { return getCurrentTheme().getHighlightedTextColor(); }
1589
1590    public static ColorUIResource getWindowBackground() { return getCurrentTheme().getWindowBackground(); }
1591    public static ColorUIResource getWindowTitleBackground() { return getCurrentTheme().getWindowTitleBackground(); }
1592    public static ColorUIResource getWindowTitleForeground() { return getCurrentTheme().getWindowTitleForeground(); }
1593    public static ColorUIResource getWindowTitleInactiveBackground() { return getCurrentTheme().getWindowTitleInactiveBackground(); }
1594    public static ColorUIResource getWindowTitleInactiveForeground() { return getCurrentTheme().getWindowTitleInactiveForeground(); }
1595
1596    public static ColorUIResource getMenuBackground() { return getCurrentTheme().getMenuBackground(); }
1597    public static ColorUIResource getMenuForeground() { return getCurrentTheme().getMenuForeground(); }
1598    public static ColorUIResource getMenuSelectedBackground() { return getCurrentTheme().getMenuSelectedBackground(); }
1599    public static ColorUIResource getMenuSelectedForeground() { return getCurrentTheme().getMenuSelectedForeground(); }
1600    public static ColorUIResource getMenuDisabledForeground() { return getCurrentTheme().getMenuDisabledForeground(); }
1601    public static ColorUIResource getSeparatorBackground() { return getCurrentTheme().getSeparatorBackground(); }
1602    public static ColorUIResource getSeparatorForeground() { return getCurrentTheme().getSeparatorForeground(); }
1603    public static ColorUIResource getAcceleratorForeground() { return getCurrentTheme().getAcceleratorForeground(); }
1604    public static ColorUIResource getAcceleratorSelectedForeground() { return getCurrentTheme().getAcceleratorSelectedForeground(); }
1605
1606
1607    /**
1608     * MetalLazyValue is a slimmed down version of <code>ProxyLaxyValue</code>.
1609     * The code is duplicate so that it can get at the package private
1610     * classes in metal.
1611     */

1612    private static class MetalLazyValue implements UIDefaults.LazyValue {
1613        /**
1614         * Name of the class to create.
1615         */

1616        private String JavaDoc className;
1617        private String JavaDoc methodName;
1618
1619        MetalLazyValue(String JavaDoc name) {
1620            this.className = name;
1621        }
1622
1623        MetalLazyValue(String JavaDoc name, String JavaDoc methodName) {
1624            this(name);
1625            this.methodName = methodName;
1626        }
1627
1628        public Object JavaDoc createValue(UIDefaults table) {
1629            try {
1630                final Class JavaDoc c = Class.forName(className);
1631
1632                if (methodName == null) {
1633                    return c.newInstance();
1634                }
1635                Method method = (Method)AccessController.doPrivileged(
1636                    new PrivilegedAction JavaDoc() {
1637                    public Object JavaDoc run() {
1638                        Method[] methods = c.getDeclaredMethods();
1639                        for (int counter = methods.length - 1; counter >= 0;
1640                             counter--) {
1641                            if (methods[counter].getName().equals(methodName)){
1642                                methods[counter].setAccessible(true);
1643                                return methods[counter];
1644                            }
1645                        }
1646                        return null;
1647                    }
1648                });
1649                if (method != null) {
1650                    return method.invoke(null, null);
1651                }
1652            } catch (ClassNotFoundException JavaDoc cnfe) {
1653            } catch (InstantiationException JavaDoc ie) {
1654            } catch (IllegalAccessException JavaDoc iae) {
1655            } catch (InvocationTargetException ite) {
1656            }
1657            return null;
1658        }
1659    }
1660
1661
1662    /**
1663     * FontActiveValue redirects to the appropriate metal theme method.
1664     */

1665    private static class FontActiveValue implements UIDefaults.ActiveValue {
1666        private int type;
1667        private MetalTheme JavaDoc theme;
1668
1669        FontActiveValue(MetalTheme JavaDoc theme, int type) {
1670            this.theme = theme;
1671            this.type = type;
1672        }
1673
1674        public Object JavaDoc createValue(UIDefaults table) {
1675            Object JavaDoc value = null;
1676            switch (type) {
1677            case MetalTheme.CONTROL_TEXT_FONT:
1678                value = theme.getControlTextFont();
1679                break;
1680            case MetalTheme.SYSTEM_TEXT_FONT:
1681                value = theme.getSystemTextFont();
1682                break;
1683            case MetalTheme.USER_TEXT_FONT:
1684                value = theme.getUserTextFont();
1685                break;
1686            case MetalTheme.MENU_TEXT_FONT:
1687                value = theme.getMenuTextFont();
1688                break;
1689            case MetalTheme.WINDOW_TITLE_FONT:
1690                value = theme.getWindowTitleFont();
1691                break;
1692            case MetalTheme.SUB_TEXT_FONT:
1693                value = theme.getSubTextFont();
1694                break;
1695            }
1696            return value;
1697        }
1698    }
1699}
1700
Popular Tags