1 /*
   2  * Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package javax.swing.plaf.metal;
  27 
  28 import java.awt.*;
  29 import java.beans.PropertyChangeEvent;
  30 import java.beans.PropertyChangeListener;
  31 import javax.swing.plaf.*;
  32 import javax.swing.*;
  33 import javax.swing.plaf.basic.*;
  34 import javax.swing.text.DefaultEditorKit;
  35 
  36 import java.awt.Color;
  37 import java.awt.event.KeyEvent;
  38 import java.lang.reflect.*;
  39 import java.lang.ref.ReferenceQueue;
  40 import java.lang.ref.WeakReference;
  41 
  42 import java.security.AccessController;
  43 import java.security.PrivilegedAction;
  44 
  45 import sun.awt.*;
  46 import sun.security.action.GetPropertyAction;
  47 import sun.swing.DefaultLayoutStyle;
  48 import sun.swing.SwingLazyValue;
  49 import sun.swing.SwingUtilities2;
  50 
  51 /**
  52  * The Java Look and Feel, otherwise known as Metal.
  53  * <p>
  54  * Each of the {@code ComponentUI}s provided by {@code
  55  * MetalLookAndFeel} derives its behavior from the defaults
  56  * table. Unless otherwise noted each of the {@code ComponentUI}
  57  * implementations in this package document the set of defaults they
  58  * use. Unless otherwise noted the defaults are installed at the time
  59  * {@code installUI} is invoked, and follow the recommendations
  60  * outlined in {@code LookAndFeel} for installing defaults.
  61  * <p>
  62  * {@code MetalLookAndFeel} derives it's color palette and fonts from
  63  * {@code MetalTheme}. The default theme is {@code OceanTheme}. The theme
  64  * can be changed using the {@code setCurrentTheme} method, refer to it
  65  * for details on changing the theme. Prior to 1.5 the default
  66  * theme was {@code DefaultMetalTheme}. The system property
  67  * {@code "swing.metalTheme"} can be set to {@code "steel"} to indicate
  68  * the default should be {@code DefaultMetalTheme}.
  69  * <p>
  70  * <strong>Warning:</strong>
  71  * Serialized objects of this class will not be compatible with
  72  * future Swing releases. The current serialization support is
  73  * appropriate for short term storage or RMI between applications running
  74  * the same version of Swing.  As of 1.4, support for long term storage
  75  * of all JavaBeans<sup><font size="-2">TM</font></sup>
  76  * has been added to the <code>java.beans</code> package.
  77  * Please see {@link java.beans.XMLEncoder}.
  78  *
  79  * @see MetalTheme
  80  * @see DefaultMetalTheme
  81  * @see OceanTheme
  82  *
  83  * @author Steve Wilson
  84  */
  85 public class MetalLookAndFeel extends BasicLookAndFeel
  86 {
  87 
  88     private static boolean METAL_LOOK_AND_FEEL_INITED = false;
  89 
  90     private static MetalTheme currentTheme;
  91     private static boolean isOnlyOneContext = true;
  92     private static AppContext cachedAppContext;
  93 
  94     /**
  95      * True if checked for windows yet.
  96      */
  97     private static boolean checkedWindows;
  98     /**
  99      * True if running on Windows.
 100      */
 101     private static boolean isWindows;
 102 
 103     /**
 104      * Set to true first time we've checked swing.useSystemFontSettings.
 105      */
 106     private static boolean checkedSystemFontSettings;
 107 
 108     /**
 109      * True indicates we should use system fonts, unless the developer has
 110      * specified otherwise with Application.useSystemFontSettings.
 111      */
 112     private static boolean useSystemFonts;
 113 
 114 
 115     /**
 116      * Returns true if running on Windows.
 117      */
 118     static boolean isWindows() {
 119         if (!checkedWindows) {
 120             OSInfo.OSType osType = AccessController.doPrivileged(OSInfo.getOSTypeAction());
 121             if (osType == OSInfo.OSType.WINDOWS) {
 122                 isWindows = true;
 123                 String systemFonts = AccessController.doPrivileged(
 124                     new GetPropertyAction("swing.useSystemFontSettings"));
 125                 useSystemFonts = (systemFonts != null &&
 126                                (Boolean.valueOf(systemFonts).booleanValue()));
 127             }
 128             checkedWindows = true;
 129         }
 130         return isWindows;
 131     }
 132 
 133     /**
 134      * Returns true if system fonts should be used, this is only useful
 135      * for windows.
 136      */
 137     static boolean useSystemFonts() {
 138         if (isWindows() && useSystemFonts) {
 139             if (METAL_LOOK_AND_FEEL_INITED) {
 140                 Object value = UIManager.get(
 141                                  "Application.useSystemFontSettings");
 142 
 143                 return (value == null || Boolean.TRUE.equals(value));
 144             }
 145             // If an instanceof MetalLookAndFeel hasn't been inited yet, we
 146             // don't want to trigger loading of a UI by asking the UIManager
 147             // for a property, assume the user wants system fonts. This will
 148             // be properly adjusted when install is invoked on the
 149             // MetalTheme
 150             return true;
 151         }
 152         return false;
 153     }
 154 
 155     /**
 156      * Returns true if the high contrast theme should be used as the default
 157      * theme.
 158      */
 159     private static boolean useHighContrastTheme() {
 160         if (isWindows() && useSystemFonts()) {
 161             Boolean highContrast = (Boolean)Toolkit.getDefaultToolkit().
 162                                   getDesktopProperty("win.highContrast.on");
 163 
 164             return (highContrast == null) ? false : highContrast.
 165                                             booleanValue();
 166         }
 167         return false;
 168     }
 169 
 170     /**
 171      * Returns true if we're using the Ocean Theme.
 172      */
 173     static boolean usingOcean() {
 174         return (getCurrentTheme() instanceof OceanTheme);
 175     }
 176 
 177     /**
 178      * Returns the name of this look and feel. This returns
 179      * {@code "Metal"}.
 180      *
 181      * @return the name of this look and feel
 182      */
 183     public String getName() {
 184         return "Metal";
 185     }
 186 
 187     /**
 188      * Returns an identifier for this look and feel. This returns
 189      * {@code "Metal"}.
 190      *
 191      * @return the identifier of this look and feel
 192      */
 193     public String getID() {
 194         return "Metal";
 195     }
 196 
 197     /**
 198      * Returns a short description of this look and feel. This returns
 199      * {@code "The Java(tm) Look and Feel"}.
 200 
 201      * @return a short description for the look and feel
 202      */
 203     public String getDescription() {
 204         return "The Java(tm) Look and Feel";
 205     }
 206 
 207     /**
 208      * Returns {@code false}; {@code MetalLookAndFeel} is not a native
 209      * look and feel.
 210      *
 211      * @return {@code false}
 212      */
 213     public boolean isNativeLookAndFeel() {
 214         return false;
 215     }
 216 
 217     /**
 218      * Returns {@code true}; {@code MetalLookAndFeel} can be run on
 219      * any platform.
 220      *
 221      * @return {@code true}
 222      */
 223     public boolean isSupportedLookAndFeel() {
 224         return true;
 225     }
 226 
 227     /**
 228      * Returns {@code true}; metal can provide {@code Window}
 229      * decorations.
 230      *
 231      * @return {@code true}
 232      *
 233      * @see JDialog#setDefaultLookAndFeelDecorated
 234      * @see JFrame#setDefaultLookAndFeelDecorated
 235      * @see JRootPane#setWindowDecorationStyle
 236      * @since 1.4
 237      */
 238     public boolean getSupportsWindowDecorations() {
 239         return true;
 240     }
 241 
 242     /**
 243      * Populates {@code table} with mappings from {@code uiClassID} to
 244      * the fully qualified name of the ui class. {@code
 245      * MetalLookAndFeel} registers an entry for each of the classes in
 246      * the package {@code javax.swing.plaf.metal} that are named
 247      * MetalXXXUI. The string {@code XXX} is one of Swing's uiClassIDs. For
 248      * the {@code uiClassIDs} that do not have a class in metal, the
 249      * corresponding class in {@code javax.swing.plaf.basic} is
 250      * used. For example, metal does not have a class named {@code
 251      * "MetalColorChooserUI"}, as such, {@code
 252      * javax.swing.plaf.basic.BasicColorChooserUI} is used.
 253      *
 254      * @param table the {@code UIDefaults} instance the entries are
 255      *        added to
 256      * @throws NullPointerException if {@code table} is {@code null}
 257      *
 258      * @see javax.swing.plaf.basic.BasicLookAndFeel#initClassDefaults
 259      */
 260     protected void initClassDefaults(UIDefaults table)
 261     {
 262         super.initClassDefaults(table);
 263         final String metalPackageName = "javax.swing.plaf.metal.";
 264 
 265         Object[] uiDefaults = {
 266                    "ButtonUI", metalPackageName + "MetalButtonUI",
 267                  "CheckBoxUI", metalPackageName + "MetalCheckBoxUI",
 268                  "ComboBoxUI", metalPackageName + "MetalComboBoxUI",
 269               "DesktopIconUI", metalPackageName + "MetalDesktopIconUI",
 270               "FileChooserUI", metalPackageName + "MetalFileChooserUI",
 271             "InternalFrameUI", metalPackageName + "MetalInternalFrameUI",
 272                     "LabelUI", metalPackageName + "MetalLabelUI",
 273        "PopupMenuSeparatorUI", metalPackageName + "MetalPopupMenuSeparatorUI",
 274               "ProgressBarUI", metalPackageName + "MetalProgressBarUI",
 275               "RadioButtonUI", metalPackageName + "MetalRadioButtonUI",
 276                 "ScrollBarUI", metalPackageName + "MetalScrollBarUI",
 277                "ScrollPaneUI", metalPackageName + "MetalScrollPaneUI",
 278                 "SeparatorUI", metalPackageName + "MetalSeparatorUI",
 279                    "SliderUI", metalPackageName + "MetalSliderUI",
 280                 "SplitPaneUI", metalPackageName + "MetalSplitPaneUI",
 281                "TabbedPaneUI", metalPackageName + "MetalTabbedPaneUI",
 282                 "TextFieldUI", metalPackageName + "MetalTextFieldUI",
 283              "ToggleButtonUI", metalPackageName + "MetalToggleButtonUI",
 284                   "ToolBarUI", metalPackageName + "MetalToolBarUI",
 285                   "ToolTipUI", metalPackageName + "MetalToolTipUI",
 286                      "TreeUI", metalPackageName + "MetalTreeUI",
 287                  "RootPaneUI", metalPackageName + "MetalRootPaneUI",
 288         };
 289 
 290         table.putDefaults(uiDefaults);
 291     }
 292 
 293     /**
 294      * Populates {@code table} with system colors. The following values are
 295      * added to {@code table}:
 296      * <table border="1" cellpadding="1" cellspacing="0"
 297      *         summary="Metal's system color mapping"
 298      *         valign="top" >
 299      *  <tr valign="top"  align="left">
 300      *    <th bgcolor="#CCCCFF" align="left">Key
 301      *    <th bgcolor="#CCCCFF" align="left">Value
 302      *  <tr valign="top"  align="left">
 303      *    <td>"desktop"
 304      *    <td>{@code theme.getDesktopColor()}
 305      *  <tr valign="top"  align="left">
 306      *    <td>"activeCaption"
 307      *    <td>{@code theme.getWindowTitleBackground()}
 308      *  <tr valign="top"  align="left">
 309      *    <td>"activeCaptionText"
 310      *    <td>{@code theme.getWindowTitleForeground()}
 311      *  <tr valign="top"  align="left">
 312      *    <td>"activeCaptionBorder"
 313      *    <td>{@code theme.getPrimaryControlShadow()}
 314      *  <tr valign="top"  align="left">
 315      *    <td>"inactiveCaption"
 316      *    <td>{@code theme.getWindowTitleInactiveBackground()}
 317      *  <tr valign="top"  align="left">
 318      *    <td>"inactiveCaptionText"
 319      *    <td>{@code theme.getWindowTitleInactiveForeground()}
 320      *  <tr valign="top"  align="left">
 321      *    <td>"inactiveCaptionBorder"
 322      *    <td>{@code theme.getControlShadow()}
 323      *  <tr valign="top"  align="left">
 324      *    <td>"window"
 325      *    <td>{@code theme.getWindowBackground()}
 326      *  <tr valign="top"  align="left">
 327      *    <td>"windowBorder"
 328      *    <td>{@code theme.getControl()}
 329      *  <tr valign="top"  align="left">
 330      *    <td>"windowText"
 331      *    <td>{@code theme.getUserTextColor()}
 332      *  <tr valign="top"  align="left">
 333      *    <td>"menu"
 334      *    <td>{@code theme.getMenuBackground()}
 335      *  <tr valign="top"  align="left">
 336      *    <td>"menuText"
 337      *    <td>{@code theme.getMenuForeground()}
 338      *  <tr valign="top"  align="left">
 339      *    <td>"text"
 340      *    <td>{@code theme.getWindowBackground()}
 341      *  <tr valign="top"  align="left">
 342      *    <td>"textText"
 343      *    <td>{@code theme.getUserTextColor()}
 344      *  <tr valign="top"  align="left">
 345      *    <td>"textHighlight"
 346      *    <td>{@code theme.getTextHighlightColor()}
 347      *  <tr valign="top"  align="left">
 348      *    <td>"textHighlightText"
 349      *    <td>{@code theme.getHighlightedTextColor()}
 350      *  <tr valign="top"  align="left">
 351      *    <td>"textInactiveText"
 352      *    <td>{@code theme.getInactiveSystemTextColor()}
 353      *  <tr valign="top"  align="left">
 354      *    <td>"control"
 355      *    <td>{@code theme.getControl()}
 356      *  <tr valign="top"  align="left">
 357      *    <td>"controlText"
 358      *    <td>{@code theme.getControlTextColor()}
 359      *  <tr valign="top"  align="left">
 360      *    <td>"controlHighlight"
 361      *    <td>{@code theme.getControlHighlight()}
 362      *  <tr valign="top"  align="left">
 363      *    <td>"controlLtHighlight"
 364      *    <td>{@code theme.getControlHighlight()}
 365      *  <tr valign="top"  align="left">
 366      *    <td>"controlShadow"
 367      *    <td>{@code theme.getControlShadow()}
 368      *  <tr valign="top"  align="left">
 369      *    <td>"controlDkShadow"
 370      *    <td>{@code theme.getControlDarkShadow()}
 371      *  <tr valign="top"  align="left">
 372      *    <td>"scrollbar"
 373      *    <td>{@code theme.getControl()}
 374      *  <tr valign="top"  align="left">
 375      *    <td>"info"
 376      *    <td>{@code theme.getPrimaryControl()}
 377      *  <tr valign="top"  align="left">
 378      *    <td>"infoText"
 379      *    <td>{@code theme.getPrimaryControlInfo()}
 380      * </table>
 381      * The value {@code theme} corresponds to the current {@code MetalTheme}.
 382      *
 383      * @param table the {@code UIDefaults} object the values are added to
 384      * @throws NullPointerException if {@code table} is {@code null}
 385      */
 386     protected void initSystemColorDefaults(UIDefaults table)
 387     {
 388         MetalTheme theme = getCurrentTheme();
 389         Color control = theme.getControl();
 390         Object[] systemColors = {
 391                 "desktop", theme.getDesktopColor(), /* Color of the desktop background */
 392           "activeCaption", theme.getWindowTitleBackground(), /* Color for captions (title bars) when they are active. */
 393       "activeCaptionText", theme.getWindowTitleForeground(), /* Text color for text in captions (title bars). */
 394     "activeCaptionBorder", theme.getPrimaryControlShadow(), /* Border color for caption (title bar) window borders. */
 395         "inactiveCaption", theme.getWindowTitleInactiveBackground(), /* Color for captions (title bars) when not active. */
 396     "inactiveCaptionText", theme.getWindowTitleInactiveForeground(), /* Text color for text in inactive captions (title bars). */
 397   "inactiveCaptionBorder", theme.getControlShadow(), /* Border color for inactive caption (title bar) window borders. */
 398                  "window", theme.getWindowBackground(), /* Default color for the interior of windows */
 399            "windowBorder", control, /* ??? */
 400              "windowText", theme.getUserTextColor(), /* ??? */
 401                    "menu", theme.getMenuBackground(), /* Background color for menus */
 402                "menuText", theme.getMenuForeground(), /* Text color for menus  */
 403                    "text", theme.getWindowBackground(), /* Text background color */
 404                "textText", theme.getUserTextColor(), /* Text foreground color */
 405           "textHighlight", theme.getTextHighlightColor(), /* Text background color when selected */
 406       "textHighlightText", theme.getHighlightedTextColor(), /* Text color when selected */
 407        "textInactiveText", theme.getInactiveSystemTextColor(), /* Text color when disabled */
 408                 "control", control, /* Default color for controls (buttons, sliders, etc) */
 409             "controlText", theme.getControlTextColor(), /* Default color for text in controls */
 410        "controlHighlight", theme.getControlHighlight(), /* Specular highlight (opposite of the shadow) */
 411      "controlLtHighlight", theme.getControlHighlight(), /* Highlight color for controls */
 412           "controlShadow", theme.getControlShadow(), /* Shadow color for controls */
 413         "controlDkShadow", theme.getControlDarkShadow(), /* Dark shadow color for controls */
 414               "scrollbar", control, /* Scrollbar background (usually the "track") */
 415                    "info", theme.getPrimaryControl(), /* ToolTip Background */
 416                "infoText", theme.getPrimaryControlInfo()  /* ToolTip Text */
 417         };
 418 
 419         table.putDefaults(systemColors);
 420     }
 421 
 422     /**
 423      * Initialize the defaults table with the name of the ResourceBundle
 424      * used for getting localized defaults.
 425      */
 426     private void initResourceBundle(UIDefaults table) {
 427         table.addResourceBundle( "com.sun.swing.internal.plaf.metal.resources.metal" );
 428     }
 429 
 430     /**
 431      * Populates {@code table} with the defaults for metal.
 432      *
 433      * @param table the {@code UIDefaults} to add the values to
 434      * @throws NullPointerException if {@code table} is {@code null}
 435      */
 436     protected void initComponentDefaults(UIDefaults table) {
 437         super.initComponentDefaults( table );
 438 
 439         initResourceBundle(table);
 440 
 441         Color acceleratorForeground = getAcceleratorForeground();
 442         Color acceleratorSelectedForeground = getAcceleratorSelectedForeground();
 443         Color control = getControl();
 444         Color controlHighlight = getControlHighlight();
 445         Color controlShadow = getControlShadow();
 446         Color controlDarkShadow = getControlDarkShadow();
 447         Color controlTextColor = getControlTextColor();
 448         Color focusColor = getFocusColor();
 449         Color inactiveControlTextColor = getInactiveControlTextColor();
 450         Color menuBackground = getMenuBackground();
 451         Color menuSelectedBackground = getMenuSelectedBackground();
 452         Color menuDisabledForeground = getMenuDisabledForeground();
 453         Color menuSelectedForeground = getMenuSelectedForeground();
 454         Color primaryControl = getPrimaryControl();
 455         Color primaryControlDarkShadow = getPrimaryControlDarkShadow();
 456         Color primaryControlShadow = getPrimaryControlShadow();
 457         Color systemTextColor = getSystemTextColor();
 458 
 459         Insets zeroInsets = new InsetsUIResource(0, 0, 0, 0);
 460 
 461         Integer zero = new Integer(0);
 462 
 463         Object textFieldBorder =
 464             new SwingLazyValue("javax.swing.plaf.metal.MetalBorders",
 465                                           "getTextFieldBorder");
 466 
 467         Object dialogBorder = new MetalLazyValue(
 468                           "javax.swing.plaf.metal.MetalBorders$DialogBorder");
 469 
 470         Object questionDialogBorder = new MetalLazyValue(
 471                   "javax.swing.plaf.metal.MetalBorders$QuestionDialogBorder");
 472 
 473         Object fieldInputMap = new UIDefaults.LazyInputMap(new Object[] {
 474                            "ctrl C", DefaultEditorKit.copyAction,
 475                            "ctrl V", DefaultEditorKit.pasteAction,
 476                            "ctrl X", DefaultEditorKit.cutAction,
 477                              "COPY", DefaultEditorKit.copyAction,
 478                             "PASTE", DefaultEditorKit.pasteAction,
 479                               "CUT", DefaultEditorKit.cutAction,
 480                    "control INSERT", DefaultEditorKit.copyAction,
 481                      "shift INSERT", DefaultEditorKit.pasteAction,
 482                      "shift DELETE", DefaultEditorKit.cutAction,
 483                        "shift LEFT", DefaultEditorKit.selectionBackwardAction,
 484                     "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction,
 485                       "shift RIGHT", DefaultEditorKit.selectionForwardAction,
 486                    "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction,
 487                         "ctrl LEFT", DefaultEditorKit.previousWordAction,
 488                      "ctrl KP_LEFT", DefaultEditorKit.previousWordAction,
 489                        "ctrl RIGHT", DefaultEditorKit.nextWordAction,
 490                     "ctrl KP_RIGHT", DefaultEditorKit.nextWordAction,
 491                   "ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
 492                "ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction,
 493                  "ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction,
 494               "ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction,
 495                            "ctrl A", DefaultEditorKit.selectAllAction,
 496                              "HOME", DefaultEditorKit.beginLineAction,
 497                               "END", DefaultEditorKit.endLineAction,
 498                        "shift HOME", DefaultEditorKit.selectionBeginLineAction,
 499                         "shift END", DefaultEditorKit.selectionEndLineAction,
 500                        "BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
 501                  "shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
 502                            "ctrl H", DefaultEditorKit.deletePrevCharAction,
 503                            "DELETE", DefaultEditorKit.deleteNextCharAction,
 504                       "ctrl DELETE", DefaultEditorKit.deleteNextWordAction,
 505                   "ctrl BACK_SPACE", DefaultEditorKit.deletePrevWordAction,
 506                             "RIGHT", DefaultEditorKit.forwardAction,
 507                              "LEFT", DefaultEditorKit.backwardAction,
 508                          "KP_RIGHT", DefaultEditorKit.forwardAction,
 509                           "KP_LEFT", DefaultEditorKit.backwardAction,
 510                             "ENTER", JTextField.notifyAction,
 511                   "ctrl BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/,
 512                    "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
 513         });
 514 
 515         Object passwordInputMap = new UIDefaults.LazyInputMap(new Object[] {
 516                            "ctrl C", DefaultEditorKit.copyAction,
 517                            "ctrl V", DefaultEditorKit.pasteAction,
 518                            "ctrl X", DefaultEditorKit.cutAction,
 519                              "COPY", DefaultEditorKit.copyAction,
 520                             "PASTE", DefaultEditorKit.pasteAction,
 521                               "CUT", DefaultEditorKit.cutAction,
 522                    "control INSERT", DefaultEditorKit.copyAction,
 523                      "shift INSERT", DefaultEditorKit.pasteAction,
 524                      "shift DELETE", DefaultEditorKit.cutAction,
 525                        "shift LEFT", DefaultEditorKit.selectionBackwardAction,
 526                     "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction,
 527                       "shift RIGHT", DefaultEditorKit.selectionForwardAction,
 528                    "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction,
 529                         "ctrl LEFT", DefaultEditorKit.beginLineAction,
 530                      "ctrl KP_LEFT", DefaultEditorKit.beginLineAction,
 531                        "ctrl RIGHT", DefaultEditorKit.endLineAction,
 532                     "ctrl KP_RIGHT", DefaultEditorKit.endLineAction,
 533                   "ctrl shift LEFT", DefaultEditorKit.selectionBeginLineAction,
 534                "ctrl shift KP_LEFT", DefaultEditorKit.selectionBeginLineAction,
 535                  "ctrl shift RIGHT", DefaultEditorKit.selectionEndLineAction,
 536               "ctrl shift KP_RIGHT", DefaultEditorKit.selectionEndLineAction,
 537                            "ctrl A", DefaultEditorKit.selectAllAction,
 538                              "HOME", DefaultEditorKit.beginLineAction,
 539                               "END", DefaultEditorKit.endLineAction,
 540                        "shift HOME", DefaultEditorKit.selectionBeginLineAction,
 541                         "shift END", DefaultEditorKit.selectionEndLineAction,
 542                        "BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
 543                  "shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
 544                            "ctrl H", DefaultEditorKit.deletePrevCharAction,
 545                            "DELETE", DefaultEditorKit.deleteNextCharAction,
 546                             "RIGHT", DefaultEditorKit.forwardAction,
 547                              "LEFT", DefaultEditorKit.backwardAction,
 548                          "KP_RIGHT", DefaultEditorKit.forwardAction,
 549                           "KP_LEFT", DefaultEditorKit.backwardAction,
 550                             "ENTER", JTextField.notifyAction,
 551                   "ctrl BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/,
 552                    "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
 553         });
 554 
 555         Object multilineInputMap = new UIDefaults.LazyInputMap(new Object[] {
 556                            "ctrl C", DefaultEditorKit.copyAction,
 557                            "ctrl V", DefaultEditorKit.pasteAction,
 558                            "ctrl X", DefaultEditorKit.cutAction,
 559                              "COPY", DefaultEditorKit.copyAction,
 560                             "PASTE", DefaultEditorKit.pasteAction,
 561                               "CUT", DefaultEditorKit.cutAction,
 562                    "control INSERT", DefaultEditorKit.copyAction,
 563                      "shift INSERT", DefaultEditorKit.pasteAction,
 564                      "shift DELETE", DefaultEditorKit.cutAction,
 565                        "shift LEFT", DefaultEditorKit.selectionBackwardAction,
 566                     "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction,
 567                       "shift RIGHT", DefaultEditorKit.selectionForwardAction,
 568                    "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction,
 569                         "ctrl LEFT", DefaultEditorKit.previousWordAction,
 570                      "ctrl KP_LEFT", DefaultEditorKit.previousWordAction,
 571                        "ctrl RIGHT", DefaultEditorKit.nextWordAction,
 572                     "ctrl KP_RIGHT", DefaultEditorKit.nextWordAction,
 573                   "ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
 574                "ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction,
 575                  "ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction,
 576               "ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction,
 577                            "ctrl A", DefaultEditorKit.selectAllAction,
 578                              "HOME", DefaultEditorKit.beginLineAction,
 579                               "END", DefaultEditorKit.endLineAction,
 580                        "shift HOME", DefaultEditorKit.selectionBeginLineAction,
 581                         "shift END", DefaultEditorKit.selectionEndLineAction,
 582 
 583                                "UP", DefaultEditorKit.upAction,
 584                             "KP_UP", DefaultEditorKit.upAction,
 585                              "DOWN", DefaultEditorKit.downAction,
 586                           "KP_DOWN", DefaultEditorKit.downAction,
 587                           "PAGE_UP", DefaultEditorKit.pageUpAction,
 588                         "PAGE_DOWN", DefaultEditorKit.pageDownAction,
 589                     "shift PAGE_UP", "selection-page-up",
 590                   "shift PAGE_DOWN", "selection-page-down",
 591                "ctrl shift PAGE_UP", "selection-page-left",
 592              "ctrl shift PAGE_DOWN", "selection-page-right",
 593                          "shift UP", DefaultEditorKit.selectionUpAction,
 594                       "shift KP_UP", DefaultEditorKit.selectionUpAction,
 595                        "shift DOWN", DefaultEditorKit.selectionDownAction,
 596                     "shift KP_DOWN", DefaultEditorKit.selectionDownAction,
 597                             "ENTER", DefaultEditorKit.insertBreakAction,
 598                        "BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
 599                  "shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
 600                            "ctrl H", DefaultEditorKit.deletePrevCharAction,
 601                            "DELETE", DefaultEditorKit.deleteNextCharAction,
 602                       "ctrl DELETE", DefaultEditorKit.deleteNextWordAction,
 603                   "ctrl BACK_SPACE", DefaultEditorKit.deletePrevWordAction,
 604                             "RIGHT", DefaultEditorKit.forwardAction,
 605                              "LEFT", DefaultEditorKit.backwardAction,
 606                          "KP_RIGHT", DefaultEditorKit.forwardAction,
 607                           "KP_LEFT", DefaultEditorKit.backwardAction,
 608                               "TAB", DefaultEditorKit.insertTabAction,
 609                   "ctrl BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/,
 610                         "ctrl HOME", DefaultEditorKit.beginAction,
 611                          "ctrl END", DefaultEditorKit.endAction,
 612                   "ctrl shift HOME", DefaultEditorKit.selectionBeginAction,
 613                    "ctrl shift END", DefaultEditorKit.selectionEndAction,
 614                            "ctrl T", "next-link-action",
 615                      "ctrl shift T", "previous-link-action",
 616                        "ctrl SPACE", "activate-link-action",
 617                    "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
 618         });
 619 
 620         Object scrollPaneBorder = new SwingLazyValue("javax.swing.plaf.metal.MetalBorders$ScrollPaneBorder");
 621         Object buttonBorder =
 622                     new SwingLazyValue("javax.swing.plaf.metal.MetalBorders",
 623                                           "getButtonBorder");
 624 
 625         Object toggleButtonBorder =
 626             new SwingLazyValue("javax.swing.plaf.metal.MetalBorders",
 627                                           "getToggleButtonBorder");
 628 
 629         Object titledBorderBorder =
 630             new SwingLazyValue(
 631                           "javax.swing.plaf.BorderUIResource$LineBorderUIResource",
 632                           new Object[] {controlShadow});
 633 
 634         Object desktopIconBorder =
 635             new SwingLazyValue(
 636                           "javax.swing.plaf.metal.MetalBorders",
 637                           "getDesktopIconBorder");
 638 
 639         Object menuBarBorder =
 640             new SwingLazyValue(
 641                           "javax.swing.plaf.metal.MetalBorders$MenuBarBorder");
 642 
 643         Object popupMenuBorder =
 644             new SwingLazyValue(
 645                          "javax.swing.plaf.metal.MetalBorders$PopupMenuBorder");
 646         Object menuItemBorder =
 647             new SwingLazyValue(
 648                          "javax.swing.plaf.metal.MetalBorders$MenuItemBorder");
 649 
 650         Object menuItemAcceleratorDelimiter = "-";
 651         Object toolBarBorder = new SwingLazyValue("javax.swing.plaf.metal.MetalBorders$ToolBarBorder");
 652 
 653         Object progressBarBorder = new SwingLazyValue(
 654                           "javax.swing.plaf.BorderUIResource$LineBorderUIResource",
 655                           new Object[] {controlDarkShadow, new Integer(1)});
 656 
 657         Object toolTipBorder = new SwingLazyValue(
 658                           "javax.swing.plaf.BorderUIResource$LineBorderUIResource",
 659                           new Object[] {primaryControlDarkShadow});
 660 
 661         Object toolTipBorderInactive = new SwingLazyValue(
 662                           "javax.swing.plaf.BorderUIResource$LineBorderUIResource",
 663                           new Object[] {controlDarkShadow});
 664 
 665         Object focusCellHighlightBorder = new SwingLazyValue(
 666                           "javax.swing.plaf.BorderUIResource$LineBorderUIResource",
 667                           new Object[] {focusColor});
 668 
 669         Object tabbedPaneTabAreaInsets = new InsetsUIResource(4, 2, 0, 6);
 670 
 671         Object tabbedPaneTabInsets = new InsetsUIResource(0, 9, 1, 9);
 672 
 673         final Object[] internalFrameIconArgs = new Object[1];
 674         internalFrameIconArgs[0] = new Integer(16);
 675 
 676         Object[] defaultCueList = new Object[] {
 677                 "OptionPane.errorSound",
 678                 "OptionPane.informationSound",
 679                 "OptionPane.questionSound",
 680                 "OptionPane.warningSound" };
 681 
 682         MetalTheme theme = getCurrentTheme();
 683         Object menuTextValue = new FontActiveValue(theme,
 684                                                    MetalTheme.MENU_TEXT_FONT);
 685         Object controlTextValue = new FontActiveValue(theme,
 686                                MetalTheme.CONTROL_TEXT_FONT);
 687         Object userTextValue = new FontActiveValue(theme,
 688                                                    MetalTheme.USER_TEXT_FONT);
 689         Object windowTitleValue = new FontActiveValue(theme,
 690                                MetalTheme.WINDOW_TITLE_FONT);
 691         Object subTextValue = new FontActiveValue(theme,
 692                                                   MetalTheme.SUB_TEXT_FONT);
 693         Object systemTextValue = new FontActiveValue(theme,
 694                                                  MetalTheme.SYSTEM_TEXT_FONT);
 695         //
 696         // DEFAULTS TABLE
 697         //
 698 
 699         Object[] defaults = {
 700             // *** Auditory Feedback
 701             "AuditoryCues.defaultCueList", defaultCueList,
 702             // this key defines which of the various cues to render
 703             // This is disabled until sound bugs can be resolved.
 704             "AuditoryCues.playList", null, // defaultCueList,
 705 
 706             // Text (Note: many are inherited)
 707             "TextField.border", textFieldBorder,
 708             "TextField.font", userTextValue,
 709 
 710             "PasswordField.border", textFieldBorder,
 711             // passwordField.font should actually map to
 712             // win.ansiFixed.font.height on windows.
 713             "PasswordField.font", userTextValue,
 714             "PasswordField.echoChar", (char)0x2022,
 715 
 716             // TextArea.font should actually map to win.ansiFixed.font.height
 717             // on windows.
 718             "TextArea.font", userTextValue,
 719 
 720             "TextPane.background", table.get("window"),
 721             "TextPane.font", userTextValue,
 722 
 723             "EditorPane.background", table.get("window"),
 724             "EditorPane.font", userTextValue,
 725 
 726             "TextField.focusInputMap", fieldInputMap,
 727             "PasswordField.focusInputMap", passwordInputMap,
 728             "TextArea.focusInputMap", multilineInputMap,
 729             "TextPane.focusInputMap", multilineInputMap,
 730             "EditorPane.focusInputMap", multilineInputMap,
 731 
 732             // FormattedTextFields
 733             "FormattedTextField.border", textFieldBorder,
 734             "FormattedTextField.font", userTextValue,
 735             "FormattedTextField.focusInputMap",
 736               new UIDefaults.LazyInputMap(new Object[] {
 737                            "ctrl C", DefaultEditorKit.copyAction,
 738                            "ctrl V", DefaultEditorKit.pasteAction,
 739                            "ctrl X", DefaultEditorKit.cutAction,
 740                              "COPY", DefaultEditorKit.copyAction,
 741                             "PASTE", DefaultEditorKit.pasteAction,
 742                               "CUT", DefaultEditorKit.cutAction,
 743                    "control INSERT", DefaultEditorKit.copyAction,
 744                      "shift INSERT", DefaultEditorKit.pasteAction,
 745                      "shift DELETE", DefaultEditorKit.cutAction,
 746                        "shift LEFT", DefaultEditorKit.selectionBackwardAction,
 747                     "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction,
 748                       "shift RIGHT", DefaultEditorKit.selectionForwardAction,
 749                    "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction,
 750                         "ctrl LEFT", DefaultEditorKit.previousWordAction,
 751                      "ctrl KP_LEFT", DefaultEditorKit.previousWordAction,
 752                        "ctrl RIGHT", DefaultEditorKit.nextWordAction,
 753                     "ctrl KP_RIGHT", DefaultEditorKit.nextWordAction,
 754                   "ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
 755                "ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction,
 756                  "ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction,
 757               "ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction,
 758                            "ctrl A", DefaultEditorKit.selectAllAction,
 759                              "HOME", DefaultEditorKit.beginLineAction,
 760                               "END", DefaultEditorKit.endLineAction,
 761                        "shift HOME", DefaultEditorKit.selectionBeginLineAction,
 762                         "shift END", DefaultEditorKit.selectionEndLineAction,
 763                        "BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
 764                  "shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
 765                            "ctrl H", DefaultEditorKit.deletePrevCharAction,
 766                            "DELETE", DefaultEditorKit.deleteNextCharAction,
 767                       "ctrl DELETE", DefaultEditorKit.deleteNextWordAction,
 768                   "ctrl BACK_SPACE", DefaultEditorKit.deletePrevWordAction,
 769                             "RIGHT", DefaultEditorKit.forwardAction,
 770                              "LEFT", DefaultEditorKit.backwardAction,
 771                          "KP_RIGHT", DefaultEditorKit.forwardAction,
 772                           "KP_LEFT", DefaultEditorKit.backwardAction,
 773                             "ENTER", JTextField.notifyAction,
 774                   "ctrl BACK_SLASH", "unselect",
 775                    "control shift O", "toggle-componentOrientation",
 776                            "ESCAPE", "reset-field-edit",
 777                                "UP", "increment",
 778                             "KP_UP", "increment",
 779                              "DOWN", "decrement",
 780                           "KP_DOWN", "decrement",
 781               }),
 782 
 783 
 784             // Buttons
 785             "Button.defaultButtonFollowsFocus", Boolean.FALSE,
 786             "Button.disabledText", inactiveControlTextColor,
 787             "Button.select", controlShadow,
 788             "Button.border", buttonBorder,
 789             "Button.font", controlTextValue,
 790             "Button.focus", focusColor,
 791             "Button.focusInputMap", new UIDefaults.LazyInputMap(new Object[] {
 792                           "SPACE", "pressed",
 793                  "released SPACE", "released"
 794               }),
 795 
 796             "CheckBox.disabledText", inactiveControlTextColor,
 797             "Checkbox.select", controlShadow,
 798             "CheckBox.font", controlTextValue,
 799             "CheckBox.focus", focusColor,
 800             "CheckBox.icon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getCheckBoxIcon"),
 801             "CheckBox.focusInputMap",
 802                new UIDefaults.LazyInputMap(new Object[] {
 803                             "SPACE", "pressed",
 804                    "released SPACE", "released"
 805                  }),
 806             // margin is 2 all the way around, BasicBorders.RadioButtonBorder
 807             // (checkbox uses RadioButtonBorder) is 2 all the way around too.
 808             "CheckBox.totalInsets", new Insets(4, 4, 4, 4),
 809 
 810             "RadioButton.disabledText", inactiveControlTextColor,
 811             "RadioButton.select", controlShadow,
 812             "RadioButton.icon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getRadioButtonIcon"),
 813             "RadioButton.font", controlTextValue,
 814             "RadioButton.focus", focusColor,
 815             "RadioButton.focusInputMap",
 816                new UIDefaults.LazyInputMap(new Object[] {
 817                           "SPACE", "pressed",
 818                  "released SPACE", "released"
 819               }),
 820             // margin is 2 all the way around, BasicBorders.RadioButtonBorder
 821             // is 2 all the way around too.
 822             "RadioButton.totalInsets", new Insets(4, 4, 4, 4),
 823 
 824             "ToggleButton.select", controlShadow,
 825             "ToggleButton.disabledText", inactiveControlTextColor,
 826             "ToggleButton.focus", focusColor,
 827             "ToggleButton.border", toggleButtonBorder,
 828             "ToggleButton.font", controlTextValue,
 829             "ToggleButton.focusInputMap",
 830               new UIDefaults.LazyInputMap(new Object[] {
 831                             "SPACE", "pressed",
 832                    "released SPACE", "released"
 833                 }),
 834 
 835 
 836             // File View
 837             "FileView.directoryIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getTreeFolderIcon"),
 838             "FileView.fileIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getTreeLeafIcon"),
 839             "FileView.computerIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getTreeComputerIcon"),
 840             "FileView.hardDriveIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getTreeHardDriveIcon"),
 841             "FileView.floppyDriveIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getTreeFloppyDriveIcon"),
 842 
 843             // File Chooser
 844             "FileChooser.detailsViewIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getFileChooserDetailViewIcon"),
 845             "FileChooser.homeFolderIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getFileChooserHomeFolderIcon"),
 846             "FileChooser.listViewIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getFileChooserListViewIcon"),
 847             "FileChooser.newFolderIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getFileChooserNewFolderIcon"),
 848             "FileChooser.upFolderIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getFileChooserUpFolderIcon"),
 849 
 850             "FileChooser.lookInLabelMnemonic", new Integer(KeyEvent.VK_I),
 851             "FileChooser.fileNameLabelMnemonic", new Integer(KeyEvent.VK_N),
 852             "FileChooser.filesOfTypeLabelMnemonic", new Integer(KeyEvent.VK_T),
 853             "FileChooser.usesSingleFilePane", Boolean.TRUE,
 854             "FileChooser.ancestorInputMap",
 855                new UIDefaults.LazyInputMap(new Object[] {
 856                      "ESCAPE", "cancelSelection",
 857                      "F2", "editFileName",
 858                      "F5", "refresh",
 859                      "BACK_SPACE", "Go Up",
 860                      "ENTER", "approveSelection",
 861                 "ctrl ENTER", "approveSelection"
 862                  }),
 863 
 864 
 865             // ToolTip
 866             "ToolTip.font", systemTextValue,
 867             "ToolTip.border", toolTipBorder,
 868             "ToolTip.borderInactive", toolTipBorderInactive,
 869             "ToolTip.backgroundInactive", control,
 870             "ToolTip.foregroundInactive", controlDarkShadow,
 871             "ToolTip.hideAccelerator", Boolean.FALSE,
 872 
 873             // ToolTipManager
 874             "ToolTipManager.enableToolTipMode", "activeApplication",
 875 
 876             // Slider Defaults
 877             "Slider.font", controlTextValue,
 878             "Slider.border", null,
 879             "Slider.foreground", primaryControlShadow,
 880             "Slider.focus", focusColor,
 881             "Slider.focusInsets", zeroInsets,
 882             "Slider.trackWidth", new Integer( 7 ),
 883             "Slider.majorTickLength", new Integer( 6 ),
 884             "Slider.horizontalThumbIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getHorizontalSliderThumbIcon"),
 885             "Slider.verticalThumbIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getVerticalSliderThumbIcon"),
 886             "Slider.focusInputMap",
 887                new UIDefaults.LazyInputMap(new Object[] {
 888                        "RIGHT", "positiveUnitIncrement",
 889                     "KP_RIGHT", "positiveUnitIncrement",
 890                         "DOWN", "negativeUnitIncrement",
 891                      "KP_DOWN", "negativeUnitIncrement",
 892                    "PAGE_DOWN", "negativeBlockIncrement",
 893               "ctrl PAGE_DOWN", "negativeBlockIncrement",
 894                         "LEFT", "negativeUnitIncrement",
 895                      "KP_LEFT", "negativeUnitIncrement",
 896                           "UP", "positiveUnitIncrement",
 897                        "KP_UP", "positiveUnitIncrement",
 898                      "PAGE_UP", "positiveBlockIncrement",
 899                 "ctrl PAGE_UP", "positiveBlockIncrement",
 900                         "HOME", "minScroll",
 901                          "END", "maxScroll"
 902                  }),
 903 
 904             // Progress Bar
 905             "ProgressBar.font", controlTextValue,
 906             "ProgressBar.foreground", primaryControlShadow,
 907             "ProgressBar.selectionBackground", primaryControlDarkShadow,
 908             "ProgressBar.border", progressBarBorder,
 909             "ProgressBar.cellSpacing", zero,
 910             "ProgressBar.cellLength", new Integer(1),
 911 
 912             // Combo Box
 913             "ComboBox.background", control,
 914             "ComboBox.foreground", controlTextColor,
 915             "ComboBox.selectionBackground", primaryControlShadow,
 916             "ComboBox.selectionForeground", controlTextColor,
 917             "ComboBox.font", controlTextValue,
 918             "ComboBox.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[] {
 919                      "ESCAPE", "hidePopup",
 920                     "PAGE_UP", "pageUpPassThrough",
 921                   "PAGE_DOWN", "pageDownPassThrough",
 922                        "HOME", "homePassThrough",
 923                         "END", "endPassThrough",
 924                        "DOWN", "selectNext",
 925                     "KP_DOWN", "selectNext",
 926                    "alt DOWN", "togglePopup",
 927                 "alt KP_DOWN", "togglePopup",
 928                      "alt UP", "togglePopup",
 929                   "alt KP_UP", "togglePopup",
 930                       "SPACE", "spacePopup",
 931                      "ENTER", "enterPressed",
 932                          "UP", "selectPrevious",
 933                       "KP_UP", "selectPrevious"
 934               }),
 935 
 936             // Internal Frame Defaults
 937             "InternalFrame.icon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getInternalFrameDefaultMenuIcon"),
 938             "InternalFrame.border", new SwingLazyValue("javax.swing.plaf.metal.MetalBorders$InternalFrameBorder"),
 939             "InternalFrame.optionDialogBorder", new SwingLazyValue("javax.swing.plaf.metal.MetalBorders$OptionDialogBorder"),
 940             "InternalFrame.paletteBorder", new SwingLazyValue("javax.swing.plaf.metal.MetalBorders$PaletteBorder"),
 941             "InternalFrame.paletteTitleHeight", new Integer(11),
 942             "InternalFrame.paletteCloseIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory$PaletteCloseIcon"),
 943             "InternalFrame.closeIcon",
 944                   new SwingLazyValue(
 945                                      "javax.swing.plaf.metal.MetalIconFactory",
 946                                      "getInternalFrameCloseIcon",
 947                                      internalFrameIconArgs),
 948             "InternalFrame.maximizeIcon",
 949                   new SwingLazyValue(
 950                                      "javax.swing.plaf.metal.MetalIconFactory",
 951                                      "getInternalFrameMaximizeIcon",
 952                                      internalFrameIconArgs),
 953             "InternalFrame.iconifyIcon",
 954                   new SwingLazyValue(
 955                                      "javax.swing.plaf.metal.MetalIconFactory",
 956                                      "getInternalFrameMinimizeIcon",
 957                                      internalFrameIconArgs),
 958             "InternalFrame.minimizeIcon",
 959                   new SwingLazyValue(
 960                                      "javax.swing.plaf.metal.MetalIconFactory",
 961                                      "getInternalFrameAltMaximizeIcon",
 962                                      internalFrameIconArgs),
 963             "InternalFrame.titleFont",  windowTitleValue,
 964             "InternalFrame.windowBindings", null,
 965             // Internal Frame Auditory Cue Mappings
 966             "InternalFrame.closeSound", "sounds/FrameClose.wav",
 967             "InternalFrame.maximizeSound", "sounds/FrameMaximize.wav",
 968             "InternalFrame.minimizeSound", "sounds/FrameMinimize.wav",
 969             "InternalFrame.restoreDownSound", "sounds/FrameRestoreDown.wav",
 970             "InternalFrame.restoreUpSound", "sounds/FrameRestoreUp.wav",
 971 
 972             // Desktop Icon
 973             "DesktopIcon.border", desktopIconBorder,
 974             "DesktopIcon.font", controlTextValue,
 975             "DesktopIcon.foreground", controlTextColor,
 976             "DesktopIcon.background", control,
 977             "DesktopIcon.width", new Integer(160),
 978 
 979             "Desktop.ancestorInputMap",
 980                new UIDefaults.LazyInputMap(new Object[] {
 981                  "ctrl F5", "restore",
 982                  "ctrl F4", "close",
 983                  "ctrl F7", "move",
 984                  "ctrl F8", "resize",
 985                    "RIGHT", "right",
 986                 "KP_RIGHT", "right",
 987              "shift RIGHT", "shrinkRight",
 988           "shift KP_RIGHT", "shrinkRight",
 989                     "LEFT", "left",
 990                  "KP_LEFT", "left",
 991               "shift LEFT", "shrinkLeft",
 992            "shift KP_LEFT", "shrinkLeft",
 993                       "UP", "up",
 994                    "KP_UP", "up",
 995                 "shift UP", "shrinkUp",
 996              "shift KP_UP", "shrinkUp",
 997                     "DOWN", "down",
 998                  "KP_DOWN", "down",
 999               "shift DOWN", "shrinkDown",
1000            "shift KP_DOWN", "shrinkDown",
1001                   "ESCAPE", "escape",
1002                  "ctrl F9", "minimize",
1003                 "ctrl F10", "maximize",
1004                  "ctrl F6", "selectNextFrame",
1005                 "ctrl TAB", "selectNextFrame",
1006              "ctrl alt F6", "selectNextFrame",
1007        "shift ctrl alt F6", "selectPreviousFrame",
1008                 "ctrl F12", "navigateNext",
1009            "shift ctrl F12", "navigatePrevious"
1010               }),
1011 
1012             // Titled Border
1013             "TitledBorder.font", controlTextValue,
1014             "TitledBorder.titleColor", systemTextColor,
1015             "TitledBorder.border", titledBorderBorder,
1016 
1017             // Label
1018             "Label.font", controlTextValue,
1019             "Label.foreground", systemTextColor,
1020             "Label.disabledForeground", getInactiveSystemTextColor(),
1021 
1022             // List
1023             "List.font", controlTextValue,
1024             "List.focusCellHighlightBorder", focusCellHighlightBorder,
1025             "List.focusInputMap",
1026                new UIDefaults.LazyInputMap(new Object[] {
1027                            "ctrl C", "copy",
1028                            "ctrl V", "paste",
1029                            "ctrl X", "cut",
1030                              "COPY", "copy",
1031                             "PASTE", "paste",
1032                               "CUT", "cut",
1033                    "control INSERT", "copy",
1034                      "shift INSERT", "paste",
1035                      "shift DELETE", "cut",
1036                                "UP", "selectPreviousRow",
1037                             "KP_UP", "selectPreviousRow",
1038                          "shift UP", "selectPreviousRowExtendSelection",
1039                       "shift KP_UP", "selectPreviousRowExtendSelection",
1040                     "ctrl shift UP", "selectPreviousRowExtendSelection",
1041                  "ctrl shift KP_UP", "selectPreviousRowExtendSelection",
1042                           "ctrl UP", "selectPreviousRowChangeLead",
1043                        "ctrl KP_UP", "selectPreviousRowChangeLead",
1044                              "DOWN", "selectNextRow",
1045                           "KP_DOWN", "selectNextRow",
1046                        "shift DOWN", "selectNextRowExtendSelection",
1047                     "shift KP_DOWN", "selectNextRowExtendSelection",
1048                   "ctrl shift DOWN", "selectNextRowExtendSelection",
1049                "ctrl shift KP_DOWN", "selectNextRowExtendSelection",
1050                         "ctrl DOWN", "selectNextRowChangeLead",
1051                      "ctrl KP_DOWN", "selectNextRowChangeLead",
1052                              "LEFT", "selectPreviousColumn",
1053                           "KP_LEFT", "selectPreviousColumn",
1054                        "shift LEFT", "selectPreviousColumnExtendSelection",
1055                     "shift KP_LEFT", "selectPreviousColumnExtendSelection",
1056                   "ctrl shift LEFT", "selectPreviousColumnExtendSelection",
1057                "ctrl shift KP_LEFT", "selectPreviousColumnExtendSelection",
1058                         "ctrl LEFT", "selectPreviousColumnChangeLead",
1059                      "ctrl KP_LEFT", "selectPreviousColumnChangeLead",
1060                             "RIGHT", "selectNextColumn",
1061                          "KP_RIGHT", "selectNextColumn",
1062                       "shift RIGHT", "selectNextColumnExtendSelection",
1063                    "shift KP_RIGHT", "selectNextColumnExtendSelection",
1064                  "ctrl shift RIGHT", "selectNextColumnExtendSelection",
1065               "ctrl shift KP_RIGHT", "selectNextColumnExtendSelection",
1066                        "ctrl RIGHT", "selectNextColumnChangeLead",
1067                     "ctrl KP_RIGHT", "selectNextColumnChangeLead",
1068                              "HOME", "selectFirstRow",
1069                        "shift HOME", "selectFirstRowExtendSelection",
1070                   "ctrl shift HOME", "selectFirstRowExtendSelection",
1071                         "ctrl HOME", "selectFirstRowChangeLead",
1072                               "END", "selectLastRow",
1073                         "shift END", "selectLastRowExtendSelection",
1074                    "ctrl shift END", "selectLastRowExtendSelection",
1075                          "ctrl END", "selectLastRowChangeLead",
1076                           "PAGE_UP", "scrollUp",
1077                     "shift PAGE_UP", "scrollUpExtendSelection",
1078                "ctrl shift PAGE_UP", "scrollUpExtendSelection",
1079                      "ctrl PAGE_UP", "scrollUpChangeLead",
1080                         "PAGE_DOWN", "scrollDown",
1081                   "shift PAGE_DOWN", "scrollDownExtendSelection",
1082              "ctrl shift PAGE_DOWN", "scrollDownExtendSelection",
1083                    "ctrl PAGE_DOWN", "scrollDownChangeLead",
1084                            "ctrl A", "selectAll",
1085                        "ctrl SLASH", "selectAll",
1086                   "ctrl BACK_SLASH", "clearSelection",
1087                             "SPACE", "addToSelection",
1088                        "ctrl SPACE", "toggleAndAnchor",
1089                       "shift SPACE", "extendTo",
1090                  "ctrl shift SPACE", "moveSelectionTo"
1091                  }),
1092 
1093             // ScrollBar
1094             "ScrollBar.background", control,
1095             "ScrollBar.highlight", controlHighlight,
1096             "ScrollBar.shadow", controlShadow,
1097             "ScrollBar.darkShadow", controlDarkShadow,
1098             "ScrollBar.thumb", primaryControlShadow,
1099             "ScrollBar.thumbShadow", primaryControlDarkShadow,
1100             "ScrollBar.thumbHighlight", primaryControl,
1101             "ScrollBar.width", new Integer( 17 ),
1102             "ScrollBar.allowsAbsolutePositioning", Boolean.TRUE,
1103             "ScrollBar.ancestorInputMap",
1104                new UIDefaults.LazyInputMap(new Object[] {
1105                        "RIGHT", "positiveUnitIncrement",
1106                     "KP_RIGHT", "positiveUnitIncrement",
1107                         "DOWN", "positiveUnitIncrement",
1108                      "KP_DOWN", "positiveUnitIncrement",
1109                    "PAGE_DOWN", "positiveBlockIncrement",
1110                         "LEFT", "negativeUnitIncrement",
1111                      "KP_LEFT", "negativeUnitIncrement",
1112                           "UP", "negativeUnitIncrement",
1113                        "KP_UP", "negativeUnitIncrement",
1114                      "PAGE_UP", "negativeBlockIncrement",
1115                         "HOME", "minScroll",
1116                          "END", "maxScroll"
1117                  }),
1118 
1119             // ScrollPane
1120             "ScrollPane.border", scrollPaneBorder,
1121             "ScrollPane.ancestorInputMap",
1122                new UIDefaults.LazyInputMap(new Object[] {
1123                            "RIGHT", "unitScrollRight",
1124                         "KP_RIGHT", "unitScrollRight",
1125                             "DOWN", "unitScrollDown",
1126                          "KP_DOWN", "unitScrollDown",
1127                             "LEFT", "unitScrollLeft",
1128                          "KP_LEFT", "unitScrollLeft",
1129                               "UP", "unitScrollUp",
1130                            "KP_UP", "unitScrollUp",
1131                          "PAGE_UP", "scrollUp",
1132                        "PAGE_DOWN", "scrollDown",
1133                     "ctrl PAGE_UP", "scrollLeft",
1134                   "ctrl PAGE_DOWN", "scrollRight",
1135                        "ctrl HOME", "scrollHome",
1136                         "ctrl END", "scrollEnd"
1137                  }),
1138 
1139             // Tabbed Pane
1140             "TabbedPane.font", controlTextValue,
1141             "TabbedPane.tabAreaBackground", control,
1142             "TabbedPane.background", controlShadow,
1143             "TabbedPane.light", control,
1144             "TabbedPane.focus", primaryControlDarkShadow,
1145             "TabbedPane.selected", control,
1146             "TabbedPane.selectHighlight", controlHighlight,
1147             "TabbedPane.tabAreaInsets", tabbedPaneTabAreaInsets,
1148             "TabbedPane.tabInsets", tabbedPaneTabInsets,
1149             "TabbedPane.focusInputMap",
1150               new UIDefaults.LazyInputMap(new Object[] {
1151                          "RIGHT", "navigateRight",
1152                       "KP_RIGHT", "navigateRight",
1153                           "LEFT", "navigateLeft",
1154                        "KP_LEFT", "navigateLeft",
1155                             "UP", "navigateUp",
1156                          "KP_UP", "navigateUp",
1157                           "DOWN", "navigateDown",
1158                        "KP_DOWN", "navigateDown",
1159                      "ctrl DOWN", "requestFocusForVisibleComponent",
1160                   "ctrl KP_DOWN", "requestFocusForVisibleComponent",
1161                 }),
1162             "TabbedPane.ancestorInputMap",
1163                new UIDefaults.LazyInputMap(new Object[] {
1164                    "ctrl PAGE_DOWN", "navigatePageDown",
1165                      "ctrl PAGE_UP", "navigatePageUp",
1166                           "ctrl UP", "requestFocus",
1167                        "ctrl KP_UP", "requestFocus",
1168                  }),
1169 
1170             // Table
1171             "Table.font", userTextValue,
1172             "Table.focusCellHighlightBorder", focusCellHighlightBorder,
1173             "Table.scrollPaneBorder", scrollPaneBorder,
1174             "Table.dropLineColor", focusColor,
1175             "Table.dropLineShortColor", primaryControlDarkShadow,
1176             "Table.gridColor", controlShadow,  // grid line color
1177             "Table.ancestorInputMap",
1178                new UIDefaults.LazyInputMap(new Object[] {
1179                                "ctrl C", "copy",
1180                                "ctrl V", "paste",
1181                                "ctrl X", "cut",
1182                                  "COPY", "copy",
1183                                 "PASTE", "paste",
1184                                   "CUT", "cut",
1185                        "control INSERT", "copy",
1186                          "shift INSERT", "paste",
1187                          "shift DELETE", "cut",
1188                                 "RIGHT", "selectNextColumn",
1189                              "KP_RIGHT", "selectNextColumn",
1190                           "shift RIGHT", "selectNextColumnExtendSelection",
1191                        "shift KP_RIGHT", "selectNextColumnExtendSelection",
1192                      "ctrl shift RIGHT", "selectNextColumnExtendSelection",
1193                   "ctrl shift KP_RIGHT", "selectNextColumnExtendSelection",
1194                            "ctrl RIGHT", "selectNextColumnChangeLead",
1195                         "ctrl KP_RIGHT", "selectNextColumnChangeLead",
1196                                  "LEFT", "selectPreviousColumn",
1197                               "KP_LEFT", "selectPreviousColumn",
1198                            "shift LEFT", "selectPreviousColumnExtendSelection",
1199                         "shift KP_LEFT", "selectPreviousColumnExtendSelection",
1200                       "ctrl shift LEFT", "selectPreviousColumnExtendSelection",
1201                    "ctrl shift KP_LEFT", "selectPreviousColumnExtendSelection",
1202                             "ctrl LEFT", "selectPreviousColumnChangeLead",
1203                          "ctrl KP_LEFT", "selectPreviousColumnChangeLead",
1204                                  "DOWN", "selectNextRow",
1205                               "KP_DOWN", "selectNextRow",
1206                            "shift DOWN", "selectNextRowExtendSelection",
1207                         "shift KP_DOWN", "selectNextRowExtendSelection",
1208                       "ctrl shift DOWN", "selectNextRowExtendSelection",
1209                    "ctrl shift KP_DOWN", "selectNextRowExtendSelection",
1210                             "ctrl DOWN", "selectNextRowChangeLead",
1211                          "ctrl KP_DOWN", "selectNextRowChangeLead",
1212                                    "UP", "selectPreviousRow",
1213                                 "KP_UP", "selectPreviousRow",
1214                              "shift UP", "selectPreviousRowExtendSelection",
1215                           "shift KP_UP", "selectPreviousRowExtendSelection",
1216                         "ctrl shift UP", "selectPreviousRowExtendSelection",
1217                      "ctrl shift KP_UP", "selectPreviousRowExtendSelection",
1218                               "ctrl UP", "selectPreviousRowChangeLead",
1219                            "ctrl KP_UP", "selectPreviousRowChangeLead",
1220                                  "HOME", "selectFirstColumn",
1221                            "shift HOME", "selectFirstColumnExtendSelection",
1222                       "ctrl shift HOME", "selectFirstRowExtendSelection",
1223                             "ctrl HOME", "selectFirstRow",
1224                                   "END", "selectLastColumn",
1225                             "shift END", "selectLastColumnExtendSelection",
1226                        "ctrl shift END", "selectLastRowExtendSelection",
1227                              "ctrl END", "selectLastRow",
1228                               "PAGE_UP", "scrollUpChangeSelection",
1229                         "shift PAGE_UP", "scrollUpExtendSelection",
1230                    "ctrl shift PAGE_UP", "scrollLeftExtendSelection",
1231                          "ctrl PAGE_UP", "scrollLeftChangeSelection",
1232                             "PAGE_DOWN", "scrollDownChangeSelection",
1233                       "shift PAGE_DOWN", "scrollDownExtendSelection",
1234                  "ctrl shift PAGE_DOWN", "scrollRightExtendSelection",
1235                        "ctrl PAGE_DOWN", "scrollRightChangeSelection",
1236                                   "TAB", "selectNextColumnCell",
1237                             "shift TAB", "selectPreviousColumnCell",
1238                                 "ENTER", "selectNextRowCell",
1239                           "shift ENTER", "selectPreviousRowCell",
1240                                "ctrl A", "selectAll",
1241                            "ctrl SLASH", "selectAll",
1242                       "ctrl BACK_SLASH", "clearSelection",
1243                                "ESCAPE", "cancel",
1244                                    "F2", "startEditing",
1245                                 "SPACE", "addToSelection",
1246                            "ctrl SPACE", "toggleAndAnchor",
1247                           "shift SPACE", "extendTo",
1248                      "ctrl shift SPACE", "moveSelectionTo",
1249                                    "F8", "focusHeader"
1250                  }),
1251             "Table.ascendingSortIcon",
1252                 SwingUtilities2.makeIcon(getClass(), MetalLookAndFeel.class,
1253                 "icons/sortUp.png"),
1254             "Table.descendingSortIcon",
1255                 SwingUtilities2.makeIcon(getClass(), MetalLookAndFeel.class,
1256                 "icons/sortDown.png"),
1257 
1258             "TableHeader.font", userTextValue,
1259             "TableHeader.cellBorder", new SwingLazyValue(
1260                                           "javax.swing.plaf.metal.MetalBorders$TableHeaderBorder"),
1261 
1262             // MenuBar
1263             "MenuBar.border", menuBarBorder,
1264             "MenuBar.font", menuTextValue,
1265             "MenuBar.windowBindings", new Object[] {
1266                 "F10", "takeFocus" },
1267 
1268             // Menu
1269             "Menu.border", menuItemBorder,
1270             "Menu.borderPainted", Boolean.TRUE,
1271             "Menu.menuPopupOffsetX", zero,
1272             "Menu.menuPopupOffsetY", zero,
1273             "Menu.submenuPopupOffsetX", new Integer(-4),
1274             "Menu.submenuPopupOffsetY", new Integer(-3),
1275             "Menu.font", menuTextValue,
1276             "Menu.selectionForeground", menuSelectedForeground,
1277             "Menu.selectionBackground", menuSelectedBackground,
1278             "Menu.disabledForeground", menuDisabledForeground,
1279             "Menu.acceleratorFont", subTextValue,
1280             "Menu.acceleratorForeground", acceleratorForeground,
1281             "Menu.acceleratorSelectionForeground", acceleratorSelectedForeground,
1282             "Menu.checkIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getMenuItemCheckIcon"),
1283             "Menu.arrowIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getMenuArrowIcon"),
1284 
1285             // Menu Item
1286             "MenuItem.border", menuItemBorder,
1287             "MenuItem.borderPainted", Boolean.TRUE,
1288             "MenuItem.font", menuTextValue,
1289             "MenuItem.selectionForeground", menuSelectedForeground,
1290             "MenuItem.selectionBackground", menuSelectedBackground,
1291             "MenuItem.disabledForeground", menuDisabledForeground,
1292             "MenuItem.acceleratorFont", subTextValue,
1293             "MenuItem.acceleratorForeground", acceleratorForeground,
1294             "MenuItem.acceleratorSelectionForeground", acceleratorSelectedForeground,
1295             "MenuItem.acceleratorDelimiter", menuItemAcceleratorDelimiter,
1296             "MenuItem.checkIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getMenuItemCheckIcon"),
1297             "MenuItem.arrowIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getMenuItemArrowIcon"),
1298                  // Menu Item Auditory Cue Mapping
1299             "MenuItem.commandSound", "sounds/MenuItemCommand.wav",
1300 
1301             // OptionPane.
1302             "OptionPane.windowBindings", new Object[] {
1303                 "ESCAPE", "close" },
1304             // Option Pane Auditory Cue Mappings
1305             "OptionPane.informationSound", "sounds/OptionPaneInformation.wav",
1306             "OptionPane.warningSound", "sounds/OptionPaneWarning.wav",
1307             "OptionPane.errorSound", "sounds/OptionPaneError.wav",
1308             "OptionPane.questionSound", "sounds/OptionPaneQuestion.wav",
1309 
1310             // Option Pane Special Dialog Colors, used when MetalRootPaneUI
1311             // is providing window manipulation widgets.
1312             "OptionPane.errorDialog.border.background",
1313                         new ColorUIResource(153, 51, 51),
1314             "OptionPane.errorDialog.titlePane.foreground",
1315                         new ColorUIResource(51, 0, 0),
1316             "OptionPane.errorDialog.titlePane.background",
1317                         new ColorUIResource(255, 153, 153),
1318             "OptionPane.errorDialog.titlePane.shadow",
1319                         new ColorUIResource(204, 102, 102),
1320             "OptionPane.questionDialog.border.background",
1321                         new ColorUIResource(51, 102, 51),
1322             "OptionPane.questionDialog.titlePane.foreground",
1323                         new ColorUIResource(0, 51, 0),
1324             "OptionPane.questionDialog.titlePane.background",
1325                         new ColorUIResource(153, 204, 153),
1326             "OptionPane.questionDialog.titlePane.shadow",
1327                         new ColorUIResource(102, 153, 102),
1328             "OptionPane.warningDialog.border.background",
1329                         new ColorUIResource(153, 102, 51),
1330             "OptionPane.warningDialog.titlePane.foreground",
1331                         new ColorUIResource(102, 51, 0),
1332             "OptionPane.warningDialog.titlePane.background",
1333                         new ColorUIResource(255, 204, 153),
1334             "OptionPane.warningDialog.titlePane.shadow",
1335                         new ColorUIResource(204, 153, 102),
1336             // OptionPane fonts are defined below
1337 
1338             // Separator
1339             "Separator.background", getSeparatorBackground(),
1340             "Separator.foreground", getSeparatorForeground(),
1341 
1342             // Popup Menu
1343             "PopupMenu.border", popupMenuBorder,
1344                  // Popup Menu Auditory Cue Mappings
1345             "PopupMenu.popupSound", "sounds/PopupMenuPopup.wav",
1346             "PopupMenu.font", menuTextValue,
1347 
1348             // CB & RB Menu Item
1349             "CheckBoxMenuItem.border", menuItemBorder,
1350             "CheckBoxMenuItem.borderPainted", Boolean.TRUE,
1351             "CheckBoxMenuItem.font", menuTextValue,
1352             "CheckBoxMenuItem.selectionForeground", menuSelectedForeground,
1353             "CheckBoxMenuItem.selectionBackground", menuSelectedBackground,
1354             "CheckBoxMenuItem.disabledForeground", menuDisabledForeground,
1355             "CheckBoxMenuItem.acceleratorFont", subTextValue,
1356             "CheckBoxMenuItem.acceleratorForeground", acceleratorForeground,
1357             "CheckBoxMenuItem.acceleratorSelectionForeground", acceleratorSelectedForeground,
1358             "CheckBoxMenuItem.checkIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getCheckBoxMenuItemIcon"),
1359             "CheckBoxMenuItem.arrowIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getMenuItemArrowIcon"),
1360             "CheckBoxMenuItem.commandSound", "sounds/MenuItemCommand.wav",
1361 
1362             "RadioButtonMenuItem.border", menuItemBorder,
1363             "RadioButtonMenuItem.borderPainted", Boolean.TRUE,
1364             "RadioButtonMenuItem.font", menuTextValue,
1365             "RadioButtonMenuItem.selectionForeground", menuSelectedForeground,
1366             "RadioButtonMenuItem.selectionBackground", menuSelectedBackground,
1367             "RadioButtonMenuItem.disabledForeground", menuDisabledForeground,
1368             "RadioButtonMenuItem.acceleratorFont", subTextValue,
1369             "RadioButtonMenuItem.acceleratorForeground", acceleratorForeground,
1370             "RadioButtonMenuItem.acceleratorSelectionForeground", acceleratorSelectedForeground,
1371             "RadioButtonMenuItem.checkIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getRadioButtonMenuItemIcon"),
1372             "RadioButtonMenuItem.arrowIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getMenuItemArrowIcon"),
1373             "RadioButtonMenuItem.commandSound", "sounds/MenuItemCommand.wav",
1374 
1375             "Spinner.ancestorInputMap",
1376                new UIDefaults.LazyInputMap(new Object[] {
1377                                "UP", "increment",
1378                             "KP_UP", "increment",
1379                              "DOWN", "decrement",
1380                           "KP_DOWN", "decrement",
1381                }),
1382             "Spinner.arrowButtonInsets", zeroInsets,
1383             "Spinner.border", textFieldBorder,
1384             "Spinner.arrowButtonBorder", buttonBorder,
1385             "Spinner.font", controlTextValue,
1386 
1387             // SplitPane
1388 
1389             "SplitPane.dividerSize", new Integer(10),
1390             "SplitPane.ancestorInputMap",
1391                new UIDefaults.LazyInputMap(new Object[] {
1392                         "UP", "negativeIncrement",
1393                       "DOWN", "positiveIncrement",
1394                       "LEFT", "negativeIncrement",
1395                      "RIGHT", "positiveIncrement",
1396                      "KP_UP", "negativeIncrement",
1397                    "KP_DOWN", "positiveIncrement",
1398                    "KP_LEFT", "negativeIncrement",
1399                   "KP_RIGHT", "positiveIncrement",
1400                       "HOME", "selectMin",
1401                        "END", "selectMax",
1402                         "F8", "startResize",
1403                         "F6", "toggleFocus",
1404                   "ctrl TAB", "focusOutForward",
1405             "ctrl shift TAB", "focusOutBackward"
1406                  }),
1407             "SplitPane.centerOneTouchButtons", Boolean.FALSE,
1408             "SplitPane.dividerFocusColor", primaryControl,
1409 
1410             // Tree
1411             // Tree.font was mapped to system font pre 1.4.1
1412             "Tree.font", userTextValue,
1413             "Tree.textBackground", getWindowBackground(),
1414             "Tree.selectionBorderColor", focusColor,
1415             "Tree.openIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getTreeFolderIcon"),
1416             "Tree.closedIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getTreeFolderIcon"),
1417             "Tree.leafIcon", new SwingLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getTreeLeafIcon"),
1418             "Tree.expandedIcon", new SwingLazyValue(
1419                                      "javax.swing.plaf.metal.MetalIconFactory",
1420                                      "getTreeControlIcon",
1421                                      new Object[] {Boolean.valueOf(MetalIconFactory.DARK)}),
1422             "Tree.collapsedIcon", new SwingLazyValue(
1423                                      "javax.swing.plaf.metal.MetalIconFactory",
1424                                      "getTreeControlIcon",
1425                                      new Object[] {Boolean.valueOf( MetalIconFactory.LIGHT )}),
1426 
1427             "Tree.line", primaryControl, // horiz lines
1428             "Tree.hash", primaryControl,  // legs
1429             "Tree.rowHeight", zero,
1430             "Tree.focusInputMap",
1431                new UIDefaults.LazyInputMap(new Object[] {
1432                                     "ADD", "expand",
1433                                "SUBTRACT", "collapse",
1434                                  "ctrl C", "copy",
1435                                  "ctrl V", "paste",
1436                                  "ctrl X", "cut",
1437                                    "COPY", "copy",
1438                                   "PASTE", "paste",
1439                                     "CUT", "cut",
1440                          "control INSERT", "copy",
1441                            "shift INSERT", "paste",
1442                            "shift DELETE", "cut",
1443                                      "UP", "selectPrevious",
1444                                   "KP_UP", "selectPrevious",
1445                                "shift UP", "selectPreviousExtendSelection",
1446                             "shift KP_UP", "selectPreviousExtendSelection",
1447                           "ctrl shift UP", "selectPreviousExtendSelection",
1448                        "ctrl shift KP_UP", "selectPreviousExtendSelection",
1449                                 "ctrl UP", "selectPreviousChangeLead",
1450                              "ctrl KP_UP", "selectPreviousChangeLead",
1451                                    "DOWN", "selectNext",
1452                                 "KP_DOWN", "selectNext",
1453                              "shift DOWN", "selectNextExtendSelection",
1454                           "shift KP_DOWN", "selectNextExtendSelection",
1455                         "ctrl shift DOWN", "selectNextExtendSelection",
1456                      "ctrl shift KP_DOWN", "selectNextExtendSelection",
1457                               "ctrl DOWN", "selectNextChangeLead",
1458                            "ctrl KP_DOWN", "selectNextChangeLead",
1459                                   "RIGHT", "selectChild",
1460                                "KP_RIGHT", "selectChild",
1461                                    "LEFT", "selectParent",
1462                                 "KP_LEFT", "selectParent",
1463                                 "PAGE_UP", "scrollUpChangeSelection",
1464                           "shift PAGE_UP", "scrollUpExtendSelection",
1465                      "ctrl shift PAGE_UP", "scrollUpExtendSelection",
1466                            "ctrl PAGE_UP", "scrollUpChangeLead",
1467                               "PAGE_DOWN", "scrollDownChangeSelection",
1468                         "shift PAGE_DOWN", "scrollDownExtendSelection",
1469                    "ctrl shift PAGE_DOWN", "scrollDownExtendSelection",
1470                          "ctrl PAGE_DOWN", "scrollDownChangeLead",
1471                                    "HOME", "selectFirst",
1472                              "shift HOME", "selectFirstExtendSelection",
1473                         "ctrl shift HOME", "selectFirstExtendSelection",
1474                               "ctrl HOME", "selectFirstChangeLead",
1475                                     "END", "selectLast",
1476                               "shift END", "selectLastExtendSelection",
1477                          "ctrl shift END", "selectLastExtendSelection",
1478                                "ctrl END", "selectLastChangeLead",
1479                                      "F2", "startEditing",
1480                                  "ctrl A", "selectAll",
1481                              "ctrl SLASH", "selectAll",
1482                         "ctrl BACK_SLASH", "clearSelection",
1483                               "ctrl LEFT", "scrollLeft",
1484                            "ctrl KP_LEFT", "scrollLeft",
1485                              "ctrl RIGHT", "scrollRight",
1486                           "ctrl KP_RIGHT", "scrollRight",
1487                                   "SPACE", "addToSelection",
1488                              "ctrl SPACE", "toggleAndAnchor",
1489                             "shift SPACE", "extendTo",
1490                        "ctrl shift SPACE", "moveSelectionTo"
1491                  }),
1492             "Tree.ancestorInputMap",
1493                new UIDefaults.LazyInputMap(new Object[] {
1494                      "ESCAPE", "cancel"
1495                  }),
1496 
1497             // ToolBar
1498             "ToolBar.border", toolBarBorder,
1499             "ToolBar.background", menuBackground,
1500             "ToolBar.foreground", getMenuForeground(),
1501             "ToolBar.font", menuTextValue,
1502             "ToolBar.dockingBackground", menuBackground,
1503             "ToolBar.floatingBackground", menuBackground,
1504             "ToolBar.dockingForeground", primaryControlDarkShadow,
1505             "ToolBar.floatingForeground", primaryControl,
1506             "ToolBar.rolloverBorder", new MetalLazyValue(
1507                          "javax.swing.plaf.metal.MetalBorders",
1508                          "getToolBarRolloverBorder"),
1509             "ToolBar.nonrolloverBorder", new MetalLazyValue(
1510                          "javax.swing.plaf.metal.MetalBorders",
1511                          "getToolBarNonrolloverBorder"),
1512             "ToolBar.ancestorInputMap",
1513                new UIDefaults.LazyInputMap(new Object[] {
1514                         "UP", "navigateUp",
1515                      "KP_UP", "navigateUp",
1516                       "DOWN", "navigateDown",
1517                    "KP_DOWN", "navigateDown",
1518                       "LEFT", "navigateLeft",
1519                    "KP_LEFT", "navigateLeft",
1520                      "RIGHT", "navigateRight",
1521                   "KP_RIGHT", "navigateRight"
1522                  }),
1523 
1524             // RootPane
1525             "RootPane.frameBorder", new MetalLazyValue(
1526                       "javax.swing.plaf.metal.MetalBorders$FrameBorder"),
1527             "RootPane.plainDialogBorder", dialogBorder,
1528             "RootPane.informationDialogBorder", dialogBorder,
1529             "RootPane.errorDialogBorder", new MetalLazyValue(
1530                       "javax.swing.plaf.metal.MetalBorders$ErrorDialogBorder"),
1531             "RootPane.colorChooserDialogBorder", questionDialogBorder,
1532             "RootPane.fileChooserDialogBorder", questionDialogBorder,
1533             "RootPane.questionDialogBorder", questionDialogBorder,
1534             "RootPane.warningDialogBorder", new MetalLazyValue(
1535                     "javax.swing.plaf.metal.MetalBorders$WarningDialogBorder"),
1536             // These bindings are only enabled when there is a default
1537             // button set on the rootpane.
1538             "RootPane.defaultButtonWindowKeyBindings", new Object[] {
1539                              "ENTER", "press",
1540                     "released ENTER", "release",
1541                         "ctrl ENTER", "press",
1542                "ctrl released ENTER", "release"
1543               },
1544         };
1545 
1546         table.putDefaults(defaults);
1547 
1548         if (isWindows() && useSystemFonts() && theme.isSystemTheme()) {
1549             Toolkit kit = Toolkit.getDefaultToolkit();
1550             Object messageFont = new MetalFontDesktopProperty(
1551                               "win.messagebox.font.height", kit, MetalTheme.
1552                               CONTROL_TEXT_FONT);
1553 
1554             defaults = new Object[] {
1555                 "OptionPane.messageFont", messageFont,
1556                 "OptionPane.buttonFont", messageFont,
1557             };
1558             table.putDefaults(defaults);
1559         }
1560 
1561         flushUnreferenced(); // Remove old listeners
1562 
1563         boolean lafCond = SwingUtilities2.isLocalDisplay();
1564         Object aaTextInfo = SwingUtilities2.AATextInfo.getAATextInfo(lafCond);
1565         table.put(SwingUtilities2.AA_TEXT_PROPERTY_KEY, aaTextInfo);
1566         new AATextListener(this);
1567     }
1568 
1569     /**
1570      * Ensures the current {@code MetalTheme} is {@code non-null}. This is
1571      * a cover method for {@code getCurrentTheme}.
1572      *
1573      * @see #getCurrentTheme
1574      */
1575     protected void createDefaultTheme() {
1576         getCurrentTheme();
1577     }
1578 
1579     /**
1580      * Returns the look and feel defaults. This invokes, in order,
1581      * {@code createDefaultTheme()}, {@code super.getDefaults()} and
1582      * {@code getCurrentTheme().addCustomEntriesToTable(table)}.
1583      * <p>
1584      * While this method is public, it should only be invoked by the
1585      * {@code UIManager} when the look and feel is set as the current
1586      * look and feel and after {@code initialize} has been invoked.
1587      *
1588      * @return the look and feel defaults
1589      *
1590      * @see #createDefaultTheme
1591      * @see javax.swing.plaf.basic.BasicLookAndFeel#getDefaults()
1592      * @see MetalTheme#addCustomEntriesToTable(UIDefaults)
1593      */
1594     public UIDefaults getDefaults() {
1595         // PENDING: move this to initialize when API changes are allowed
1596         METAL_LOOK_AND_FEEL_INITED = true;
1597 
1598         createDefaultTheme();
1599         UIDefaults table = super.getDefaults();
1600         currentTheme.addCustomEntriesToTable(table);
1601         currentTheme.install();
1602         return table;
1603     }
1604 
1605     /**
1606      * {@inheritDoc}
1607      *
1608      * @since 1.4
1609      */
1610     public void provideErrorFeedback(Component component) {
1611         super.provideErrorFeedback(component);
1612     }
1613 
1614     /**
1615      * Set the theme used by <code>MetalLookAndFeel</code>.
1616      * <p>
1617      * After the theme is set, {@code MetalLookAndFeel} needs to be
1618      * re-installed and the uis need to be recreated. The following
1619      * shows how to do this:
1620      * <pre>
1621      *   MetalLookAndFeel.setCurrentTheme(theme);
1622      *
1623      *   // re-install the Metal Look and Feel
1624      *   UIManager.setLookAndFeel(new MetalLookAndFeel());
1625      *
1626      *   // Update the ComponentUIs for all Components. This
1627      *   // needs to be invoked for all windows.
1628      *   SwingUtilities.updateComponentTreeUI(rootComponent);
1629      * </pre>
1630      * If this is not done the results are undefined.
1631      *
1632      * @param theme the theme to use
1633      * @throws NullPointerException if {@code theme} is {@code null}
1634      * @see #getCurrentTheme
1635      */
1636     public static void setCurrentTheme(MetalTheme theme) {
1637         // NOTE: because you need to recreate the look and feel after
1638         // this step, we don't bother blowing away any potential windows
1639         // values.
1640         if (theme == null) {
1641             throw new NullPointerException("Can't have null theme");
1642         }
1643         currentTheme = theme;
1644         cachedAppContext = AppContext.getAppContext();
1645         cachedAppContext.put( "currentMetalTheme", theme );
1646     }
1647 
1648     /**
1649      * Return the theme currently being used by <code>MetalLookAndFeel</code>.
1650      * If the current theme is {@code null}, the default theme is created.
1651      *
1652      * @return the current theme
1653      * @see #setCurrentTheme
1654      * @since 1.5
1655      */
1656     public static MetalTheme getCurrentTheme() {
1657         AppContext context = AppContext.getAppContext();
1658 
1659         if ( cachedAppContext != context ) {
1660             currentTheme = (MetalTheme)context.get( "currentMetalTheme" );
1661             if (currentTheme == null) {
1662                 // This will happen in two cases:
1663                 // . When MetalLookAndFeel is first being initialized.
1664                 // . When a new AppContext has been created that hasn't
1665                 //   triggered UIManager to load a LAF. Rather than invoke
1666                 //   a method on the UIManager, which would trigger the loading
1667                 //   of a potentially different LAF, we directly set the
1668                 //   Theme here.
1669                 if (useHighContrastTheme()) {
1670                     currentTheme = new MetalHighContrastTheme();
1671                 }
1672                 else {
1673                     // Create the default theme. We prefer Ocean, but will
1674                     // use DefaultMetalTheme if told to.
1675                     String theme = AccessController.doPrivileged(
1676                                    new GetPropertyAction("swing.metalTheme"));
1677                     if ("steel".equals(theme)) {
1678                         currentTheme = new DefaultMetalTheme();
1679                     }
1680                     else {
1681                         currentTheme = new OceanTheme();
1682                     }
1683                 }
1684                 setCurrentTheme(currentTheme);
1685             }
1686             cachedAppContext = context;
1687         }
1688 
1689         return currentTheme;
1690     }
1691 
1692     /**
1693      * Returns an <code>Icon</code> with a disabled appearance.
1694      * This method is used to generate a disabled <code>Icon</code> when
1695      * one has not been specified.  For example, if you create a
1696      * <code>JButton</code> and only specify an <code>Icon</code> via
1697      * <code>setIcon</code> this method will be called to generate the
1698      * disabled <code>Icon</code>. If null is passed as <code>icon</code>
1699      * this method returns null.
1700      * <p>
1701      * Some look and feels might not render the disabled Icon, in which
1702      * case they will ignore this.
1703      *
1704      * @param component JComponent that will display the Icon, may be null
1705      * @param icon Icon to generate disable icon from.
1706      * @return Disabled icon, or null if a suitable Icon can not be
1707      *         generated.
1708      * @since 1.5
1709      */
1710     public Icon getDisabledIcon(JComponent component, Icon icon) {
1711         if ((icon instanceof ImageIcon) && MetalLookAndFeel.usingOcean()) {
1712             return MetalUtils.getOceanDisabledButtonIcon(
1713                                   ((ImageIcon)icon).getImage());
1714         }
1715         return super.getDisabledIcon(component, icon);
1716     }
1717 
1718     /**
1719      * Returns an <code>Icon</code> for use by disabled
1720      * components that are also selected. This method is used to generate an
1721      * <code>Icon</code> for components that are in both the disabled and
1722      * selected states but do not have a specific <code>Icon</code> for this
1723      * state.  For example, if you create a <code>JButton</code> and only
1724      * specify an <code>Icon</code> via <code>setIcon</code> this method
1725      * will be called to generate the disabled and selected
1726      * <code>Icon</code>. If null is passed as <code>icon</code> this method
1727      * returns null.
1728      * <p>
1729      * Some look and feels might not render the disabled and selected Icon,
1730      * in which case they will ignore this.
1731      *
1732      * @param component JComponent that will display the Icon, may be null
1733      * @param icon Icon to generate disabled and selected icon from.
1734      * @return Disabled and Selected icon, or null if a suitable Icon can not
1735      *         be generated.
1736      * @since 1.5
1737      */
1738     public Icon getDisabledSelectedIcon(JComponent component, Icon icon) {
1739         if ((icon instanceof ImageIcon) && MetalLookAndFeel.usingOcean()) {
1740             return MetalUtils.getOceanDisabledButtonIcon(
1741                                   ((ImageIcon)icon).getImage());
1742         }
1743         return super.getDisabledSelectedIcon(component, icon);
1744     }
1745 
1746     /**
1747      * Returns the control text font of the current theme. This is a
1748      * cover method for {@code getCurrentTheme().getControlTextColor()}.
1749      *
1750      * @return the control text font
1751      *
1752      * @see MetalTheme
1753      */
1754     public static FontUIResource getControlTextFont() { return getCurrentTheme().getControlTextFont();}
1755 
1756     /**
1757      * Returns the sytem text font of the current theme. This is a
1758      * cover method for {@code getCurrentTheme().getSystemTextFont()}.
1759      *
1760      * @return the system text font
1761      *
1762      * @see MetalTheme
1763      */
1764     public static FontUIResource getSystemTextFont() { return getCurrentTheme().getSystemTextFont();}
1765 
1766     /**
1767      * Returns the user text font of the current theme. This is a
1768      * cover method for {@code getCurrentTheme().getUserTextFont()}.
1769      *
1770      * @return the user text font
1771      *
1772      * @see MetalTheme
1773      */
1774     public static FontUIResource getUserTextFont() { return getCurrentTheme().getUserTextFont();}
1775 
1776     /**
1777      * Returns the menu text font of the current theme. This is a
1778      * cover method for {@code getCurrentTheme().getMenuTextFont()}.
1779      *
1780      * @return the menu text font
1781      *
1782      * @see MetalTheme
1783      */
1784     public static FontUIResource getMenuTextFont() { return getCurrentTheme().getMenuTextFont();}
1785 
1786     /**
1787      * Returns the window title font of the current theme. This is a
1788      * cover method for {@code getCurrentTheme().getWindowTitleFont()}.
1789      *
1790      * @return the window title font
1791      *
1792      * @see MetalTheme
1793      */
1794     public static FontUIResource getWindowTitleFont() { return getCurrentTheme().getWindowTitleFont();}
1795 
1796     /**
1797      * Returns the sub-text font of the current theme. This is a
1798      * cover method for {@code getCurrentTheme().getSubTextFont()}.
1799      *
1800      * @return the sub-text font
1801      *
1802      * @see MetalTheme
1803      */
1804     public static FontUIResource getSubTextFont() { return getCurrentTheme().getSubTextFont();}
1805 
1806     /**
1807      * Returns the desktop color of the current theme. This is a
1808      * cover method for {@code getCurrentTheme().getDesktopColor()}.
1809      *
1810      * @return the desktop color
1811      *
1812      * @see MetalTheme
1813      */
1814     public static ColorUIResource getDesktopColor() { return getCurrentTheme().getDesktopColor(); }
1815 
1816     /**
1817      * Returns the focus color of the current theme. This is a
1818      * cover method for {@code getCurrentTheme().getFocusColor()}.
1819      *
1820      * @return the focus color
1821      *
1822      * @see MetalTheme
1823      */
1824     public static ColorUIResource getFocusColor() { return getCurrentTheme().getFocusColor(); }
1825 
1826     /**
1827      * Returns the white color of the current theme. This is a
1828      * cover method for {@code getCurrentTheme().getWhite()}.
1829      *
1830      * @return the white color
1831      *
1832      * @see MetalTheme
1833      */
1834     public static ColorUIResource getWhite() { return getCurrentTheme().getWhite(); }
1835 
1836     /**
1837      * Returns the black color of the current theme. This is a
1838      * cover method for {@code getCurrentTheme().getBlack()}.
1839      *
1840      * @return the black color
1841      *
1842      * @see MetalTheme
1843      */
1844     public static ColorUIResource getBlack() { return getCurrentTheme().getBlack(); }
1845 
1846     /**
1847      * Returns the control color of the current theme. This is a
1848      * cover method for {@code getCurrentTheme().getControl()}.
1849      *
1850      * @return the control color
1851      *
1852      * @see MetalTheme
1853      */
1854     public static ColorUIResource getControl() { return getCurrentTheme().getControl(); }
1855 
1856     /**
1857      * Returns the control shadow color of the current theme. This is a
1858      * cover method for {@code getCurrentTheme().getControlShadow()}.
1859      *
1860      * @return the control shadow color
1861      *
1862      * @see MetalTheme
1863      */
1864     public static ColorUIResource getControlShadow() { return getCurrentTheme().getControlShadow(); }
1865 
1866     /**
1867      * Returns the control dark shadow color of the current theme. This is a
1868      * cover method for {@code getCurrentTheme().getControlDarkShadow()}.
1869      *
1870      * @return the control dark shadow color
1871      *
1872      * @see MetalTheme
1873      */
1874     public static ColorUIResource getControlDarkShadow() { return getCurrentTheme().getControlDarkShadow(); }
1875 
1876     /**
1877      * Returns the control info color of the current theme. This is a
1878      * cover method for {@code getCurrentTheme().getControlInfo()}.
1879      *
1880      * @return the control info color
1881      *
1882      * @see MetalTheme
1883      */
1884     public static ColorUIResource getControlInfo() { return getCurrentTheme().getControlInfo(); }
1885 
1886     /**
1887      * Returns the control highlight color of the current theme. This is a
1888      * cover method for {@code getCurrentTheme().getControlHighlight()}.
1889      *
1890      * @return the control highlight color
1891      *
1892      * @see MetalTheme
1893      */
1894     public static ColorUIResource getControlHighlight() { return getCurrentTheme().getControlHighlight(); }
1895 
1896     /**
1897      * Returns the control disabled color of the current theme. This is a
1898      * cover method for {@code getCurrentTheme().getControlDisabled()}.
1899      *
1900      * @return the control disabled color
1901      *
1902      * @see MetalTheme
1903      */
1904     public static ColorUIResource getControlDisabled() { return getCurrentTheme().getControlDisabled(); }
1905 
1906     /**
1907      * Returns the primary control color of the current theme. This is a
1908      * cover method for {@code getCurrentTheme().getPrimaryControl()}.
1909      *
1910      * @return the primary control color
1911      *
1912      * @see MetalTheme
1913      */
1914     public static ColorUIResource getPrimaryControl() { return getCurrentTheme().getPrimaryControl(); }
1915 
1916     /**
1917      * Returns the primary control shadow color of the current theme. This is a
1918      * cover method for {@code getCurrentTheme().getPrimaryControlShadow()}.
1919      *
1920      * @return the primary control shadow color
1921      *
1922      * @see MetalTheme
1923      */
1924     public static ColorUIResource getPrimaryControlShadow() { return getCurrentTheme().getPrimaryControlShadow(); }
1925 
1926     /**
1927      * Returns the primary control dark shadow color of the current
1928      * theme. This is a cover method for {@code
1929      * getCurrentTheme().getPrimaryControlDarkShadow()}.
1930      *
1931      * @return the primary control dark shadow color
1932      *
1933      * @see MetalTheme
1934      */
1935     public static ColorUIResource getPrimaryControlDarkShadow() { return getCurrentTheme().getPrimaryControlDarkShadow(); }
1936 
1937     /**
1938      * Returns the primary control info color of the current theme. This is a
1939      * cover method for {@code getCurrentTheme().getPrimaryControlInfo()}.
1940      *
1941      * @return the primary control info color
1942      *
1943      * @see MetalTheme
1944      */
1945     public static ColorUIResource getPrimaryControlInfo() { return getCurrentTheme().getPrimaryControlInfo(); }
1946 
1947     /**
1948      * Returns the primary control highlight color of the current
1949      * theme. This is a cover method for {@code
1950      * getCurrentTheme().getPrimaryControlHighlight()}.
1951      *
1952      * @return the primary control highlight color
1953      *
1954      * @see MetalTheme
1955      */
1956     public static ColorUIResource getPrimaryControlHighlight() { return getCurrentTheme().getPrimaryControlHighlight(); }
1957 
1958     /**
1959      * Returns the system text color of the current theme. This is a
1960      * cover method for {@code getCurrentTheme().getSystemTextColor()}.
1961      *
1962      * @return the system text color
1963      *
1964      * @see MetalTheme
1965      */
1966     public static ColorUIResource getSystemTextColor() { return getCurrentTheme().getSystemTextColor(); }
1967 
1968     /**
1969      * Returns the control text color of the current theme. This is a
1970      * cover method for {@code getCurrentTheme().getControlTextColor()}.
1971      *
1972      * @return the control text color
1973      *
1974      * @see MetalTheme
1975      */
1976     public static ColorUIResource getControlTextColor() { return getCurrentTheme().getControlTextColor(); }
1977 
1978     /**
1979      * Returns the inactive control text color of the current theme. This is a
1980      * cover method for {@code
1981      * getCurrentTheme().getInactiveControlTextColor()}.
1982      *
1983      * @return the inactive control text color
1984      *
1985      * @see MetalTheme
1986      */
1987     public static ColorUIResource getInactiveControlTextColor() { return getCurrentTheme().getInactiveControlTextColor(); }
1988 
1989     /**
1990      * Returns the inactive system text color of the current theme. This is a
1991      * cover method for {@code
1992      * getCurrentTheme().getInactiveSystemTextColor()}.
1993      *
1994      * @return the inactive system text color
1995      *
1996      * @see MetalTheme
1997      */
1998     public static ColorUIResource getInactiveSystemTextColor() { return getCurrentTheme().getInactiveSystemTextColor(); }
1999 
2000     /**
2001      * Returns the user text color of the current theme. This is a
2002      * cover method for {@code getCurrentTheme().getUserTextColor()}.
2003      *
2004      * @return the user text color
2005      *
2006      * @see MetalTheme
2007      */
2008     public static ColorUIResource getUserTextColor() { return getCurrentTheme().getUserTextColor(); }
2009 
2010     /**
2011      * Returns the text highlight color of the current theme. This is a
2012      * cover method for {@code getCurrentTheme().getTextHighlightColor()}.
2013      *
2014      * @return the text highlight color
2015      *
2016      * @see MetalTheme
2017      */
2018     public static ColorUIResource getTextHighlightColor() { return getCurrentTheme().getTextHighlightColor(); }
2019 
2020     /**
2021      * Returns the highlighted text color of the current theme. This is a
2022      * cover method for {@code getCurrentTheme().getHighlightedTextColor()}.
2023      *
2024      * @return the highlighted text color
2025      *
2026      * @see MetalTheme
2027      */
2028     public static ColorUIResource getHighlightedTextColor() { return getCurrentTheme().getHighlightedTextColor(); }
2029 
2030     /**
2031      * Returns the window background color of the current theme. This is a
2032      * cover method for {@code getCurrentTheme().getWindowBackground()}.
2033      *
2034      * @return the window background color
2035      *
2036      * @see MetalTheme
2037      */
2038     public static ColorUIResource getWindowBackground() { return getCurrentTheme().getWindowBackground(); }
2039 
2040     /**
2041      * Returns the window title background color of the current
2042      * theme. This is a cover method for {@code
2043      * getCurrentTheme().getWindowTitleBackground()}.
2044      *
2045      * @return the window title background color
2046      *
2047      * @see MetalTheme
2048      */
2049     public static ColorUIResource getWindowTitleBackground() { return getCurrentTheme().getWindowTitleBackground(); }
2050 
2051     /**
2052      * Returns the window title foreground color of the current
2053      * theme. This is a cover method for {@code
2054      * getCurrentTheme().getWindowTitleForeground()}.
2055      *
2056      * @return the window title foreground color
2057      *
2058      * @see MetalTheme
2059      */
2060     public static ColorUIResource getWindowTitleForeground() { return getCurrentTheme().getWindowTitleForeground(); }
2061 
2062     /**
2063      * Returns the window title inactive background color of the current
2064      * theme. This is a cover method for {@code
2065      * getCurrentTheme().getWindowTitleInactiveBackground()}.
2066      *
2067      * @return the window title inactive background color
2068      *
2069      * @see MetalTheme
2070      */
2071     public static ColorUIResource getWindowTitleInactiveBackground() { return getCurrentTheme().getWindowTitleInactiveBackground(); }
2072 
2073     /**
2074      * Returns the window title inactive foreground color of the current
2075      * theme. This is a cover method for {@code
2076      * getCurrentTheme().getWindowTitleInactiveForeground()}.
2077      *
2078      * @return the window title inactive foreground color
2079      *
2080      * @see MetalTheme
2081      */
2082     public static ColorUIResource getWindowTitleInactiveForeground() { return getCurrentTheme().getWindowTitleInactiveForeground(); }
2083 
2084     /**
2085      * Returns the menu background color of the current theme. This is
2086      * a cover method for {@code getCurrentTheme().getMenuBackground()}.
2087      *
2088      * @return the menu background color
2089      *
2090      * @see MetalTheme
2091      */
2092     public static ColorUIResource getMenuBackground() { return getCurrentTheme().getMenuBackground(); }
2093 
2094     /**
2095      * Returns the menu foreground color of the current theme. This is
2096      * a cover method for {@code getCurrentTheme().getMenuForeground()}.
2097      *
2098      * @return the menu foreground color
2099      *
2100      * @see MetalTheme
2101      */
2102     public static ColorUIResource getMenuForeground() { return getCurrentTheme().getMenuForeground(); }
2103 
2104     /**
2105      * Returns the menu selected background color of the current theme. This is
2106      * a cover method for
2107      * {@code getCurrentTheme().getMenuSelectedBackground()}.
2108      *
2109      * @return the menu selected background color
2110      *
2111      * @see MetalTheme
2112      */
2113     public static ColorUIResource getMenuSelectedBackground() { return getCurrentTheme().getMenuSelectedBackground(); }
2114 
2115     /**
2116      * Returns the menu selected foreground color of the current theme. This is
2117      * a cover method for
2118      * {@code getCurrentTheme().getMenuSelectedForeground()}.
2119      *
2120      * @return the menu selected foreground color
2121      *
2122      * @see MetalTheme
2123      */
2124     public static ColorUIResource getMenuSelectedForeground() { return getCurrentTheme().getMenuSelectedForeground(); }
2125 
2126     /**
2127      * Returns the menu disabled foreground color of the current theme. This is
2128      * a cover method for
2129      * {@code getCurrentTheme().getMenuDisabledForeground()}.
2130      *
2131      * @return the menu disabled foreground color
2132      *
2133      * @see MetalTheme
2134      */
2135     public static ColorUIResource getMenuDisabledForeground() { return getCurrentTheme().getMenuDisabledForeground(); }
2136 
2137     /**
2138      * Returns the separator background color of the current theme. This is
2139      * a cover method for {@code getCurrentTheme().getSeparatorBackground()}.
2140      *
2141      * @return the separator background color
2142      *
2143      * @see MetalTheme
2144      */
2145     public static ColorUIResource getSeparatorBackground() { return getCurrentTheme().getSeparatorBackground(); }
2146 
2147     /**
2148      * Returns the separator foreground color of the current theme. This is
2149      * a cover method for {@code getCurrentTheme().getSeparatorForeground()}.
2150      *
2151      * @return the separator foreground color
2152      *
2153      * @see MetalTheme
2154      */
2155     public static ColorUIResource getSeparatorForeground() { return getCurrentTheme().getSeparatorForeground(); }
2156 
2157     /**
2158      * Returns the accelerator foreground color of the current theme. This is
2159      * a cover method for {@code getCurrentTheme().getAcceleratorForeground()}.
2160      *
2161      * @return the separator accelerator foreground color
2162      *
2163      * @see MetalTheme
2164      */
2165     public static ColorUIResource getAcceleratorForeground() { return getCurrentTheme().getAcceleratorForeground(); }
2166 
2167     /**
2168      * Returns the accelerator selected foreground color of the
2169      * current theme. This is a cover method for {@code
2170      * getCurrentTheme().getAcceleratorSelectedForeground()}.
2171      *
2172      * @return the accelerator selected foreground color
2173      *
2174      * @see MetalTheme
2175      */
2176     public static ColorUIResource getAcceleratorSelectedForeground() { return getCurrentTheme().getAcceleratorSelectedForeground(); }
2177 
2178 
2179     /**
2180      * Returns a {@code LayoutStyle} implementing the Java look and feel
2181      * design guidelines as specified at
2182      * <a href="http://java.sun.com/products/jlf/ed2/book/HIG.Visual2.html">http://java.sun.com/products/jlf/ed2/book/HIG.Visual2.html</a>.
2183      *
2184      * @return LayoutStyle implementing the Java look and feel design
2185      *         guidelines
2186      * @since 1.6
2187      */
2188     public LayoutStyle getLayoutStyle() {
2189         return MetalLayoutStyle.INSTANCE;
2190     }
2191 
2192 
2193     /**
2194      * MetalLazyValue is a slimmed down version of <code>ProxyLaxyValue</code>.
2195      * The code is duplicate so that it can get at the package private
2196      * classes in metal.
2197      */
2198     private static class MetalLazyValue implements UIDefaults.LazyValue {
2199         /**
2200          * Name of the class to create.
2201          */
2202         private String className;
2203         private String methodName;
2204 
2205         MetalLazyValue(String name) {
2206             this.className = name;
2207         }
2208 
2209         MetalLazyValue(String name, String methodName) {
2210             this(name);
2211             this.methodName = methodName;
2212         }
2213 
2214         public Object createValue(UIDefaults table) {
2215             try {
2216                 final Class c = Class.forName(className);
2217 
2218                 if (methodName == null) {
2219                     return c.newInstance();
2220                 }
2221                 Method method = (Method)AccessController.doPrivileged(
2222                     new PrivilegedAction() {
2223                     public Object run() {
2224                         Method[] methods = c.getDeclaredMethods();
2225                         for (int counter = methods.length - 1; counter >= 0;
2226                              counter--) {
2227                             if (methods[counter].getName().equals(methodName)){
2228                                 methods[counter].setAccessible(true);
2229                                 return methods[counter];
2230                             }
2231                         }
2232                         return null;
2233                     }
2234                 });
2235                 if (method != null) {
2236                     return method.invoke(null, (Object[])null);
2237                 }
2238             } catch (ClassNotFoundException cnfe) {
2239             } catch (InstantiationException ie) {
2240             } catch (IllegalAccessException iae) {
2241             } catch (InvocationTargetException ite) {
2242             }
2243             return null;
2244         }
2245     }
2246 
2247 
2248     /**
2249      * FontActiveValue redirects to the appropriate metal theme method.
2250      */
2251     private static class FontActiveValue implements UIDefaults.ActiveValue {
2252         private int type;
2253         private MetalTheme theme;
2254 
2255         FontActiveValue(MetalTheme theme, int type) {
2256             this.theme = theme;
2257             this.type = type;
2258         }
2259 
2260         public Object createValue(UIDefaults table) {
2261             Object value = null;
2262             switch (type) {
2263             case MetalTheme.CONTROL_TEXT_FONT:
2264                 value = theme.getControlTextFont();
2265                 break;
2266             case MetalTheme.SYSTEM_TEXT_FONT:
2267                 value = theme.getSystemTextFont();
2268                 break;
2269             case MetalTheme.USER_TEXT_FONT:
2270                 value = theme.getUserTextFont();
2271                 break;
2272             case MetalTheme.MENU_TEXT_FONT:
2273                 value = theme.getMenuTextFont();
2274                 break;
2275             case MetalTheme.WINDOW_TITLE_FONT:
2276                 value = theme.getWindowTitleFont();
2277                 break;
2278             case MetalTheme.SUB_TEXT_FONT:
2279                 value = theme.getSubTextFont();
2280                 break;
2281             }
2282             return value;
2283         }
2284     }
2285 
2286     static ReferenceQueue queue = new ReferenceQueue();
2287 
2288     static void flushUnreferenced() {
2289         AATextListener aatl;
2290         while ((aatl = (AATextListener)queue.poll()) != null) {
2291             aatl.dispose();
2292         }
2293     }
2294 
2295     static class AATextListener
2296         extends WeakReference implements PropertyChangeListener {
2297 
2298         private String key = SunToolkit.DESKTOPFONTHINTS;
2299 
2300         AATextListener(LookAndFeel laf) {
2301             super(laf, queue);
2302             Toolkit tk = Toolkit.getDefaultToolkit();
2303             tk.addPropertyChangeListener(key, this);
2304         }
2305 
2306         public void propertyChange(PropertyChangeEvent pce) {
2307             LookAndFeel laf = (LookAndFeel)get();
2308             if (laf == null || laf != UIManager.getLookAndFeel()) {
2309                 dispose();
2310                 return;
2311             }
2312             UIDefaults defaults = UIManager.getLookAndFeelDefaults();
2313             boolean lafCond = SwingUtilities2.isLocalDisplay();
2314             Object aaTextInfo =
2315                 SwingUtilities2.AATextInfo.getAATextInfo(lafCond);
2316             defaults.put(SwingUtilities2.AA_TEXT_PROPERTY_KEY, aaTextInfo);
2317             updateUI();
2318         }
2319 
2320         void dispose() {
2321             Toolkit tk = Toolkit.getDefaultToolkit();
2322             tk.removePropertyChangeListener(key, this);
2323         }
2324 
2325         /**
2326          * Updates the UI of the passed in window and all its children.
2327          */
2328         private static void updateWindowUI(Window window) {
2329             SwingUtilities.updateComponentTreeUI(window);
2330             Window ownedWins[] = window.getOwnedWindows();
2331             for (int i=0; i < ownedWins.length; i++) {
2332                 updateWindowUI(ownedWins[i]);
2333             }
2334         }
2335 
2336         /**
2337          * Updates the UIs of all the known Frames.
2338          */
2339         private static void updateAllUIs() {
2340             Frame appFrames[] = Frame.getFrames();
2341             for (int j=0; j < appFrames.length; j++) {
2342                 updateWindowUI(appFrames[j]);
2343             }
2344         }
2345 
2346         /**
2347          * Indicates if an updateUI call is pending.
2348          */
2349         private static boolean updatePending;
2350 
2351         /**
2352          * Sets whether or not an updateUI call is pending.
2353          */
2354         private static synchronized void setUpdatePending(boolean update) {
2355             updatePending = update;
2356         }
2357 
2358         /**
2359          * Returns true if a UI update is pending.
2360          */
2361         private static synchronized boolean isUpdatePending() {
2362             return updatePending;
2363     }
2364 
2365         protected void updateUI() {
2366             if (!isUpdatePending()) {
2367                 setUpdatePending(true);
2368                 Runnable uiUpdater = new Runnable() {
2369                         public void run() {
2370                             updateAllUIs();
2371                             setUpdatePending(false);
2372                         }
2373                     };
2374                 SwingUtilities.invokeLater(uiUpdater);
2375             }
2376         }
2377     }
2378 
2379     // From the JLF Design Guidelines:
2380     // http://java.sun.com/products/jlf/ed2/book/HIG.Visual2.html
2381     private static class MetalLayoutStyle extends DefaultLayoutStyle {
2382         private static MetalLayoutStyle INSTANCE = new MetalLayoutStyle();
2383 
2384         @Override
2385         public int getPreferredGap(JComponent component1,
2386                 JComponent component2, ComponentPlacement type, int position,
2387                 Container parent) {
2388             // Checks args
2389             super.getPreferredGap(component1, component2, type, position,
2390                                   parent);
2391 
2392             int offset = 0;
2393 
2394             switch(type) {
2395             case INDENT:
2396                 // Metal doesn't spec this.
2397                 if (position == SwingConstants.EAST ||
2398                         position == SwingConstants.WEST) {
2399                     int indent = getIndent(component1, position);
2400                     if (indent > 0) {
2401                         return indent;
2402                     }
2403                     return 12;
2404                 }
2405                 // Fall through to related.
2406             case RELATED:
2407                 if (component1.getUIClassID() == "ToggleButtonUI" &&
2408                         component2.getUIClassID() == "ToggleButtonUI") {
2409                     ButtonModel sourceModel = ((JToggleButton)component1).
2410                             getModel();
2411                     ButtonModel targetModel = ((JToggleButton)component2).
2412                             getModel();
2413                     if ((sourceModel instanceof DefaultButtonModel) &&
2414                         (targetModel instanceof DefaultButtonModel) &&
2415                         (((DefaultButtonModel)sourceModel).getGroup() ==
2416                          ((DefaultButtonModel)targetModel).getGroup()) &&
2417                         ((DefaultButtonModel)sourceModel).getGroup() != null) {
2418                         // When toggle buttons are exclusive (that is,
2419                         // they form a radio button set), separate
2420                         // them with 2 pixels. This rule applies
2421                         // whether the toggle buttons appear in a
2422                         // toolbar or elsewhere in the interface.
2423                         // Note: this number does not appear to
2424                         // include any borders and so is not adjusted
2425                         // by the border of the toggle button
2426                         return 2;
2427                     }
2428                     // When toggle buttons are independent (like
2429                     // checkboxes) and used outside a toolbar,
2430                     // separate them with 5 pixels.
2431                     if (usingOcean()) {
2432                         return 6;
2433                     }
2434                     return 5;
2435                 }
2436                 offset = 6;
2437                 break;
2438             case UNRELATED:
2439                 offset = 12;
2440                 break;
2441             }
2442             if (isLabelAndNonlabel(component1, component2, position)) {
2443                 // Insert 12 pixels between the trailing edge of a
2444                 // label and any associated components. Insert 12
2445                 // pixels between the trailing edge of a label and the
2446                 // component it describes when labels are
2447                 // right-aligned. When labels are left-aligned, insert
2448                 // 12 pixels between the trailing edge of the longest
2449                 // label and its associated component
2450                 return getButtonGap(component1, component2, position,
2451                                     offset + 6);
2452             }
2453             return getButtonGap(component1, component2, position, offset);
2454         }
2455 
2456         @Override
2457         public int getContainerGap(JComponent component, int position,
2458                                    Container parent) {
2459             super.getContainerGap(component, position, parent);
2460             // Include 11 pixels between the bottom and right
2461             // borders of a dialog box and its command
2462             // buttons. (To the eye, the 11-pixel spacing appears
2463             // to be 12 pixels because the white borders on the
2464             // lower and right edges of the button components are
2465             // not visually significant.)
2466             // NOTE: this last text was designed with Steel in mind,
2467             // not Ocean.
2468             //
2469             // Insert 12 pixels between the edges of the panel and the
2470             // titled border. Insert 11 pixels between the top of the
2471             // title and the component above the titled border. Insert 12
2472             // pixels between the bottom of the title and the top of the
2473             // first label in the panel. Insert 11 pixels between
2474             // component groups and between the bottom of the last
2475             // component and the lower border.
2476             return getButtonGap(component, position, 12 -
2477                                 getButtonAdjustment(component, position));
2478         }
2479 
2480         @Override
2481         protected int getButtonGap(JComponent source, JComponent target,
2482                                    int position, int offset) {
2483             offset = super.getButtonGap(source, target, position, offset);
2484             if (offset > 0) {
2485                 int buttonAdjustment = getButtonAdjustment(source, position);
2486                 if (buttonAdjustment == 0) {
2487                     buttonAdjustment = getButtonAdjustment(
2488                             target, flipDirection(position));
2489                 }
2490                 offset -= buttonAdjustment;
2491             }
2492             if (offset < 0) {
2493                 return 0;
2494             }
2495             return offset;
2496         }
2497 
2498         private int getButtonAdjustment(JComponent source, int edge) {
2499             String classID = source.getUIClassID();
2500             if (classID == "ButtonUI" || classID == "ToggleButtonUI") {
2501                 if (!usingOcean() && (edge == SwingConstants.EAST ||
2502                                       edge == SwingConstants.SOUTH)) {
2503                     if (source.getBorder() instanceof UIResource) {
2504                         return 1;
2505                     }
2506                 }
2507             }
2508             else if (edge == SwingConstants.SOUTH) {
2509                 if ((classID == "RadioButtonUI" || classID == "CheckBoxUI") &&
2510                         !usingOcean()) {
2511                     return 1;
2512                 }
2513             }
2514             return 0;
2515         }
2516     }
2517 }