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