1 /*
   2  * Copyright (c) 1997, 2015, 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 /*
  27  * <p>These classes are designed to be used while the
  28  * corresponding {@code LookAndFeel} class has been installed
  29  * (<code>UIManager.setLookAndFeel(new <i>XXX</i>LookAndFeel())</code>).
  30  * Using them while a different {@code LookAndFeel} is installed
  31  * may produce unexpected results, including exceptions.
  32  * Additionally, changing the {@code LookAndFeel}
  33  * maintained by the {@code UIManager} without updating the
  34  * corresponding {@code ComponentUI} of any
  35  * {@code JComponent}s may also produce unexpected results,
  36  * such as the wrong colors showing up, and is generally not
  37  * encouraged.
  38  *
  39  */
  40 
  41 package com.sun.java.swing.plaf.windows;
  42 
  43 import java.awt.*;
  44 import java.awt.image.BufferedImage;
  45 import java.awt.image.ImageFilter;
  46 import java.awt.image.ImageProducer;
  47 import java.awt.image.FilteredImageSource;
  48 import java.awt.image.RGBImageFilter;
  49 
  50 import javax.swing.plaf.*;
  51 import javax.swing.*;
  52 import javax.swing.plaf.basic.*;
  53 import javax.swing.border.*;
  54 import javax.swing.text.DefaultEditorKit;
  55 import static javax.swing.UIDefaults.LazyValue;
  56 
  57 import java.awt.Font;
  58 import java.awt.Color;
  59 import java.awt.event.ActionEvent;
  60 
  61 import java.security.AccessController;
  62 
  63 import sun.awt.SunToolkit;
  64 import sun.awt.OSInfo;
  65 import sun.awt.shell.ShellFolder;
  66 import sun.font.FontUtilities;
  67 import sun.misc.ManagedLocalsThread;
  68 import sun.security.action.GetPropertyAction;
  69 
  70 import sun.swing.DefaultLayoutStyle;
  71 import sun.swing.ImageIconUIResource;
  72 import sun.swing.icon.SortArrowIcon;
  73 import sun.swing.SwingUtilities2;
  74 import sun.swing.StringUIClientPropertyKey;
  75 import sun.swing.plaf.windows.ClassicSortArrowIcon;
  76 
  77 import static com.sun.java.swing.plaf.windows.TMSchema.*;
  78 import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
  79 
  80 import com.sun.java.swing.plaf.windows.WindowsIconFactory.VistaMenuItemCheckIconFactory;
  81 
  82 /**
  83  * Implements the Windows95/98/NT/2000 Look and Feel.
  84  * UI classes not implemented specifically for Windows will
  85  * default to those implemented in Basic.
  86  * <p>
  87  * <strong>Warning:</strong>
  88  * Serialized objects of this class will not be compatible with
  89  * future Swing releases.  The current serialization support is appropriate
  90  * for short term storage or RMI between applications running the same
  91  * version of Swing.  A future release of Swing will provide support for
  92  * long term persistence.
  93  *
  94  * @author unattributed
  95  */
  96 @SuppressWarnings("serial") // Superclass is not serializable across versions
  97 public class WindowsLookAndFeel extends BasicLookAndFeel
  98 {
  99     /**
 100      * A client property that can be used with any JComponent that will end up
 101      * calling the LookAndFeel.getDisabledIcon method. This client property,
 102      * when set to Boolean.TRUE, will cause getDisabledIcon to use an
 103      * alternate algorithm for creating disabled icons to produce icons
 104      * that appear similar to the native Windows file chooser
 105      */
 106     static final Object HI_RES_DISABLED_ICON_CLIENT_KEY =
 107         new StringUIClientPropertyKey(
 108             "WindowsLookAndFeel.generateHiResDisabledIcon");
 109 
 110     private boolean updatePending = false;
 111 
 112     private boolean useSystemFontSettings = true;
 113     private boolean useSystemFontSizeSettings;
 114 
 115     // These properties are not used directly, but are kept as
 116     // private members to avoid being GC'd.
 117     private DesktopProperty themeActive, dllName, colorName, sizeName;
 118     private DesktopProperty aaSettings;
 119 
 120     private transient LayoutStyle style;
 121 
 122     /**
 123      * Base dialog units along the horizontal axis.
 124      */
 125     private int baseUnitX;
 126 
 127     /**
 128      * Base dialog units along the vertical axis.
 129      */
 130     private int baseUnitY;
 131 
 132     public String getName() {
 133         return "Windows";
 134     }
 135 
 136     public String getDescription() {
 137         return "The Microsoft Windows Look and Feel";
 138     }
 139 
 140     public String getID() {
 141         return "Windows";
 142     }
 143 
 144     public boolean isNativeLookAndFeel() {
 145         return OSInfo.getOSType() == OSInfo.OSType.WINDOWS;
 146     }
 147 
 148     public boolean isSupportedLookAndFeel() {
 149         return isNativeLookAndFeel();
 150     }
 151 
 152     public void initialize() {
 153         super.initialize();
 154 
 155         // Set the flag which determines which version of Windows should
 156         // be rendered. This flag only need to be set once.
 157         // if version <= 4.0 then the classic LAF should be loaded.
 158         if (OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_95) <= 0) {
 159             isClassicWindows = true;
 160         } else {
 161             isClassicWindows = false;
 162             XPStyle.invalidateStyle();
 163         }
 164 
 165         // Using the fonts set by the user can potentially cause
 166         // performance and compatibility issues, so allow this feature
 167         // to be switched off either at runtime or programmatically
 168         //
 169         String systemFonts = java.security.AccessController.doPrivileged(
 170                new GetPropertyAction("swing.useSystemFontSettings"));
 171         useSystemFontSettings = (systemFonts == null ||
 172                                  Boolean.valueOf(systemFonts).booleanValue());
 173 
 174         if (useSystemFontSettings) {
 175             Object value = UIManager.get("Application.useSystemFontSettings");
 176 
 177             useSystemFontSettings = (value == null ||
 178                                      Boolean.TRUE.equals(value));
 179         }
 180         KeyboardFocusManager.getCurrentKeyboardFocusManager().
 181             addKeyEventPostProcessor(WindowsRootPaneUI.altProcessor);
 182 
 183     }
 184 
 185     /**
 186      * Initialize the uiClassID to BasicComponentUI mapping.
 187      * The JComponent classes define their own uiClassID constants
 188      * (see AbstractComponent.getUIClassID).  This table must
 189      * map those constants to a BasicComponentUI class of the
 190      * appropriate type.
 191      *
 192      * @see BasicLookAndFeel#getDefaults
 193      */
 194     protected void initClassDefaults(UIDefaults table)
 195     {
 196         super.initClassDefaults(table);
 197 
 198         final String windowsPackageName = "com.sun.java.swing.plaf.windows.";
 199 
 200         Object[] uiDefaults = {
 201               "ButtonUI", windowsPackageName + "WindowsButtonUI",
 202             "CheckBoxUI", windowsPackageName + "WindowsCheckBoxUI",
 203     "CheckBoxMenuItemUI", windowsPackageName + "WindowsCheckBoxMenuItemUI",
 204                "LabelUI", windowsPackageName + "WindowsLabelUI",
 205          "RadioButtonUI", windowsPackageName + "WindowsRadioButtonUI",
 206  "RadioButtonMenuItemUI", windowsPackageName + "WindowsRadioButtonMenuItemUI",
 207         "ToggleButtonUI", windowsPackageName + "WindowsToggleButtonUI",
 208          "ProgressBarUI", windowsPackageName + "WindowsProgressBarUI",
 209               "SliderUI", windowsPackageName + "WindowsSliderUI",
 210            "SeparatorUI", windowsPackageName + "WindowsSeparatorUI",
 211            "SplitPaneUI", windowsPackageName + "WindowsSplitPaneUI",
 212              "SpinnerUI", windowsPackageName + "WindowsSpinnerUI",
 213           "TabbedPaneUI", windowsPackageName + "WindowsTabbedPaneUI",
 214             "TextAreaUI", windowsPackageName + "WindowsTextAreaUI",
 215            "TextFieldUI", windowsPackageName + "WindowsTextFieldUI",
 216        "PasswordFieldUI", windowsPackageName + "WindowsPasswordFieldUI",
 217             "TextPaneUI", windowsPackageName + "WindowsTextPaneUI",
 218           "EditorPaneUI", windowsPackageName + "WindowsEditorPaneUI",
 219                 "TreeUI", windowsPackageName + "WindowsTreeUI",
 220              "ToolBarUI", windowsPackageName + "WindowsToolBarUI",
 221     "ToolBarSeparatorUI", windowsPackageName + "WindowsToolBarSeparatorUI",
 222             "ComboBoxUI", windowsPackageName + "WindowsComboBoxUI",
 223          "TableHeaderUI", windowsPackageName + "WindowsTableHeaderUI",
 224        "InternalFrameUI", windowsPackageName + "WindowsInternalFrameUI",
 225          "DesktopPaneUI", windowsPackageName + "WindowsDesktopPaneUI",
 226          "DesktopIconUI", windowsPackageName + "WindowsDesktopIconUI",
 227          "FileChooserUI", windowsPackageName + "WindowsFileChooserUI",
 228                 "MenuUI", windowsPackageName + "WindowsMenuUI",
 229             "MenuItemUI", windowsPackageName + "WindowsMenuItemUI",
 230              "MenuBarUI", windowsPackageName + "WindowsMenuBarUI",
 231            "PopupMenuUI", windowsPackageName + "WindowsPopupMenuUI",
 232   "PopupMenuSeparatorUI", windowsPackageName + "WindowsPopupMenuSeparatorUI",
 233            "ScrollBarUI", windowsPackageName + "WindowsScrollBarUI",
 234             "RootPaneUI", windowsPackageName + "WindowsRootPaneUI"
 235         };
 236 
 237         table.putDefaults(uiDefaults);
 238     }
 239 
 240     /**
 241      * Load the SystemColors into the defaults table.  The keys
 242      * for SystemColor defaults are the same as the names of
 243      * the public fields in SystemColor.  If the table is being
 244      * created on a native Windows platform we use the SystemColor
 245      * values, otherwise we create color objects whose values match
 246      * the defaults Windows95 colors.
 247      */
 248     protected void initSystemColorDefaults(UIDefaults table)
 249     {
 250         String[] defaultSystemColors = {
 251                 "desktop", "#005C5C", /* Color of the desktop background */
 252           "activeCaption", "#000080", /* Color for captions (title bars) when they are active. */
 253       "activeCaptionText", "#FFFFFF", /* Text color for text in captions (title bars). */
 254     "activeCaptionBorder", "#C0C0C0", /* Border color for caption (title bar) window borders. */
 255         "inactiveCaption", "#808080", /* Color for captions (title bars) when not active. */
 256     "inactiveCaptionText", "#C0C0C0", /* Text color for text in inactive captions (title bars). */
 257   "inactiveCaptionBorder", "#C0C0C0", /* Border color for inactive caption (title bar) window borders. */
 258                  "window", "#FFFFFF", /* Default color for the interior of windows */
 259            "windowBorder", "#000000", /* ??? */
 260              "windowText", "#000000", /* ??? */
 261                    "menu", "#C0C0C0", /* Background color for menus */
 262        "menuPressedItemB", "#000080", /* LightShadow of menubutton highlight */
 263        "menuPressedItemF", "#FFFFFF", /* Default color for foreground "text" in menu item */
 264                "menuText", "#000000", /* Text color for menus  */
 265                    "text", "#C0C0C0", /* Text background color */
 266                "textText", "#000000", /* Text foreground color */
 267           "textHighlight", "#000080", /* Text background color when selected */
 268       "textHighlightText", "#FFFFFF", /* Text color when selected */
 269        "textInactiveText", "#808080", /* Text color when disabled */
 270                 "control", "#C0C0C0", /* Default color for controls (buttons, sliders, etc) */
 271             "controlText", "#000000", /* Default color for text in controls */
 272        "controlHighlight", "#C0C0C0",
 273 
 274   /*"controlHighlight", "#E0E0E0",*/ /* Specular highlight (opposite of the shadow) */
 275      "controlLtHighlight", "#FFFFFF", /* Highlight color for controls */
 276           "controlShadow", "#808080", /* Shadow color for controls */
 277         "controlDkShadow", "#000000", /* Dark shadow color for controls */
 278               "scrollbar", "#E0E0E0", /* Scrollbar background (usually the "track") */
 279                    "info", "#FFFFE1", /* ??? */
 280                "infoText", "#000000"  /* ??? */
 281         };
 282 
 283         loadSystemColors(table, defaultSystemColors, isNativeLookAndFeel());
 284     }
 285 
 286    /**
 287      * Initialize the defaults table with the name of the ResourceBundle
 288      * used for getting localized defaults.
 289      */
 290     private void initResourceBundle(UIDefaults table) {
 291         table.addResourceBundle( "com.sun.java.swing.plaf.windows.resources.windows" );
 292     }
 293 
 294     // XXX - there are probably a lot of redundant values that could be removed.
 295     // ie. Take a look at RadioButtonBorder, etc...
 296     protected void initComponentDefaults(UIDefaults table)
 297     {
 298         super.initComponentDefaults( table );
 299 
 300         initResourceBundle(table);
 301 
 302         // *** Shared Fonts
 303         LazyValue dialogPlain12 = t -> new FontUIResource(Font.DIALOG, Font.PLAIN, 12);
 304 
 305         LazyValue sansSerifPlain12 =  t -> new FontUIResource(Font.SANS_SERIF, Font.PLAIN, 12);
 306         LazyValue monospacedPlain12 = t -> new FontUIResource(Font.MONOSPACED, Font.PLAIN, 12);
 307         LazyValue dialogBold12 = t -> new FontUIResource(Font.DIALOG, Font.BOLD, 12);
 308 
 309         // *** Colors
 310         // XXX - some of these doens't seem to be used
 311         ColorUIResource red = new ColorUIResource(Color.red);
 312         ColorUIResource black = new ColorUIResource(Color.black);
 313         ColorUIResource white = new ColorUIResource(Color.white);
 314         ColorUIResource gray = new ColorUIResource(Color.gray);
 315         ColorUIResource darkGray = new ColorUIResource(Color.darkGray);
 316         ColorUIResource scrollBarTrackHighlight = darkGray;
 317 
 318         // Set the flag which determines which version of Windows should
 319         // be rendered. This flag only need to be set once.
 320         // if version <= 4.0 then the classic LAF should be loaded.
 321         isClassicWindows = OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_95) <= 0;
 322 
 323         // *** Tree
 324         Object treeExpandedIcon = WindowsTreeUI.ExpandedIcon.createExpandedIcon();
 325 
 326         Object treeCollapsedIcon = WindowsTreeUI.CollapsedIcon.createCollapsedIcon();
 327 
 328 
 329         // *** Text
 330         Object fieldInputMap = new UIDefaults.LazyInputMap(new Object[] {
 331                       "control C", DefaultEditorKit.copyAction,
 332                       "control V", DefaultEditorKit.pasteAction,
 333                       "control X", DefaultEditorKit.cutAction,
 334                            "COPY", DefaultEditorKit.copyAction,
 335                           "PASTE", DefaultEditorKit.pasteAction,
 336                             "CUT", DefaultEditorKit.cutAction,
 337                  "control INSERT", DefaultEditorKit.copyAction,
 338                    "shift INSERT", DefaultEditorKit.pasteAction,
 339                    "shift DELETE", DefaultEditorKit.cutAction,
 340                       "control A", DefaultEditorKit.selectAllAction,
 341              "control BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/,
 342                      "shift LEFT", DefaultEditorKit.selectionBackwardAction,
 343                     "shift RIGHT", DefaultEditorKit.selectionForwardAction,
 344                    "control LEFT", DefaultEditorKit.previousWordAction,
 345                   "control RIGHT", DefaultEditorKit.nextWordAction,
 346              "control shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
 347             "control shift RIGHT", DefaultEditorKit.selectionNextWordAction,
 348                            "HOME", DefaultEditorKit.beginLineAction,
 349                             "END", DefaultEditorKit.endLineAction,
 350                      "shift HOME", DefaultEditorKit.selectionBeginLineAction,
 351                       "shift END", DefaultEditorKit.selectionEndLineAction,
 352                      "BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
 353                "shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
 354                          "ctrl H", DefaultEditorKit.deletePrevCharAction,
 355                          "DELETE", DefaultEditorKit.deleteNextCharAction,
 356                     "ctrl DELETE", DefaultEditorKit.deleteNextWordAction,
 357                 "ctrl BACK_SPACE", DefaultEditorKit.deletePrevWordAction,
 358                           "RIGHT", DefaultEditorKit.forwardAction,
 359                            "LEFT", DefaultEditorKit.backwardAction,
 360                        "KP_RIGHT", DefaultEditorKit.forwardAction,
 361                         "KP_LEFT", DefaultEditorKit.backwardAction,
 362                           "ENTER", JTextField.notifyAction,
 363                 "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
 364         });
 365 
 366         Object passwordInputMap = new UIDefaults.LazyInputMap(new Object[] {
 367                       "control C", DefaultEditorKit.copyAction,
 368                       "control V", DefaultEditorKit.pasteAction,
 369                       "control X", DefaultEditorKit.cutAction,
 370                            "COPY", DefaultEditorKit.copyAction,
 371                           "PASTE", DefaultEditorKit.pasteAction,
 372                             "CUT", DefaultEditorKit.cutAction,
 373                  "control INSERT", DefaultEditorKit.copyAction,
 374                    "shift INSERT", DefaultEditorKit.pasteAction,
 375                    "shift DELETE", DefaultEditorKit.cutAction,
 376                       "control A", DefaultEditorKit.selectAllAction,
 377              "control BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/,
 378                      "shift LEFT", DefaultEditorKit.selectionBackwardAction,
 379                     "shift RIGHT", DefaultEditorKit.selectionForwardAction,
 380                    "control LEFT", DefaultEditorKit.beginLineAction,
 381                   "control RIGHT", DefaultEditorKit.endLineAction,
 382              "control shift LEFT", DefaultEditorKit.selectionBeginLineAction,
 383             "control shift RIGHT", DefaultEditorKit.selectionEndLineAction,
 384                            "HOME", DefaultEditorKit.beginLineAction,
 385                             "END", DefaultEditorKit.endLineAction,
 386                      "shift HOME", DefaultEditorKit.selectionBeginLineAction,
 387                       "shift END", DefaultEditorKit.selectionEndLineAction,
 388                      "BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
 389                "shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
 390                          "ctrl H", DefaultEditorKit.deletePrevCharAction,
 391                          "DELETE", DefaultEditorKit.deleteNextCharAction,
 392                           "RIGHT", DefaultEditorKit.forwardAction,
 393                            "LEFT", DefaultEditorKit.backwardAction,
 394                        "KP_RIGHT", DefaultEditorKit.forwardAction,
 395                         "KP_LEFT", DefaultEditorKit.backwardAction,
 396                           "ENTER", JTextField.notifyAction,
 397                 "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
 398         });
 399 
 400         Object multilineInputMap = new UIDefaults.LazyInputMap(new Object[] {
 401                       "control C", DefaultEditorKit.copyAction,
 402                       "control V", DefaultEditorKit.pasteAction,
 403                       "control X", DefaultEditorKit.cutAction,
 404                            "COPY", DefaultEditorKit.copyAction,
 405                           "PASTE", DefaultEditorKit.pasteAction,
 406                             "CUT", DefaultEditorKit.cutAction,
 407                  "control INSERT", DefaultEditorKit.copyAction,
 408                    "shift INSERT", DefaultEditorKit.pasteAction,
 409                    "shift DELETE", DefaultEditorKit.cutAction,
 410                      "shift LEFT", DefaultEditorKit.selectionBackwardAction,
 411                     "shift RIGHT", DefaultEditorKit.selectionForwardAction,
 412                    "control LEFT", DefaultEditorKit.previousWordAction,
 413                   "control RIGHT", DefaultEditorKit.nextWordAction,
 414              "control shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
 415             "control shift RIGHT", DefaultEditorKit.selectionNextWordAction,
 416                       "control A", DefaultEditorKit.selectAllAction,
 417              "control BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/,
 418                            "HOME", DefaultEditorKit.beginLineAction,
 419                             "END", DefaultEditorKit.endLineAction,
 420                      "shift HOME", DefaultEditorKit.selectionBeginLineAction,
 421                       "shift END", DefaultEditorKit.selectionEndLineAction,
 422                    "control HOME", DefaultEditorKit.beginAction,
 423                     "control END", DefaultEditorKit.endAction,
 424              "control shift HOME", DefaultEditorKit.selectionBeginAction,
 425               "control shift END", DefaultEditorKit.selectionEndAction,
 426                              "UP", DefaultEditorKit.upAction,
 427                            "DOWN", DefaultEditorKit.downAction,
 428                      "BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
 429                "shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
 430                          "ctrl H", DefaultEditorKit.deletePrevCharAction,
 431                          "DELETE", DefaultEditorKit.deleteNextCharAction,
 432                     "ctrl DELETE", DefaultEditorKit.deleteNextWordAction,
 433                 "ctrl BACK_SPACE", DefaultEditorKit.deletePrevWordAction,
 434                           "RIGHT", DefaultEditorKit.forwardAction,
 435                            "LEFT", DefaultEditorKit.backwardAction,
 436                        "KP_RIGHT", DefaultEditorKit.forwardAction,
 437                         "KP_LEFT", DefaultEditorKit.backwardAction,
 438                         "PAGE_UP", DefaultEditorKit.pageUpAction,
 439                       "PAGE_DOWN", DefaultEditorKit.pageDownAction,
 440                   "shift PAGE_UP", "selection-page-up",
 441                 "shift PAGE_DOWN", "selection-page-down",
 442              "ctrl shift PAGE_UP", "selection-page-left",
 443            "ctrl shift PAGE_DOWN", "selection-page-right",
 444                        "shift UP", DefaultEditorKit.selectionUpAction,
 445                      "shift DOWN", DefaultEditorKit.selectionDownAction,
 446                           "ENTER", DefaultEditorKit.insertBreakAction,
 447                             "TAB", DefaultEditorKit.insertTabAction,
 448                       "control T", "next-link-action",
 449                 "control shift T", "previous-link-action",
 450                   "control SPACE", "activate-link-action",
 451                 "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
 452         });
 453 
 454         Object menuItemAcceleratorDelimiter = "+";
 455 
 456         Object ControlBackgroundColor = new DesktopProperty(
 457                                                        "win.3d.backgroundColor",
 458                                                         table.get("control"));
 459         Object ControlLightColor      = new DesktopProperty(
 460                                                        "win.3d.lightColor",
 461                                                         table.get("controlHighlight"));
 462         Object ControlHighlightColor  = new DesktopProperty(
 463                                                        "win.3d.highlightColor",
 464                                                         table.get("controlLtHighlight"));
 465         Object ControlShadowColor     = new DesktopProperty(
 466                                                        "win.3d.shadowColor",
 467                                                         table.get("controlShadow"));
 468         Object ControlDarkShadowColor = new DesktopProperty(
 469                                                        "win.3d.darkShadowColor",
 470                                                         table.get("controlDkShadow"));
 471         Object ControlTextColor       = new DesktopProperty(
 472                                                        "win.button.textColor",
 473                                                         table.get("controlText"));
 474         Object MenuBackgroundColor    = new DesktopProperty(
 475                                                        "win.menu.backgroundColor",
 476                                                         table.get("menu"));
 477         Object MenuBarBackgroundColor = new DesktopProperty(
 478                                                        "win.menubar.backgroundColor",
 479                                                         table.get("menu"));
 480         Object MenuTextColor          = new DesktopProperty(
 481                                                        "win.menu.textColor",
 482                                                         table.get("menuText"));
 483         Object SelectionBackgroundColor = new DesktopProperty(
 484                                                        "win.item.highlightColor",
 485                                                         table.get("textHighlight"));
 486         Object SelectionTextColor     = new DesktopProperty(
 487                                                        "win.item.highlightTextColor",
 488                                                         table.get("textHighlightText"));
 489         Object WindowBackgroundColor  = new DesktopProperty(
 490                                                        "win.frame.backgroundColor",
 491                                                         table.get("window"));
 492         Object WindowTextColor        = new DesktopProperty(
 493                                                        "win.frame.textColor",
 494                                                         table.get("windowText"));
 495         Object WindowBorderWidth      = new DesktopProperty(
 496                                                        "win.frame.sizingBorderWidth",
 497                                                        Integer.valueOf(1));
 498         Object TitlePaneHeight        = new DesktopProperty(
 499                                                        "win.frame.captionHeight",
 500                                                        Integer.valueOf(18));
 501         Object TitleButtonWidth       = new DesktopProperty(
 502                                                        "win.frame.captionButtonWidth",
 503                                                        Integer.valueOf(16));
 504         Object TitleButtonHeight      = new DesktopProperty(
 505                                                        "win.frame.captionButtonHeight",
 506                                                        Integer.valueOf(16));
 507         Object InactiveTextColor      = new DesktopProperty(
 508                                                        "win.text.grayedTextColor",
 509                                                         table.get("textInactiveText"));
 510         Object ScrollbarBackgroundColor = new DesktopProperty(
 511                                                        "win.scrollbar.backgroundColor",
 512                                                         table.get("scrollbar"));
 513         Object buttonFocusColor = new FocusColorProperty();
 514 
 515         Object TextBackground         = new XPColorValue(Part.EP_EDIT, null, Prop.FILLCOLOR,
 516                                                          WindowBackgroundColor);
 517         //The following four lines were commented out as part of bug 4991597
 518         //This code *is* correct, however it differs from WindowsXP and is, apparently
 519         //a Windows XP bug. Until Windows fixes this bug, we shall also exhibit the same
 520         //behavior
 521         //Object ReadOnlyTextBackground = new XPColorValue(Part.EP_EDITTEXT, State.READONLY, Prop.FILLCOLOR,
 522         //                                                 ControlBackgroundColor);
 523         //Object DisabledTextBackground = new XPColorValue(Part.EP_EDITTEXT, State.DISABLED, Prop.FILLCOLOR,
 524         //                                                 ControlBackgroundColor);
 525         Object ReadOnlyTextBackground = ControlBackgroundColor;
 526         Object DisabledTextBackground = ControlBackgroundColor;
 527 
 528         Object MenuFont = dialogPlain12;
 529         Object FixedControlFont = monospacedPlain12;
 530         Object ControlFont = dialogPlain12;
 531         Object MessageFont = dialogPlain12;
 532         Object WindowFont = dialogBold12;
 533         Object ToolTipFont = sansSerifPlain12;
 534         Object IconFont = ControlFont;
 535 
 536         Object scrollBarWidth = new DesktopProperty("win.scrollbar.width", Integer.valueOf(16));
 537 
 538         Object menuBarHeight = new DesktopProperty("win.menu.height", null);
 539 
 540         Object hotTrackingOn = new DesktopProperty("win.item.hotTrackingOn", true);
 541 
 542         Object showMnemonics = new DesktopProperty("win.menu.keyboardCuesOn", Boolean.TRUE);
 543 
 544         if (useSystemFontSettings) {
 545             MenuFont = getDesktopFontValue("win.menu.font", MenuFont);
 546             FixedControlFont = getDesktopFontValue("win.ansiFixed.font", FixedControlFont);
 547             ControlFont = getDesktopFontValue("win.defaultGUI.font", ControlFont);
 548             MessageFont = getDesktopFontValue("win.messagebox.font", MessageFont);
 549             WindowFont = getDesktopFontValue("win.frame.captionFont", WindowFont);
 550             IconFont    = getDesktopFontValue("win.icon.font", IconFont);
 551             ToolTipFont = getDesktopFontValue("win.tooltip.font", ToolTipFont);
 552 
 553             /* Put the desktop AA settings in the defaults.
 554              * JComponent.setUI() retrieves this and makes it available
 555              * as a client property on the JComponent. Use the same key name
 556              * for both client property and UIDefaults.
 557              * Also need to set up listeners for changes in these settings.
 558              */
 559             SwingUtilities2.putAATextInfo(true, table);
 560             this.aaSettings =
 561                 new FontDesktopProperty(SunToolkit.DESKTOPFONTHINTS);
 562         }
 563         if (useSystemFontSizeSettings) {
 564             MenuFont = new WindowsFontSizeProperty("win.menu.font.height", Font.DIALOG, Font.PLAIN, 12);
 565             FixedControlFont = new WindowsFontSizeProperty("win.ansiFixed.font.height", Font.MONOSPACED,
 566                        Font.PLAIN, 12);
 567             ControlFont = new WindowsFontSizeProperty("win.defaultGUI.font.height", Font.DIALOG, Font.PLAIN, 12);
 568             MessageFont = new WindowsFontSizeProperty("win.messagebox.font.height", Font.DIALOG, Font.PLAIN, 12);
 569             WindowFont = new WindowsFontSizeProperty("win.frame.captionFont.height", Font.DIALOG, Font.BOLD, 12);
 570             ToolTipFont = new WindowsFontSizeProperty("win.tooltip.font.height", Font.SANS_SERIF, Font.PLAIN, 12);
 571             IconFont    = new WindowsFontSizeProperty("win.icon.font.height", Font.DIALOG, Font.PLAIN, 12);
 572         }
 573 
 574 
 575         if (!(this instanceof WindowsClassicLookAndFeel) &&
 576             (OSInfo.getOSType() == OSInfo.OSType.WINDOWS &&
 577              OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_XP) >= 0) &&
 578             AccessController.doPrivileged(new GetPropertyAction("swing.noxp")) == null) {
 579 
 580             // These desktop properties are not used directly, but are needed to
 581             // trigger realoading of UI's.
 582             this.themeActive = new TriggerDesktopProperty("win.xpstyle.themeActive");
 583             this.dllName     = new TriggerDesktopProperty("win.xpstyle.dllName");
 584             this.colorName   = new TriggerDesktopProperty("win.xpstyle.colorName");
 585             this.sizeName    = new TriggerDesktopProperty("win.xpstyle.sizeName");
 586         }
 587 
 588 
 589         Object[] defaults = {
 590             // *** Auditory Feedback
 591             // this key defines which of the various cues to render
 592             // Overridden from BasicL&F. This L&F should play all sounds
 593             // all the time. The infrastructure decides what to play.
 594             // This is disabled until sound bugs can be resolved.
 595             "AuditoryCues.playList", null, // table.get("AuditoryCues.cueList"),
 596 
 597             "Application.useSystemFontSettings", Boolean.valueOf(useSystemFontSettings),
 598 
 599             "TextField.focusInputMap", fieldInputMap,
 600             "PasswordField.focusInputMap", passwordInputMap,
 601             "TextArea.focusInputMap", multilineInputMap,
 602             "TextPane.focusInputMap", multilineInputMap,
 603             "EditorPane.focusInputMap", multilineInputMap,
 604 
 605             // Buttons
 606             "Button.font", ControlFont,
 607             "Button.background", ControlBackgroundColor,
 608             // Button.foreground, Button.shadow, Button.darkShadow,
 609             // Button.disabledForground, and Button.disabledShadow are only
 610             // used for Windows Classic. Windows XP will use colors
 611             // from the current visual style.
 612             "Button.foreground", ControlTextColor,
 613             "Button.shadow", ControlShadowColor,
 614             "Button.darkShadow", ControlDarkShadowColor,
 615             "Button.light", ControlLightColor,
 616             "Button.highlight", ControlHighlightColor,
 617             "Button.disabledForeground", InactiveTextColor,
 618             "Button.disabledShadow", ControlHighlightColor,
 619             "Button.focus", buttonFocusColor,
 620             "Button.dashedRectGapX", new XPValue(Integer.valueOf(3), Integer.valueOf(5)),
 621             "Button.dashedRectGapY", new XPValue(Integer.valueOf(3), Integer.valueOf(4)),
 622             "Button.dashedRectGapWidth", new XPValue(Integer.valueOf(6), Integer.valueOf(10)),
 623             "Button.dashedRectGapHeight", new XPValue(Integer.valueOf(6), Integer.valueOf(8)),
 624             "Button.textShiftOffset", new XPValue(Integer.valueOf(0),
 625                                                   Integer.valueOf(1)),
 626             // W2K keyboard navigation hidding.
 627             "Button.showMnemonics", showMnemonics,
 628             "Button.focusInputMap",
 629                new UIDefaults.LazyInputMap(new Object[] {
 630                             "SPACE", "pressed",
 631                    "released SPACE", "released"
 632                  }),
 633 
 634             "Caret.width",
 635                   new DesktopProperty("win.caret.width", null),
 636 
 637             "CheckBox.font", ControlFont,
 638             "CheckBox.interiorBackground", WindowBackgroundColor,
 639             "CheckBox.background", ControlBackgroundColor,
 640             "CheckBox.foreground", WindowTextColor,
 641             "CheckBox.shadow", ControlShadowColor,
 642             "CheckBox.darkShadow", ControlDarkShadowColor,
 643             "CheckBox.light", ControlLightColor,
 644             "CheckBox.highlight", ControlHighlightColor,
 645             "CheckBox.focus", buttonFocusColor,
 646             "CheckBox.focusInputMap",
 647                new UIDefaults.LazyInputMap(new Object[] {
 648                             "SPACE", "pressed",
 649                    "released SPACE", "released"
 650                  }),
 651             // margin is 2 all the way around, BasicBorders.RadioButtonBorder
 652             // (checkbox uses RadioButtonBorder) is 2 all the way around too.
 653             "CheckBox.totalInsets", new Insets(4, 4, 4, 4),
 654 
 655             "CheckBoxMenuItem.font", MenuFont,
 656             "CheckBoxMenuItem.background", MenuBackgroundColor,
 657             "CheckBoxMenuItem.foreground", MenuTextColor,
 658             "CheckBoxMenuItem.selectionForeground", SelectionTextColor,
 659             "CheckBoxMenuItem.selectionBackground", SelectionBackgroundColor,
 660             "CheckBoxMenuItem.acceleratorForeground", MenuTextColor,
 661             "CheckBoxMenuItem.acceleratorSelectionForeground", SelectionTextColor,
 662             "CheckBoxMenuItem.commandSound", "win.sound.menuCommand",
 663 
 664             "ComboBox.font", ControlFont,
 665             "ComboBox.background", WindowBackgroundColor,
 666             "ComboBox.foreground", WindowTextColor,
 667             "ComboBox.buttonBackground", ControlBackgroundColor,
 668             "ComboBox.buttonShadow", ControlShadowColor,
 669             "ComboBox.buttonDarkShadow", ControlDarkShadowColor,
 670             "ComboBox.buttonHighlight", ControlHighlightColor,
 671             "ComboBox.selectionBackground", SelectionBackgroundColor,
 672             "ComboBox.selectionForeground", SelectionTextColor,
 673             "ComboBox.editorBorder", new XPValue(new EmptyBorder(1,2,1,1),
 674                                                  new EmptyBorder(1,4,1,4)),
 675             "ComboBox.disabledBackground",
 676                         new XPColorValue(Part.CP_COMBOBOX, State.DISABLED,
 677                         Prop.FILLCOLOR, DisabledTextBackground),
 678             "ComboBox.disabledForeground",
 679                         new XPColorValue(Part.CP_COMBOBOX, State.DISABLED,
 680                         Prop.TEXTCOLOR, InactiveTextColor),
 681             "ComboBox.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[] {
 682                    "ESCAPE", "hidePopup",
 683                   "PAGE_UP", "pageUpPassThrough",
 684                 "PAGE_DOWN", "pageDownPassThrough",
 685                      "HOME", "homePassThrough",
 686                       "END", "endPassThrough",
 687                      "DOWN", "selectNext2",
 688                   "KP_DOWN", "selectNext2",
 689                        "UP", "selectPrevious2",
 690                     "KP_UP", "selectPrevious2",
 691                     "ENTER", "enterPressed",
 692                        "F4", "togglePopup",
 693                  "alt DOWN", "togglePopup",
 694               "alt KP_DOWN", "togglePopup",
 695                    "alt UP", "togglePopup",
 696                 "alt KP_UP", "togglePopup"
 697               }),
 698 
 699             // DeskTop.
 700             "Desktop.background", new DesktopProperty(
 701                                                  "win.desktop.backgroundColor",
 702                                                   table.get("desktop")),
 703             "Desktop.ancestorInputMap",
 704                new UIDefaults.LazyInputMap(new Object[] {
 705                    "ctrl F5", "restore",
 706                    "ctrl F4", "close",
 707                    "ctrl F7", "move",
 708                    "ctrl F8", "resize",
 709                    "RIGHT", "right",
 710                    "KP_RIGHT", "right",
 711                    "LEFT", "left",
 712                    "KP_LEFT", "left",
 713                    "UP", "up",
 714                    "KP_UP", "up",
 715                    "DOWN", "down",
 716                    "KP_DOWN", "down",
 717                    "ESCAPE", "escape",
 718                    "ctrl F9", "minimize",
 719                    "ctrl F10", "maximize",
 720                    "ctrl F6", "selectNextFrame",
 721                    "ctrl TAB", "selectNextFrame",
 722                    "ctrl alt F6", "selectNextFrame",
 723                    "shift ctrl alt F6", "selectPreviousFrame",
 724                    "ctrl F12", "navigateNext",
 725                    "shift ctrl F12", "navigatePrevious"
 726                }),
 727 
 728             // DesktopIcon
 729             "DesktopIcon.width", Integer.valueOf(160),
 730 
 731             "EditorPane.font", ControlFont,
 732             "EditorPane.background", WindowBackgroundColor,
 733             "EditorPane.foreground", WindowTextColor,
 734             "EditorPane.selectionBackground", SelectionBackgroundColor,
 735             "EditorPane.selectionForeground", SelectionTextColor,
 736             "EditorPane.caretForeground", WindowTextColor,
 737             "EditorPane.inactiveForeground", InactiveTextColor,
 738             "EditorPane.inactiveBackground", WindowBackgroundColor,
 739             "EditorPane.disabledBackground", DisabledTextBackground,
 740 
 741             "FileChooser.homeFolderIcon",  new LazyWindowsIcon(null,
 742                                                                "icons/HomeFolder.gif"),
 743             "FileChooser.listFont", IconFont,
 744             "FileChooser.listViewBackground", new XPColorValue(Part.LVP_LISTVIEW, null, Prop.FILLCOLOR,
 745                                                                WindowBackgroundColor),
 746             "FileChooser.listViewBorder", new XPBorderValue(Part.LVP_LISTVIEW,
 747                (LazyValue) t -> BorderUIResource.getLoweredBevelBorderUIResource()),
 748             "FileChooser.listViewIcon",    new LazyWindowsIcon("fileChooserIcon ListView",
 749                                                                "icons/ListView.gif"),
 750             "FileChooser.listViewWindowsStyle", Boolean.TRUE,
 751             "FileChooser.detailsViewIcon", new LazyWindowsIcon("fileChooserIcon DetailsView",
 752                                                                "icons/DetailsView.gif"),
 753             "FileChooser.viewMenuIcon", new LazyWindowsIcon("fileChooserIcon ViewMenu",
 754                                                             "icons/ListView.gif"),
 755             "FileChooser.upFolderIcon",    new LazyWindowsIcon("fileChooserIcon UpFolder",
 756                                                                "icons/UpFolder.gif"),
 757             "FileChooser.newFolderIcon",   new LazyWindowsIcon("fileChooserIcon NewFolder",
 758                                                                "icons/NewFolder.gif"),
 759             "FileChooser.useSystemExtensionHiding", Boolean.TRUE,
 760 
 761             "FileChooser.usesSingleFilePane", Boolean.TRUE,
 762             "FileChooser.noPlacesBar", new DesktopProperty("win.comdlg.noPlacesBar",
 763                                                            Boolean.FALSE),
 764             "FileChooser.ancestorInputMap",
 765                new UIDefaults.LazyInputMap(new Object[] {
 766                      "ESCAPE", "cancelSelection",
 767                      "F2", "editFileName",
 768                      "F5", "refresh",
 769                      "BACK_SPACE", "Go Up"
 770                  }),
 771 
 772             "FileView.directoryIcon", SwingUtilities2.makeIcon(getClass(),
 773                                                                WindowsLookAndFeel.class,
 774                                                                "icons/Directory.gif"),
 775             "FileView.fileIcon", SwingUtilities2.makeIcon(getClass(),
 776                                                           WindowsLookAndFeel.class,
 777                                                           "icons/File.gif"),
 778             "FileView.computerIcon", SwingUtilities2.makeIcon(getClass(),
 779                                                               WindowsLookAndFeel.class,
 780                                                               "icons/Computer.gif"),
 781             "FileView.hardDriveIcon", SwingUtilities2.makeIcon(getClass(),
 782                                                                WindowsLookAndFeel.class,
 783                                                                "icons/HardDrive.gif"),
 784             "FileView.floppyDriveIcon", SwingUtilities2.makeIcon(getClass(),
 785                                                                  WindowsLookAndFeel.class,
 786                                                                  "icons/FloppyDrive.gif"),
 787 
 788             "FormattedTextField.font", ControlFont,
 789             "InternalFrame.titleFont", WindowFont,
 790             "InternalFrame.titlePaneHeight",   TitlePaneHeight,
 791             "InternalFrame.titleButtonWidth",  TitleButtonWidth,
 792             "InternalFrame.titleButtonHeight", TitleButtonHeight,
 793             "InternalFrame.titleButtonToolTipsOn", hotTrackingOn,
 794             "InternalFrame.borderColor", ControlBackgroundColor,
 795             "InternalFrame.borderShadow", ControlShadowColor,
 796             "InternalFrame.borderDarkShadow", ControlDarkShadowColor,
 797             "InternalFrame.borderHighlight", ControlHighlightColor,
 798             "InternalFrame.borderLight", ControlLightColor,
 799             "InternalFrame.borderWidth", WindowBorderWidth,
 800             "InternalFrame.minimizeIconBackground", ControlBackgroundColor,
 801             "InternalFrame.resizeIconHighlight", ControlLightColor,
 802             "InternalFrame.resizeIconShadow", ControlShadowColor,
 803             "InternalFrame.activeBorderColor", new DesktopProperty(
 804                                                        "win.frame.activeBorderColor",
 805                                                        table.get("windowBorder")),
 806             "InternalFrame.inactiveBorderColor", new DesktopProperty(
 807                                                        "win.frame.inactiveBorderColor",
 808                                                        table.get("windowBorder")),
 809             "InternalFrame.activeTitleBackground", new DesktopProperty(
 810                                                         "win.frame.activeCaptionColor",
 811                                                          table.get("activeCaption")),
 812             "InternalFrame.activeTitleGradient", new DesktopProperty(
 813                                                         "win.frame.activeCaptionGradientColor",
 814                                                          table.get("activeCaption")),
 815             "InternalFrame.activeTitleForeground", new DesktopProperty(
 816                                                         "win.frame.captionTextColor",
 817                                                          table.get("activeCaptionText")),
 818             "InternalFrame.inactiveTitleBackground", new DesktopProperty(
 819                                                         "win.frame.inactiveCaptionColor",
 820                                                          table.get("inactiveCaption")),
 821             "InternalFrame.inactiveTitleGradient", new DesktopProperty(
 822                                                         "win.frame.inactiveCaptionGradientColor",
 823                                                          table.get("inactiveCaption")),
 824             "InternalFrame.inactiveTitleForeground", new DesktopProperty(
 825                                                         "win.frame.inactiveCaptionTextColor",
 826                                                          table.get("inactiveCaptionText")),
 827 
 828             "InternalFrame.maximizeIcon",
 829                 WindowsIconFactory.createFrameMaximizeIcon(),
 830             "InternalFrame.minimizeIcon",
 831                 WindowsIconFactory.createFrameMinimizeIcon(),
 832             "InternalFrame.iconifyIcon",
 833                 WindowsIconFactory.createFrameIconifyIcon(),
 834             "InternalFrame.closeIcon",
 835                 WindowsIconFactory.createFrameCloseIcon(),
 836             "InternalFrame.icon",
 837                 (LazyValue) t -> new WindowsInternalFrameTitlePane.ScalableIconUIResource(new Object[]{
 838                     // The constructor takes one arg: an array of UIDefaults.LazyValue
 839                     // representing the icons
 840                         SwingUtilities2.makeIcon(getClass(), BasicLookAndFeel.class, "icons/JavaCup16.png"),
 841                         SwingUtilities2.makeIcon(getClass(), WindowsLookAndFeel.class, "icons/JavaCup32.png")
 842                 }),
 843             // Internal Frame Auditory Cue Mappings
 844             "InternalFrame.closeSound", "win.sound.close",
 845             "InternalFrame.maximizeSound", "win.sound.maximize",
 846             "InternalFrame.minimizeSound", "win.sound.minimize",
 847             "InternalFrame.restoreDownSound", "win.sound.restoreDown",
 848             "InternalFrame.restoreUpSound", "win.sound.restoreUp",
 849 
 850             "InternalFrame.windowBindings", new Object[] {
 851                 "shift ESCAPE", "showSystemMenu",
 852                   "ctrl SPACE", "showSystemMenu",
 853                       "ESCAPE", "hideSystemMenu"},
 854 
 855             // Label
 856             "Label.font", ControlFont,
 857             "Label.background", ControlBackgroundColor,
 858             "Label.foreground", WindowTextColor,
 859             "Label.disabledForeground", InactiveTextColor,
 860             "Label.disabledShadow", ControlHighlightColor,
 861 
 862             // List.
 863             "List.font", ControlFont,
 864             "List.background", WindowBackgroundColor,
 865             "List.foreground", WindowTextColor,
 866             "List.selectionBackground", SelectionBackgroundColor,
 867             "List.selectionForeground", SelectionTextColor,
 868             "List.lockToPositionOnScroll", Boolean.TRUE,
 869             "List.focusInputMap",
 870                new UIDefaults.LazyInputMap(new Object[] {
 871                            "ctrl C", "copy",
 872                            "ctrl V", "paste",
 873                            "ctrl X", "cut",
 874                              "COPY", "copy",
 875                             "PASTE", "paste",
 876                               "CUT", "cut",
 877                    "control INSERT", "copy",
 878                      "shift INSERT", "paste",
 879                      "shift DELETE", "cut",
 880                                "UP", "selectPreviousRow",
 881                             "KP_UP", "selectPreviousRow",
 882                          "shift UP", "selectPreviousRowExtendSelection",
 883                       "shift KP_UP", "selectPreviousRowExtendSelection",
 884                     "ctrl shift UP", "selectPreviousRowExtendSelection",
 885                  "ctrl shift KP_UP", "selectPreviousRowExtendSelection",
 886                           "ctrl UP", "selectPreviousRowChangeLead",
 887                        "ctrl KP_UP", "selectPreviousRowChangeLead",
 888                              "DOWN", "selectNextRow",
 889                           "KP_DOWN", "selectNextRow",
 890                        "shift DOWN", "selectNextRowExtendSelection",
 891                     "shift KP_DOWN", "selectNextRowExtendSelection",
 892                   "ctrl shift DOWN", "selectNextRowExtendSelection",
 893                "ctrl shift KP_DOWN", "selectNextRowExtendSelection",
 894                         "ctrl DOWN", "selectNextRowChangeLead",
 895                      "ctrl KP_DOWN", "selectNextRowChangeLead",
 896                              "LEFT", "selectPreviousColumn",
 897                           "KP_LEFT", "selectPreviousColumn",
 898                        "shift LEFT", "selectPreviousColumnExtendSelection",
 899                     "shift KP_LEFT", "selectPreviousColumnExtendSelection",
 900                   "ctrl shift LEFT", "selectPreviousColumnExtendSelection",
 901                "ctrl shift KP_LEFT", "selectPreviousColumnExtendSelection",
 902                         "ctrl LEFT", "selectPreviousColumnChangeLead",
 903                      "ctrl KP_LEFT", "selectPreviousColumnChangeLead",
 904                             "RIGHT", "selectNextColumn",
 905                          "KP_RIGHT", "selectNextColumn",
 906                       "shift RIGHT", "selectNextColumnExtendSelection",
 907                    "shift KP_RIGHT", "selectNextColumnExtendSelection",
 908                  "ctrl shift RIGHT", "selectNextColumnExtendSelection",
 909               "ctrl shift KP_RIGHT", "selectNextColumnExtendSelection",
 910                        "ctrl RIGHT", "selectNextColumnChangeLead",
 911                     "ctrl KP_RIGHT", "selectNextColumnChangeLead",
 912                              "HOME", "selectFirstRow",
 913                        "shift HOME", "selectFirstRowExtendSelection",
 914                   "ctrl shift HOME", "selectFirstRowExtendSelection",
 915                         "ctrl HOME", "selectFirstRowChangeLead",
 916                               "END", "selectLastRow",
 917                         "shift END", "selectLastRowExtendSelection",
 918                    "ctrl shift END", "selectLastRowExtendSelection",
 919                          "ctrl END", "selectLastRowChangeLead",
 920                           "PAGE_UP", "scrollUp",
 921                     "shift PAGE_UP", "scrollUpExtendSelection",
 922                "ctrl shift PAGE_UP", "scrollUpExtendSelection",
 923                      "ctrl PAGE_UP", "scrollUpChangeLead",
 924                         "PAGE_DOWN", "scrollDown",
 925                   "shift PAGE_DOWN", "scrollDownExtendSelection",
 926              "ctrl shift PAGE_DOWN", "scrollDownExtendSelection",
 927                    "ctrl PAGE_DOWN", "scrollDownChangeLead",
 928                            "ctrl A", "selectAll",
 929                        "ctrl SLASH", "selectAll",
 930                   "ctrl BACK_SLASH", "clearSelection",
 931                             "SPACE", "addToSelection",
 932                        "ctrl SPACE", "toggleAndAnchor",
 933                       "shift SPACE", "extendTo",
 934                  "ctrl shift SPACE", "moveSelectionTo"
 935                  }),
 936 
 937             // PopupMenu
 938             "PopupMenu.font", MenuFont,
 939             "PopupMenu.background", MenuBackgroundColor,
 940             "PopupMenu.foreground", MenuTextColor,
 941             "PopupMenu.popupSound", "win.sound.menuPopup",
 942             "PopupMenu.consumeEventOnClose", Boolean.TRUE,
 943 
 944             // Menus
 945             "Menu.font", MenuFont,
 946             "Menu.foreground", MenuTextColor,
 947             "Menu.background", MenuBackgroundColor,
 948             "Menu.useMenuBarBackgroundForTopLevel", Boolean.TRUE,
 949             "Menu.selectionForeground", SelectionTextColor,
 950             "Menu.selectionBackground", SelectionBackgroundColor,
 951             "Menu.acceleratorForeground", MenuTextColor,
 952             "Menu.acceleratorSelectionForeground", SelectionTextColor,
 953             "Menu.menuPopupOffsetX", Integer.valueOf(0),
 954             "Menu.menuPopupOffsetY", Integer.valueOf(0),
 955             "Menu.submenuPopupOffsetX", Integer.valueOf(-4),
 956             "Menu.submenuPopupOffsetY", Integer.valueOf(-3),
 957             "Menu.crossMenuMnemonic", Boolean.FALSE,
 958             "Menu.preserveTopLevelSelection", Boolean.TRUE,
 959 
 960             // MenuBar.
 961             "MenuBar.font", MenuFont,
 962             "MenuBar.background", new XPValue(MenuBarBackgroundColor,
 963                                               MenuBackgroundColor),
 964             "MenuBar.foreground", MenuTextColor,
 965             "MenuBar.shadow", ControlShadowColor,
 966             "MenuBar.highlight", ControlHighlightColor,
 967             "MenuBar.height", menuBarHeight,
 968             "MenuBar.rolloverEnabled", hotTrackingOn,
 969             "MenuBar.windowBindings", new Object[] {
 970                 "F10", "takeFocus" },
 971 
 972             "MenuItem.font", MenuFont,
 973             "MenuItem.acceleratorFont", MenuFont,
 974             "MenuItem.foreground", MenuTextColor,
 975             "MenuItem.background", MenuBackgroundColor,
 976             "MenuItem.selectionForeground", SelectionTextColor,
 977             "MenuItem.selectionBackground", SelectionBackgroundColor,
 978             "MenuItem.disabledForeground", InactiveTextColor,
 979             "MenuItem.acceleratorForeground", MenuTextColor,
 980             "MenuItem.acceleratorSelectionForeground", SelectionTextColor,
 981             "MenuItem.acceleratorDelimiter", menuItemAcceleratorDelimiter,
 982                  // Menu Item Auditory Cue Mapping
 983             "MenuItem.commandSound", "win.sound.menuCommand",
 984              // indicates that keyboard navigation won't skip disabled menu items
 985             "MenuItem.disabledAreNavigable", Boolean.TRUE,
 986 
 987             "RadioButton.font", ControlFont,
 988             "RadioButton.interiorBackground", WindowBackgroundColor,
 989             "RadioButton.background", ControlBackgroundColor,
 990             "RadioButton.foreground", WindowTextColor,
 991             "RadioButton.shadow", ControlShadowColor,
 992             "RadioButton.darkShadow", ControlDarkShadowColor,
 993             "RadioButton.light", ControlLightColor,
 994             "RadioButton.highlight", ControlHighlightColor,
 995             "RadioButton.focus", buttonFocusColor,
 996             "RadioButton.focusInputMap",
 997                new UIDefaults.LazyInputMap(new Object[] {
 998                           "SPACE", "pressed",
 999                  "released SPACE", "released"
1000               }),
1001             // margin is 2 all the way around, BasicBorders.RadioButtonBorder
1002             // is 2 all the way around too.
1003             "RadioButton.totalInsets", new Insets(4, 4, 4, 4),
1004 
1005 
1006             "RadioButtonMenuItem.font", MenuFont,
1007             "RadioButtonMenuItem.foreground", MenuTextColor,
1008             "RadioButtonMenuItem.background", MenuBackgroundColor,
1009             "RadioButtonMenuItem.selectionForeground", SelectionTextColor,
1010             "RadioButtonMenuItem.selectionBackground", SelectionBackgroundColor,
1011             "RadioButtonMenuItem.disabledForeground", InactiveTextColor,
1012             "RadioButtonMenuItem.acceleratorForeground", MenuTextColor,
1013             "RadioButtonMenuItem.acceleratorSelectionForeground", SelectionTextColor,
1014             "RadioButtonMenuItem.commandSound", "win.sound.menuCommand",
1015 
1016             // OptionPane.
1017             "OptionPane.font", MessageFont,
1018             "OptionPane.messageFont", MessageFont,
1019             "OptionPane.buttonFont", MessageFont,
1020             "OptionPane.background", ControlBackgroundColor,
1021             "OptionPane.foreground", WindowTextColor,
1022             "OptionPane.buttonMinimumWidth", new XPDLUValue(50, 50, SwingConstants.EAST),
1023             "OptionPane.messageForeground", ControlTextColor,
1024             "OptionPane.errorIcon",       new LazyWindowsIcon("optionPaneIcon Error",
1025                                                               "icons/Error.gif"),
1026             "OptionPane.informationIcon", new LazyWindowsIcon("optionPaneIcon Information",
1027                                                               "icons/Inform.gif"),
1028             "OptionPane.questionIcon",    new LazyWindowsIcon("optionPaneIcon Question",
1029                                                               "icons/Question.gif"),
1030             "OptionPane.warningIcon",     new LazyWindowsIcon("optionPaneIcon Warning",
1031                                                               "icons/Warn.gif"),
1032             "OptionPane.windowBindings", new Object[] {
1033                 "ESCAPE", "close" },
1034                  // Option Pane Auditory Cue Mappings
1035             "OptionPane.errorSound", "win.sound.hand", // Error
1036             "OptionPane.informationSound", "win.sound.asterisk", // Info Plain
1037             "OptionPane.questionSound", "win.sound.question", // Question
1038             "OptionPane.warningSound", "win.sound.exclamation", // Warning
1039 
1040             "FormattedTextField.focusInputMap",
1041               new UIDefaults.LazyInputMap(new Object[] {
1042                            "ctrl C", DefaultEditorKit.copyAction,
1043                            "ctrl V", DefaultEditorKit.pasteAction,
1044                            "ctrl X", DefaultEditorKit.cutAction,
1045                              "COPY", DefaultEditorKit.copyAction,
1046                             "PASTE", DefaultEditorKit.pasteAction,
1047                               "CUT", DefaultEditorKit.cutAction,
1048                    "control INSERT", DefaultEditorKit.copyAction,
1049                      "shift INSERT", DefaultEditorKit.pasteAction,
1050                      "shift DELETE", DefaultEditorKit.cutAction,
1051                        "shift LEFT", DefaultEditorKit.selectionBackwardAction,
1052                     "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction,
1053                       "shift RIGHT", DefaultEditorKit.selectionForwardAction,
1054                    "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction,
1055                         "ctrl LEFT", DefaultEditorKit.previousWordAction,
1056                      "ctrl KP_LEFT", DefaultEditorKit.previousWordAction,
1057                        "ctrl RIGHT", DefaultEditorKit.nextWordAction,
1058                     "ctrl KP_RIGHT", DefaultEditorKit.nextWordAction,
1059                   "ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
1060                "ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction,
1061                  "ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction,
1062               "ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction,
1063                            "ctrl A", DefaultEditorKit.selectAllAction,
1064                              "HOME", DefaultEditorKit.beginLineAction,
1065                               "END", DefaultEditorKit.endLineAction,
1066                        "shift HOME", DefaultEditorKit.selectionBeginLineAction,
1067                         "shift END", DefaultEditorKit.selectionEndLineAction,
1068                        "BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
1069                  "shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
1070                            "ctrl H", DefaultEditorKit.deletePrevCharAction,
1071                            "DELETE", DefaultEditorKit.deleteNextCharAction,
1072                       "ctrl DELETE", DefaultEditorKit.deleteNextWordAction,
1073                   "ctrl BACK_SPACE", DefaultEditorKit.deletePrevWordAction,
1074                             "RIGHT", DefaultEditorKit.forwardAction,
1075                              "LEFT", DefaultEditorKit.backwardAction,
1076                          "KP_RIGHT", DefaultEditorKit.forwardAction,
1077                           "KP_LEFT", DefaultEditorKit.backwardAction,
1078                             "ENTER", JTextField.notifyAction,
1079                   "ctrl BACK_SLASH", "unselect",
1080                    "control shift O", "toggle-componentOrientation",
1081                            "ESCAPE", "reset-field-edit",
1082                                "UP", "increment",
1083                             "KP_UP", "increment",
1084                              "DOWN", "decrement",
1085                           "KP_DOWN", "decrement",
1086               }),
1087             "FormattedTextField.inactiveBackground", ReadOnlyTextBackground,
1088             "FormattedTextField.disabledBackground", DisabledTextBackground,
1089 
1090             // *** Panel
1091             "Panel.font", ControlFont,
1092             "Panel.background", ControlBackgroundColor,
1093             "Panel.foreground", WindowTextColor,
1094 
1095             // *** PasswordField
1096             "PasswordField.font", ControlFont,
1097             "PasswordField.background", TextBackground,
1098             "PasswordField.foreground", WindowTextColor,
1099             "PasswordField.inactiveForeground", InactiveTextColor,      // for disabled
1100             "PasswordField.inactiveBackground", ReadOnlyTextBackground, // for readonly
1101             "PasswordField.disabledBackground", DisabledTextBackground, // for disabled
1102             "PasswordField.selectionBackground", SelectionBackgroundColor,
1103             "PasswordField.selectionForeground", SelectionTextColor,
1104             "PasswordField.caretForeground",WindowTextColor,
1105             "PasswordField.echoChar", new XPValue((char)0x25CF, '*'),
1106 
1107             // *** ProgressBar
1108             "ProgressBar.font", ControlFont,
1109             "ProgressBar.foreground",  SelectionBackgroundColor,
1110             "ProgressBar.background", ControlBackgroundColor,
1111             "ProgressBar.shadow", ControlShadowColor,
1112             "ProgressBar.highlight", ControlHighlightColor,
1113             "ProgressBar.selectionForeground", ControlBackgroundColor,
1114             "ProgressBar.selectionBackground", SelectionBackgroundColor,
1115             "ProgressBar.cellLength", Integer.valueOf(7),
1116             "ProgressBar.cellSpacing", Integer.valueOf(2),
1117             "ProgressBar.indeterminateInsets", new Insets(3, 3, 3, 3),
1118 
1119             // *** RootPane.
1120             // These bindings are only enabled when there is a default
1121             // button set on the rootpane.
1122             "RootPane.defaultButtonWindowKeyBindings", new Object[] {
1123                              "ENTER", "press",
1124                     "released ENTER", "release",
1125                         "ctrl ENTER", "press",
1126                "ctrl released ENTER", "release"
1127               },
1128 
1129             // *** ScrollBar.
1130             "ScrollBar.background", ScrollbarBackgroundColor,
1131             "ScrollBar.foreground", ControlBackgroundColor,
1132             "ScrollBar.track", white,
1133             "ScrollBar.trackForeground", ScrollbarBackgroundColor,
1134             "ScrollBar.trackHighlight", black,
1135             "ScrollBar.trackHighlightForeground", scrollBarTrackHighlight,
1136             "ScrollBar.thumb", ControlBackgroundColor,
1137             "ScrollBar.thumbHighlight", ControlHighlightColor,
1138             "ScrollBar.thumbDarkShadow", ControlDarkShadowColor,
1139             "ScrollBar.thumbShadow", ControlShadowColor,
1140             "ScrollBar.width", scrollBarWidth,
1141             "ScrollBar.ancestorInputMap",
1142                new UIDefaults.LazyInputMap(new Object[] {
1143                        "RIGHT", "positiveUnitIncrement",
1144                     "KP_RIGHT", "positiveUnitIncrement",
1145                         "DOWN", "positiveUnitIncrement",
1146                      "KP_DOWN", "positiveUnitIncrement",
1147                    "PAGE_DOWN", "positiveBlockIncrement",
1148               "ctrl PAGE_DOWN", "positiveBlockIncrement",
1149                         "LEFT", "negativeUnitIncrement",
1150                      "KP_LEFT", "negativeUnitIncrement",
1151                           "UP", "negativeUnitIncrement",
1152                        "KP_UP", "negativeUnitIncrement",
1153                      "PAGE_UP", "negativeBlockIncrement",
1154                 "ctrl PAGE_UP", "negativeBlockIncrement",
1155                         "HOME", "minScroll",
1156                          "END", "maxScroll"
1157                  }),
1158 
1159             // *** ScrollPane.
1160             "ScrollPane.font", ControlFont,
1161             "ScrollPane.background", ControlBackgroundColor,
1162             "ScrollPane.foreground", ControlTextColor,
1163             "ScrollPane.ancestorInputMap",
1164                new UIDefaults.LazyInputMap(new Object[] {
1165                            "RIGHT", "unitScrollRight",
1166                         "KP_RIGHT", "unitScrollRight",
1167                             "DOWN", "unitScrollDown",
1168                          "KP_DOWN", "unitScrollDown",
1169                             "LEFT", "unitScrollLeft",
1170                          "KP_LEFT", "unitScrollLeft",
1171                               "UP", "unitScrollUp",
1172                            "KP_UP", "unitScrollUp",
1173                          "PAGE_UP", "scrollUp",
1174                        "PAGE_DOWN", "scrollDown",
1175                     "ctrl PAGE_UP", "scrollLeft",
1176                   "ctrl PAGE_DOWN", "scrollRight",
1177                        "ctrl HOME", "scrollHome",
1178                         "ctrl END", "scrollEnd"
1179                  }),
1180 
1181             // *** Separator
1182             "Separator.background", ControlHighlightColor,
1183             "Separator.foreground", ControlShadowColor,
1184 
1185             // *** Slider.
1186             "Slider.font", ControlFont,
1187             "Slider.foreground", ControlBackgroundColor,
1188             "Slider.background", ControlBackgroundColor,
1189             "Slider.highlight", ControlHighlightColor,
1190             "Slider.shadow", ControlShadowColor,
1191             "Slider.focus", ControlDarkShadowColor,
1192             "Slider.focusInputMap",
1193                new UIDefaults.LazyInputMap(new Object[] {
1194                        "RIGHT", "positiveUnitIncrement",
1195                     "KP_RIGHT", "positiveUnitIncrement",
1196                         "DOWN", "negativeUnitIncrement",
1197                      "KP_DOWN", "negativeUnitIncrement",
1198                    "PAGE_DOWN", "negativeBlockIncrement",
1199                         "LEFT", "negativeUnitIncrement",
1200                      "KP_LEFT", "negativeUnitIncrement",
1201                           "UP", "positiveUnitIncrement",
1202                        "KP_UP", "positiveUnitIncrement",
1203                      "PAGE_UP", "positiveBlockIncrement",
1204                         "HOME", "minScroll",
1205                          "END", "maxScroll"
1206                  }),
1207 
1208             // Spinner
1209             "Spinner.font", ControlFont,
1210             "Spinner.ancestorInputMap",
1211                new UIDefaults.LazyInputMap(new Object[] {
1212                                "UP", "increment",
1213                             "KP_UP", "increment",
1214                              "DOWN", "decrement",
1215                           "KP_DOWN", "decrement",
1216                }),
1217 
1218             // *** SplitPane
1219             "SplitPane.background", ControlBackgroundColor,
1220             "SplitPane.highlight", ControlHighlightColor,
1221             "SplitPane.shadow", ControlShadowColor,
1222             "SplitPane.darkShadow", ControlDarkShadowColor,
1223             "SplitPane.dividerSize", Integer.valueOf(5),
1224             "SplitPane.ancestorInputMap",
1225                new UIDefaults.LazyInputMap(new Object[] {
1226                         "UP", "negativeIncrement",
1227                       "DOWN", "positiveIncrement",
1228                       "LEFT", "negativeIncrement",
1229                      "RIGHT", "positiveIncrement",
1230                      "KP_UP", "negativeIncrement",
1231                    "KP_DOWN", "positiveIncrement",
1232                    "KP_LEFT", "negativeIncrement",
1233                   "KP_RIGHT", "positiveIncrement",
1234                       "HOME", "selectMin",
1235                        "END", "selectMax",
1236                         "F8", "startResize",
1237                         "F6", "toggleFocus",
1238                   "ctrl TAB", "focusOutForward",
1239             "ctrl shift TAB", "focusOutBackward"
1240                }),
1241 
1242             // *** TabbedPane
1243             "TabbedPane.tabsOverlapBorder", new XPValue(Boolean.TRUE, Boolean.FALSE),
1244             "TabbedPane.tabInsets",         new XPValue(new InsetsUIResource(1, 4, 1, 4),
1245                                                         new InsetsUIResource(0, 4, 1, 4)),
1246             "TabbedPane.tabAreaInsets",     new XPValue(new InsetsUIResource(3, 2, 2, 2),
1247                                                         new InsetsUIResource(3, 2, 0, 2)),
1248             "TabbedPane.font", ControlFont,
1249             "TabbedPane.background", ControlBackgroundColor,
1250             "TabbedPane.foreground", ControlTextColor,
1251             "TabbedPane.highlight", ControlHighlightColor,
1252             "TabbedPane.light", ControlLightColor,
1253             "TabbedPane.shadow", ControlShadowColor,
1254             "TabbedPane.darkShadow", ControlDarkShadowColor,
1255             "TabbedPane.focus", ControlTextColor,
1256             "TabbedPane.focusInputMap",
1257               new UIDefaults.LazyInputMap(new Object[] {
1258                          "RIGHT", "navigateRight",
1259                       "KP_RIGHT", "navigateRight",
1260                           "LEFT", "navigateLeft",
1261                        "KP_LEFT", "navigateLeft",
1262                             "UP", "navigateUp",
1263                          "KP_UP", "navigateUp",
1264                           "DOWN", "navigateDown",
1265                        "KP_DOWN", "navigateDown",
1266                      "ctrl DOWN", "requestFocusForVisibleComponent",
1267                   "ctrl KP_DOWN", "requestFocusForVisibleComponent",
1268                 }),
1269             "TabbedPane.ancestorInputMap",
1270                new UIDefaults.LazyInputMap(new Object[] {
1271                          "ctrl TAB", "navigateNext",
1272                    "ctrl shift TAB", "navigatePrevious",
1273                    "ctrl PAGE_DOWN", "navigatePageDown",
1274                      "ctrl PAGE_UP", "navigatePageUp",
1275                           "ctrl UP", "requestFocus",
1276                        "ctrl KP_UP", "requestFocus",
1277                  }),
1278 
1279             // *** Table
1280             "Table.font", ControlFont,
1281             "Table.foreground", ControlTextColor,  // cell text color
1282             "Table.background", WindowBackgroundColor,  // cell background color
1283             "Table.highlight", ControlHighlightColor,
1284             "Table.light", ControlLightColor,
1285             "Table.shadow", ControlShadowColor,
1286             "Table.darkShadow", ControlDarkShadowColor,
1287             "Table.selectionForeground", SelectionTextColor,
1288             "Table.selectionBackground", SelectionBackgroundColor,
1289             "Table.gridColor", gray,  // grid line color
1290             "Table.focusCellBackground", WindowBackgroundColor,
1291             "Table.focusCellForeground", ControlTextColor,
1292             "Table.ancestorInputMap",
1293                new UIDefaults.LazyInputMap(new Object[] {
1294                                "ctrl C", "copy",
1295                                "ctrl V", "paste",
1296                                "ctrl X", "cut",
1297                                  "COPY", "copy",
1298                                 "PASTE", "paste",
1299                                   "CUT", "cut",
1300                        "control INSERT", "copy",
1301                          "shift INSERT", "paste",
1302                          "shift DELETE", "cut",
1303                                 "RIGHT", "selectNextColumn",
1304                              "KP_RIGHT", "selectNextColumn",
1305                           "shift RIGHT", "selectNextColumnExtendSelection",
1306                        "shift KP_RIGHT", "selectNextColumnExtendSelection",
1307                      "ctrl shift RIGHT", "selectNextColumnExtendSelection",
1308                   "ctrl shift KP_RIGHT", "selectNextColumnExtendSelection",
1309                            "ctrl RIGHT", "selectNextColumnChangeLead",
1310                         "ctrl KP_RIGHT", "selectNextColumnChangeLead",
1311                                  "LEFT", "selectPreviousColumn",
1312                               "KP_LEFT", "selectPreviousColumn",
1313                            "shift LEFT", "selectPreviousColumnExtendSelection",
1314                         "shift KP_LEFT", "selectPreviousColumnExtendSelection",
1315                       "ctrl shift LEFT", "selectPreviousColumnExtendSelection",
1316                    "ctrl shift KP_LEFT", "selectPreviousColumnExtendSelection",
1317                             "ctrl LEFT", "selectPreviousColumnChangeLead",
1318                          "ctrl KP_LEFT", "selectPreviousColumnChangeLead",
1319                                  "DOWN", "selectNextRow",
1320                               "KP_DOWN", "selectNextRow",
1321                            "shift DOWN", "selectNextRowExtendSelection",
1322                         "shift KP_DOWN", "selectNextRowExtendSelection",
1323                       "ctrl shift DOWN", "selectNextRowExtendSelection",
1324                    "ctrl shift KP_DOWN", "selectNextRowExtendSelection",
1325                             "ctrl DOWN", "selectNextRowChangeLead",
1326                          "ctrl KP_DOWN", "selectNextRowChangeLead",
1327                                    "UP", "selectPreviousRow",
1328                                 "KP_UP", "selectPreviousRow",
1329                              "shift UP", "selectPreviousRowExtendSelection",
1330                           "shift KP_UP", "selectPreviousRowExtendSelection",
1331                         "ctrl shift UP", "selectPreviousRowExtendSelection",
1332                      "ctrl shift KP_UP", "selectPreviousRowExtendSelection",
1333                               "ctrl UP", "selectPreviousRowChangeLead",
1334                            "ctrl KP_UP", "selectPreviousRowChangeLead",
1335                                  "HOME", "selectFirstColumn",
1336                            "shift HOME", "selectFirstColumnExtendSelection",
1337                       "ctrl shift HOME", "selectFirstRowExtendSelection",
1338                             "ctrl HOME", "selectFirstRow",
1339                                   "END", "selectLastColumn",
1340                             "shift END", "selectLastColumnExtendSelection",
1341                        "ctrl shift END", "selectLastRowExtendSelection",
1342                              "ctrl END", "selectLastRow",
1343                               "PAGE_UP", "scrollUpChangeSelection",
1344                         "shift PAGE_UP", "scrollUpExtendSelection",
1345                    "ctrl shift PAGE_UP", "scrollLeftExtendSelection",
1346                          "ctrl PAGE_UP", "scrollLeftChangeSelection",
1347                             "PAGE_DOWN", "scrollDownChangeSelection",
1348                       "shift PAGE_DOWN", "scrollDownExtendSelection",
1349                  "ctrl shift PAGE_DOWN", "scrollRightExtendSelection",
1350                        "ctrl PAGE_DOWN", "scrollRightChangeSelection",
1351                                   "TAB", "selectNextColumnCell",
1352                             "shift TAB", "selectPreviousColumnCell",
1353                                 "ENTER", "selectNextRowCell",
1354                           "shift ENTER", "selectPreviousRowCell",
1355                                "ctrl A", "selectAll",
1356                            "ctrl SLASH", "selectAll",
1357                       "ctrl BACK_SLASH", "clearSelection",
1358                                "ESCAPE", "cancel",
1359                                    "F2", "startEditing",
1360                                 "SPACE", "addToSelection",
1361                            "ctrl SPACE", "toggleAndAnchor",
1362                           "shift SPACE", "extendTo",
1363                      "ctrl shift SPACE", "moveSelectionTo",
1364                                    "F8", "focusHeader"
1365                  }),
1366             "Table.sortIconHighlight", ControlShadowColor,
1367             "Table.sortIconLight", white,
1368 
1369             "TableHeader.font", ControlFont,
1370             "TableHeader.foreground", ControlTextColor, // header text color
1371             "TableHeader.background", ControlBackgroundColor, // header background
1372             "TableHeader.focusCellBackground",
1373                 new XPValue(XPValue.NULL_VALUE,     // use default bg from XP styles
1374                             WindowBackgroundColor), // or white bg otherwise
1375 
1376             // *** TextArea
1377             "TextArea.font", FixedControlFont,
1378             "TextArea.background", WindowBackgroundColor,
1379             "TextArea.foreground", WindowTextColor,
1380             "TextArea.inactiveForeground", InactiveTextColor,
1381             "TextArea.inactiveBackground", WindowBackgroundColor,
1382             "TextArea.disabledBackground", DisabledTextBackground,
1383             "TextArea.selectionBackground", SelectionBackgroundColor,
1384             "TextArea.selectionForeground", SelectionTextColor,
1385             "TextArea.caretForeground", WindowTextColor,
1386 
1387             // *** TextField
1388             "TextField.font", ControlFont,
1389             "TextField.background", TextBackground,
1390             "TextField.foreground", WindowTextColor,
1391             "TextField.shadow", ControlShadowColor,
1392             "TextField.darkShadow", ControlDarkShadowColor,
1393             "TextField.light", ControlLightColor,
1394             "TextField.highlight", ControlHighlightColor,
1395             "TextField.inactiveForeground", InactiveTextColor,      // for disabled
1396             "TextField.inactiveBackground", ReadOnlyTextBackground, // for readonly
1397             "TextField.disabledBackground", DisabledTextBackground, // for disabled
1398             "TextField.selectionBackground", SelectionBackgroundColor,
1399             "TextField.selectionForeground", SelectionTextColor,
1400             "TextField.caretForeground", WindowTextColor,
1401 
1402             // *** TextPane
1403             "TextPane.font", ControlFont,
1404             "TextPane.background", WindowBackgroundColor,
1405             "TextPane.foreground", WindowTextColor,
1406             "TextPane.selectionBackground", SelectionBackgroundColor,
1407             "TextPane.selectionForeground", SelectionTextColor,
1408             "TextPane.inactiveBackground", WindowBackgroundColor,
1409             "TextPane.disabledBackground", DisabledTextBackground,
1410             "TextPane.caretForeground", WindowTextColor,
1411 
1412             // *** TitledBorder
1413             "TitledBorder.font", ControlFont,
1414             "TitledBorder.titleColor",
1415                         new XPColorValue(Part.BP_GROUPBOX, null, Prop.TEXTCOLOR,
1416                                          WindowTextColor),
1417 
1418             // *** ToggleButton
1419             "ToggleButton.font", ControlFont,
1420             "ToggleButton.background", ControlBackgroundColor,
1421             "ToggleButton.foreground", ControlTextColor,
1422             "ToggleButton.shadow", ControlShadowColor,
1423             "ToggleButton.darkShadow", ControlDarkShadowColor,
1424             "ToggleButton.light", ControlLightColor,
1425             "ToggleButton.highlight", ControlHighlightColor,
1426             "ToggleButton.focus", ControlTextColor,
1427             "ToggleButton.textShiftOffset", Integer.valueOf(1),
1428             "ToggleButton.focusInputMap",
1429               new UIDefaults.LazyInputMap(new Object[] {
1430                             "SPACE", "pressed",
1431                    "released SPACE", "released"
1432                 }),
1433 
1434             // *** ToolBar
1435             "ToolBar.font", MenuFont,
1436             "ToolBar.background", ControlBackgroundColor,
1437             "ToolBar.foreground", ControlTextColor,
1438             "ToolBar.shadow", ControlShadowColor,
1439             "ToolBar.darkShadow", ControlDarkShadowColor,
1440             "ToolBar.light", ControlLightColor,
1441             "ToolBar.highlight", ControlHighlightColor,
1442             "ToolBar.dockingBackground", ControlBackgroundColor,
1443             "ToolBar.dockingForeground", red,
1444             "ToolBar.floatingBackground", ControlBackgroundColor,
1445             "ToolBar.floatingForeground", darkGray,
1446             "ToolBar.ancestorInputMap",
1447                new UIDefaults.LazyInputMap(new Object[] {
1448                         "UP", "navigateUp",
1449                      "KP_UP", "navigateUp",
1450                       "DOWN", "navigateDown",
1451                    "KP_DOWN", "navigateDown",
1452                       "LEFT", "navigateLeft",
1453                    "KP_LEFT", "navigateLeft",
1454                      "RIGHT", "navigateRight",
1455                   "KP_RIGHT", "navigateRight"
1456                  }),
1457             "ToolBar.separatorSize", null,
1458 
1459             // *** ToolTip
1460             "ToolTip.font", ToolTipFont,
1461             "ToolTip.background", new DesktopProperty("win.tooltip.backgroundColor", table.get("info")),
1462             "ToolTip.foreground", new DesktopProperty("win.tooltip.textColor", table.get("infoText")),
1463 
1464         // *** ToolTipManager
1465             "ToolTipManager.enableToolTipMode", "activeApplication",
1466 
1467         // *** Tree
1468             "Tree.selectionBorderColor", black,
1469             "Tree.drawDashedFocusIndicator", Boolean.TRUE,
1470             "Tree.lineTypeDashed", Boolean.TRUE,
1471             "Tree.font", ControlFont,
1472             "Tree.background", WindowBackgroundColor,
1473             "Tree.foreground", WindowTextColor,
1474             "Tree.hash", gray,
1475             "Tree.leftChildIndent", Integer.valueOf(8),
1476             "Tree.rightChildIndent", Integer.valueOf(11),
1477             "Tree.textForeground", WindowTextColor,
1478             "Tree.textBackground", WindowBackgroundColor,
1479             "Tree.selectionForeground", SelectionTextColor,
1480             "Tree.selectionBackground", SelectionBackgroundColor,
1481             "Tree.expandedIcon", treeExpandedIcon,
1482             "Tree.collapsedIcon", treeCollapsedIcon,
1483             "Tree.openIcon",   new ActiveWindowsIcon("win.icon.shellIconBPP",
1484                                    "shell32Icon 5", "icons/TreeOpen.gif"),
1485             "Tree.closedIcon", new ActiveWindowsIcon("win.icon.shellIconBPP",
1486                                    "shell32Icon 4", "icons/TreeClosed.gif"),
1487             "Tree.focusInputMap",
1488                new UIDefaults.LazyInputMap(new Object[] {
1489                                     "ADD", "expand",
1490                                "SUBTRACT", "collapse",
1491                                  "ctrl C", "copy",
1492                                  "ctrl V", "paste",
1493                                  "ctrl X", "cut",
1494                                    "COPY", "copy",
1495                                   "PASTE", "paste",
1496                                     "CUT", "cut",
1497                          "control INSERT", "copy",
1498                            "shift INSERT", "paste",
1499                            "shift DELETE", "cut",
1500                                      "UP", "selectPrevious",
1501                                   "KP_UP", "selectPrevious",
1502                                "shift UP", "selectPreviousExtendSelection",
1503                             "shift KP_UP", "selectPreviousExtendSelection",
1504                           "ctrl shift UP", "selectPreviousExtendSelection",
1505                        "ctrl shift KP_UP", "selectPreviousExtendSelection",
1506                                 "ctrl UP", "selectPreviousChangeLead",
1507                              "ctrl KP_UP", "selectPreviousChangeLead",
1508                                    "DOWN", "selectNext",
1509                                 "KP_DOWN", "selectNext",
1510                              "shift DOWN", "selectNextExtendSelection",
1511                           "shift KP_DOWN", "selectNextExtendSelection",
1512                         "ctrl shift DOWN", "selectNextExtendSelection",
1513                      "ctrl shift KP_DOWN", "selectNextExtendSelection",
1514                               "ctrl DOWN", "selectNextChangeLead",
1515                            "ctrl KP_DOWN", "selectNextChangeLead",
1516                                   "RIGHT", "selectChild",
1517                                "KP_RIGHT", "selectChild",
1518                                    "LEFT", "selectParent",
1519                                 "KP_LEFT", "selectParent",
1520                                 "PAGE_UP", "scrollUpChangeSelection",
1521                           "shift PAGE_UP", "scrollUpExtendSelection",
1522                      "ctrl shift PAGE_UP", "scrollUpExtendSelection",
1523                            "ctrl PAGE_UP", "scrollUpChangeLead",
1524                               "PAGE_DOWN", "scrollDownChangeSelection",
1525                         "shift PAGE_DOWN", "scrollDownExtendSelection",
1526                    "ctrl shift PAGE_DOWN", "scrollDownExtendSelection",
1527                          "ctrl PAGE_DOWN", "scrollDownChangeLead",
1528                                    "HOME", "selectFirst",
1529                              "shift HOME", "selectFirstExtendSelection",
1530                         "ctrl shift HOME", "selectFirstExtendSelection",
1531                               "ctrl HOME", "selectFirstChangeLead",
1532                                     "END", "selectLast",
1533                               "shift END", "selectLastExtendSelection",
1534                          "ctrl shift END", "selectLastExtendSelection",
1535                                "ctrl END", "selectLastChangeLead",
1536                                      "F2", "startEditing",
1537                                  "ctrl A", "selectAll",
1538                              "ctrl SLASH", "selectAll",
1539                         "ctrl BACK_SLASH", "clearSelection",
1540                               "ctrl LEFT", "scrollLeft",
1541                            "ctrl KP_LEFT", "scrollLeft",
1542                              "ctrl RIGHT", "scrollRight",
1543                           "ctrl KP_RIGHT", "scrollRight",
1544                                   "SPACE", "addToSelection",
1545                              "ctrl SPACE", "toggleAndAnchor",
1546                             "shift SPACE", "extendTo",
1547                        "ctrl shift SPACE", "moveSelectionTo"
1548                  }),
1549             "Tree.ancestorInputMap",
1550                new UIDefaults.LazyInputMap(new Object[] {
1551                      "ESCAPE", "cancel"
1552                  }),
1553 
1554             // *** Viewport
1555             "Viewport.font", ControlFont,
1556             "Viewport.background", ControlBackgroundColor,
1557             "Viewport.foreground", WindowTextColor,
1558 
1559 
1560         };
1561 
1562         table.putDefaults(defaults);
1563         table.putDefaults(getLazyValueDefaults());
1564         initVistaComponentDefaults(table);
1565     }
1566 
1567     static boolean isOnVista() {
1568         return OSInfo.getOSType() == OSInfo.OSType.WINDOWS
1569                 && OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_VISTA) >= 0;
1570     }
1571 
1572     static boolean isOnWindows7() {
1573         return OSInfo.getOSType() == OSInfo.OSType.WINDOWS
1574                 && OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_7) >= 0;
1575     }
1576 
1577     private void initVistaComponentDefaults(UIDefaults table) {
1578         if (! isOnVista()) {
1579             return;
1580         }
1581         /* START handling menus for Vista */
1582         String[] menuClasses = { "MenuItem", "Menu",
1583                 "CheckBoxMenuItem", "RadioButtonMenuItem",
1584         };
1585 
1586         Object menuDefaults[] = new Object[menuClasses.length * 2];
1587 
1588         /* all the menus need to be non opaque. */
1589         for (int i = 0, j = 0; i < menuClasses.length; i++) {
1590             String key = menuClasses[i] + ".opaque";
1591             Object oldValue = table.get(key);
1592             menuDefaults[j++] = key;
1593             menuDefaults[j++] =
1594                 new XPValue(Boolean.FALSE, oldValue);
1595         }
1596         table.putDefaults(menuDefaults);
1597 
1598         /*
1599          * acceleratorSelectionForeground color is the same as
1600          * acceleratorForeground
1601          */
1602         for (int i = 0, j = 0; i < menuClasses.length; i++) {
1603             String key = menuClasses[i] + ".acceleratorSelectionForeground";
1604             Object oldValue = table.get(key);
1605             menuDefaults[j++] = key;
1606             menuDefaults[j++] =
1607                 new XPValue(
1608                     table.getColor(
1609                         menuClasses[i] + ".acceleratorForeground"),
1610                         oldValue);
1611         }
1612         table.putDefaults(menuDefaults);
1613 
1614         /* they have the same MenuItemCheckIconFactory */
1615         VistaMenuItemCheckIconFactory menuItemCheckIconFactory =
1616             WindowsIconFactory.getMenuItemCheckIconFactory();
1617         for (int i = 0, j = 0; i < menuClasses.length; i++) {
1618             String key = menuClasses[i] + ".checkIconFactory";
1619             Object oldValue = table.get(key);
1620             menuDefaults[j++] = key;
1621             menuDefaults[j++] =
1622                 new XPValue(menuItemCheckIconFactory, oldValue);
1623         }
1624         table.putDefaults(menuDefaults);
1625 
1626         for (int i = 0, j = 0; i < menuClasses.length; i++) {
1627             String key = menuClasses[i] + ".checkIcon";
1628             Object oldValue = table.get(key);
1629             menuDefaults[j++] = key;
1630             menuDefaults[j++] =
1631                 new XPValue(menuItemCheckIconFactory.getIcon(menuClasses[i]),
1632                     oldValue);
1633         }
1634         table.putDefaults(menuDefaults);
1635 
1636 
1637         /* height can be even */
1638         for (int i = 0, j = 0; i < menuClasses.length; i++) {
1639             String key = menuClasses[i] + ".evenHeight";
1640             Object oldValue = table.get(key);
1641             menuDefaults[j++] = key;
1642             menuDefaults[j++] = new XPValue(Boolean.TRUE, oldValue);
1643         }
1644         table.putDefaults(menuDefaults);
1645 
1646         /*For Windows7 margin and checkIconOffset should be greater than 0 */
1647         if (!isOnWindows7()) {
1648             /* no margins */
1649             InsetsUIResource insets = new InsetsUIResource(0, 0, 0, 0);
1650             for (int i = 0, j = 0; i < menuClasses.length; i++) {
1651                 String key = menuClasses[i] + ".margin";
1652                 Object oldValue = table.get(key);
1653                 menuDefaults[j++] = key;
1654                 menuDefaults[j++] = new XPValue(insets, oldValue);
1655             }
1656             table.putDefaults(menuDefaults);
1657 
1658             /* set checkIcon offset */
1659             Integer checkIconOffsetInteger =
1660                 Integer.valueOf(0);
1661             for (int i = 0, j = 0; i < menuClasses.length; i++) {
1662                 String key = menuClasses[i] + ".checkIconOffset";
1663                 Object oldValue = table.get(key);
1664                 menuDefaults[j++] = key;
1665                 menuDefaults[j++] =
1666                     new XPValue(checkIconOffsetInteger, oldValue);
1667             }
1668             table.putDefaults(menuDefaults);
1669         }
1670         /* set width of the gap after check icon */
1671         Integer afterCheckIconGap = WindowsPopupMenuUI.getSpanBeforeGutter()
1672                 + WindowsPopupMenuUI.getGutterWidth()
1673                 + WindowsPopupMenuUI.getSpanAfterGutter();
1674         for (int i = 0, j = 0; i < menuClasses.length; i++) {
1675             String key = menuClasses[i] + ".afterCheckIconGap";
1676             Object oldValue = table.get(key);
1677             menuDefaults[j++] = key;
1678             menuDefaults[j++] =
1679                 new XPValue(afterCheckIconGap, oldValue);
1680         }
1681         table.putDefaults(menuDefaults);
1682 
1683         /* text is started after this position */
1684         Object minimumTextOffset = new UIDefaults.ActiveValue() {
1685             public Object createValue(UIDefaults table) {
1686                 return VistaMenuItemCheckIconFactory.getIconWidth()
1687                 + WindowsPopupMenuUI.getSpanBeforeGutter()
1688                 + WindowsPopupMenuUI.getGutterWidth()
1689                 + WindowsPopupMenuUI.getSpanAfterGutter();
1690             }
1691         };
1692         for (int i = 0, j = 0; i < menuClasses.length; i++) {
1693             String key = menuClasses[i] + ".minimumTextOffset";
1694             Object oldValue = table.get(key);
1695             menuDefaults[j++] = key;
1696             menuDefaults[j++] = new XPValue(minimumTextOffset, oldValue);
1697         }
1698         table.putDefaults(menuDefaults);
1699 
1700         /*
1701          * JPopupMenu has a bit of free space around menu items
1702          */
1703         String POPUP_MENU_BORDER = "PopupMenu.border";
1704 
1705         Object popupMenuBorder = new XPBorderValue(Part.MENU,
1706             (LazyValue) t -> BasicBorders.getInternalFrameBorder(),
1707                   BorderFactory.createEmptyBorder(2, 2, 2, 2));
1708         table.put(POPUP_MENU_BORDER, popupMenuBorder);
1709         /* END handling menus for Vista */
1710 
1711         /* START table handling for Vista */
1712         table.put("Table.ascendingSortIcon", new XPValue(
1713             new SkinIcon(Part.HP_HEADERSORTARROW, State.SORTEDDOWN),
1714                (LazyValue) t -> new ClassicSortArrowIcon(true)));
1715         table.put("Table.descendingSortIcon", new XPValue(
1716             new SkinIcon(Part.HP_HEADERSORTARROW, State.SORTEDUP),
1717                (LazyValue) t -> new ClassicSortArrowIcon(false)));
1718         /* END table handling for Vista */
1719     }
1720 
1721     /**
1722      * If we support loading of fonts from the desktop this will return
1723      * a DesktopProperty representing the font. If the font can't be
1724      * represented in the current encoding this will return null and
1725      * turn off the use of system fonts.
1726      */
1727     private Object getDesktopFontValue(String fontName, Object backup) {
1728         if (useSystemFontSettings) {
1729             return new WindowsFontProperty(fontName, backup);
1730         }
1731         return null;
1732     }
1733 
1734     // When a desktop property change is detected, these classes must be
1735     // reinitialized in the defaults table to ensure the classes reference
1736     // the updated desktop property values (colors mostly)
1737     //
1738     private Object[] getLazyValueDefaults() {
1739 
1740         Object buttonBorder =
1741             new XPBorderValue(Part.BP_PUSHBUTTON,
1742                (LazyValue) t -> BasicBorders.getButtonBorder());
1743 
1744         Object textFieldBorder =
1745             new XPBorderValue(Part.EP_EDIT,
1746                (LazyValue) t -> BasicBorders.getTextFieldBorder());
1747 
1748         Object textFieldMargin =
1749             new XPValue(new InsetsUIResource(2, 2, 2, 2),
1750                         new InsetsUIResource(1, 1, 1, 1));
1751 
1752         Object spinnerBorder =
1753             new XPBorderValue(Part.EP_EDIT, textFieldBorder,
1754                               new EmptyBorder(2, 2, 2, 2));
1755 
1756         Object spinnerArrowInsets =
1757             new XPValue(new InsetsUIResource(1, 1, 1, 1),
1758                         null);
1759 
1760         Object comboBoxBorder = new XPBorderValue(Part.CP_COMBOBOX, textFieldBorder);
1761 
1762         // For focus rectangle for cells and trees.
1763         LazyValue focusCellHighlightBorder = t -> WindowsBorders.getFocusCellHighlightBorder();
1764 
1765         LazyValue etchedBorder = t -> BorderUIResource.getEtchedBorderUIResource();
1766 
1767         LazyValue internalFrameBorder = t -> WindowsBorders.getInternalFrameBorder();
1768 
1769         LazyValue loweredBevelBorder = t -> BorderUIResource.getLoweredBevelBorderUIResource();
1770 
1771 
1772         LazyValue marginBorder = t -> new BasicBorders.MarginBorder();
1773 
1774         LazyValue menuBarBorder = t -> BasicBorders.getMenuBarBorder();
1775 
1776 
1777         Object popupMenuBorder = new XPBorderValue(Part.MENU,
1778             (LazyValue) t -> BasicBorders.getInternalFrameBorder());
1779 
1780         // *** ProgressBar
1781         LazyValue progressBarBorder = t -> WindowsBorders.getProgressBarBorder();
1782 
1783         LazyValue radioButtonBorder = t -> BasicBorders.getRadioButtonBorder();
1784 
1785         Object scrollPaneBorder =
1786             new XPBorderValue(Part.LBP_LISTBOX, textFieldBorder);
1787 
1788         Object tableScrollPaneBorder =
1789             new XPBorderValue(Part.LBP_LISTBOX, loweredBevelBorder);
1790 
1791         LazyValue tableHeaderBorder = t -> WindowsBorders.getTableHeaderBorder();
1792 
1793         // *** ToolBar
1794         LazyValue toolBarBorder = t -> WindowsBorders.getToolBarBorder();
1795 
1796         // *** ToolTips
1797         LazyValue toolTipBorder = t -> BorderUIResource.getBlackLineBorderUIResource();
1798 
1799 
1800 
1801         LazyValue checkBoxIcon = t -> WindowsIconFactory.getCheckBoxIcon();
1802 
1803         LazyValue radioButtonIcon = t -> WindowsIconFactory.getRadioButtonIcon();
1804 
1805         LazyValue radioButtonMenuItemIcon = t -> WindowsIconFactory.getRadioButtonMenuItemIcon();
1806 
1807         LazyValue menuItemCheckIcon = t -> WindowsIconFactory.getMenuItemCheckIcon();
1808 
1809         LazyValue menuItemArrowIcon = t -> WindowsIconFactory.getMenuItemArrowIcon();
1810 
1811         LazyValue menuArrowIcon = t -> WindowsIconFactory.getMenuArrowIcon();
1812 
1813 
1814         Object[] lazyDefaults = {
1815             "Button.border", buttonBorder,
1816             "CheckBox.border", radioButtonBorder,
1817             "ComboBox.border", comboBoxBorder,
1818             "DesktopIcon.border", internalFrameBorder,
1819             "FormattedTextField.border", textFieldBorder,
1820             "FormattedTextField.margin", textFieldMargin,
1821             "InternalFrame.border", internalFrameBorder,
1822             "List.focusCellHighlightBorder", focusCellHighlightBorder,
1823             "Table.focusCellHighlightBorder", focusCellHighlightBorder,
1824             "Menu.border", marginBorder,
1825             "MenuBar.border", menuBarBorder,
1826             "MenuItem.border", marginBorder,
1827             "PasswordField.border", textFieldBorder,
1828             "PasswordField.margin", textFieldMargin,
1829             "PopupMenu.border", popupMenuBorder,
1830             "ProgressBar.border", progressBarBorder,
1831             "RadioButton.border", radioButtonBorder,
1832             "ScrollPane.border", scrollPaneBorder,
1833             "Spinner.border", spinnerBorder,
1834             "Spinner.arrowButtonInsets", spinnerArrowInsets,
1835             "Spinner.arrowButtonSize", new Dimension(17, 9),
1836             "Table.scrollPaneBorder", tableScrollPaneBorder,
1837             "TableHeader.cellBorder", tableHeaderBorder,
1838             "TextArea.margin", textFieldMargin,
1839             "TextField.border", textFieldBorder,
1840             "TextField.margin", textFieldMargin,
1841             "TitledBorder.border",
1842                         new XPBorderValue(Part.BP_GROUPBOX, etchedBorder),
1843             "ToggleButton.border", radioButtonBorder,
1844             "ToolBar.border", toolBarBorder,
1845             "ToolTip.border", toolTipBorder,
1846 
1847             "CheckBox.icon", checkBoxIcon,
1848             "Menu.arrowIcon", menuArrowIcon,
1849             "MenuItem.checkIcon", menuItemCheckIcon,
1850             "MenuItem.arrowIcon", menuItemArrowIcon,
1851             "RadioButton.icon", radioButtonIcon,
1852             "RadioButtonMenuItem.checkIcon", radioButtonMenuItemIcon,
1853             "InternalFrame.layoutTitlePaneAtOrigin",
1854                         new XPValue(Boolean.TRUE, Boolean.FALSE),
1855             "Table.ascendingSortIcon", new XPValue(
1856                (LazyValue) t -> new SortArrowIcon(true,"Table.sortIconColor"),
1857                   (LazyValue) t -> new ClassicSortArrowIcon(true)),
1858             "Table.descendingSortIcon", new XPValue(
1859                (LazyValue) t -> new SortArrowIcon(false,"Table.sortIconColor"),
1860                   (LazyValue) t -> new ClassicSortArrowIcon(false)),
1861         };
1862 
1863         return lazyDefaults;
1864     }
1865 
1866     public void uninitialize() {
1867         super.uninitialize();
1868 
1869         if (WindowsPopupMenuUI.mnemonicListener != null) {
1870             MenuSelectionManager.defaultManager().
1871                 removeChangeListener(WindowsPopupMenuUI.mnemonicListener);
1872         }
1873         KeyboardFocusManager.getCurrentKeyboardFocusManager().
1874             removeKeyEventPostProcessor(WindowsRootPaneUI.altProcessor);
1875         DesktopProperty.flushUnreferencedProperties();
1876     }
1877 
1878 
1879     // Toggle flag for drawing the mnemonic state
1880     private static boolean isMnemonicHidden = true;
1881 
1882     // Flag which indicates that the Win98/Win2k/WinME features
1883     // should be disabled.
1884     private static boolean isClassicWindows = false;
1885 
1886     /**
1887      * Sets the state of the hide mnemonic flag. This flag is used by the
1888      * component UI delegates to determine if the mnemonic should be rendered.
1889      * This method is a non operation if the underlying operating system
1890      * does not support the mnemonic hiding feature.
1891      *
1892      * @param hide true if mnemonics should be hidden
1893      * @since 1.4
1894      */
1895     public static void setMnemonicHidden(boolean hide) {
1896         if (UIManager.getBoolean("Button.showMnemonics") == true) {
1897             // Do not hide mnemonics if the UI defaults do not support this
1898             isMnemonicHidden = false;
1899         } else {
1900             isMnemonicHidden = hide;
1901         }
1902     }
1903 
1904     /**
1905      * Gets the state of the hide mnemonic flag. This only has meaning
1906      * if this feature is supported by the underlying OS.
1907      *
1908      * @return true if mnemonics are hidden, otherwise, false
1909      * @see #setMnemonicHidden
1910      * @since 1.4
1911      */
1912     public static boolean isMnemonicHidden() {
1913         if (UIManager.getBoolean("Button.showMnemonics") == true) {
1914             // Do not hide mnemonics if the UI defaults do not support this
1915             isMnemonicHidden = false;
1916         }
1917         return isMnemonicHidden;
1918     }
1919 
1920     /**
1921      * Gets the state of the flag which indicates if the old Windows
1922      * look and feel should be rendered. This flag is used by the
1923      * component UI delegates as a hint to determine which style the component
1924      * should be rendered.
1925      *
1926      * @return true if Windows 95 and Windows NT 4 look and feel should
1927      *         be rendered
1928      * @since 1.4
1929      */
1930     public static boolean isClassicWindows() {
1931         return isClassicWindows;
1932     }
1933 
1934     /**
1935      * <p>
1936      * Invoked when the user attempts an invalid operation,
1937      * such as pasting into an uneditable {@code JTextField}
1938      * that has focus.
1939      * </p>
1940      * <p>
1941      * If the user has enabled visual error indication on
1942      * the desktop, this method will flash the caption bar
1943      * of the active window. The user can also set the
1944      * property awt.visualbell=true to achieve the same
1945      * results.
1946      * </p>
1947      *
1948      * @param component Component the error occurred in, may be
1949      *                  null indicating the error condition is
1950      *                  not directly associated with a
1951      *                  {@code Component}.
1952      *
1953      * @see javax.swing.LookAndFeel#provideErrorFeedback
1954      */
1955      public void provideErrorFeedback(Component component) {
1956          super.provideErrorFeedback(component);
1957      }
1958 
1959     /**
1960      * {@inheritDoc}
1961      */
1962     public LayoutStyle getLayoutStyle() {
1963         LayoutStyle style = this.style;
1964         if (style == null) {
1965             style = new WindowsLayoutStyle();
1966             this.style = style;
1967         }
1968         return style;
1969     }
1970 
1971     // ********* Auditory Cue support methods and objects *********
1972 
1973     /**
1974      * Returns an {@code Action}.
1975      * <P>
1976      * This Action contains the information and logic to render an
1977      * auditory cue. The {@code Object} that is passed to this
1978      * method contains the information needed to render the auditory
1979      * cue. Normally, this {@code Object} is a {@code String}
1980      * that points to a {@code Toolkit desktopProperty}.
1981      * This {@code desktopProperty} is resolved by AWT and the
1982      * Windows OS.
1983      * <P>
1984      * This {@code Action}'s {@code actionPerformed} method
1985      * is fired by the {@code playSound} method.
1986      *
1987      * @return      an Action which knows how to render the auditory
1988      *              cue for one particular system or user activity
1989      * @see #playSound(Action)
1990      * @since 1.4
1991      */
1992     protected Action createAudioAction(Object key) {
1993         if (key != null) {
1994             String audioKey = (String)key;
1995             String audioValue = (String)UIManager.get(key);
1996             return new AudioAction(audioKey, audioValue);
1997         } else {
1998             return null;
1999         }
2000     }
2001 
2002     static void repaintRootPane(Component c) {
2003         JRootPane root = null;
2004         for (; c != null; c = c.getParent()) {
2005             if (c instanceof JRootPane) {
2006                 root = (JRootPane)c;
2007             }
2008         }
2009 
2010         if (root != null) {
2011             root.repaint();
2012         } else {
2013             c.repaint();
2014         }
2015     }
2016 
2017     /**
2018      * Pass the name String to the super constructor. This is used
2019      * later to identify the Action and decide whether to play it or
2020      * not. Store the resource String. It is used to get the audio
2021      * resource. In this case, the resource is a {@code Runnable}
2022      * supplied by {@code Toolkit}. This {@code Runnable} is
2023      * effectively a pointer down into the Win32 OS that knows how to
2024      * play the right sound.
2025      *
2026      * @since 1.4
2027      */
2028     @SuppressWarnings("serial") // Superclass is not serializable across versions
2029     private static class AudioAction extends AbstractAction {
2030         private Runnable audioRunnable;
2031         private String audioResource;
2032         /**
2033          * We use the String as the name of the Action and as a pointer to
2034          * the underlying OSes audio resource.
2035          */
2036         public AudioAction(String name, String resource) {
2037             super(name);
2038             audioResource = resource;
2039         }
2040         public void actionPerformed(ActionEvent e) {
2041             if (audioRunnable == null) {
2042                 audioRunnable = (Runnable)Toolkit.getDefaultToolkit().getDesktopProperty(audioResource);
2043             }
2044             if (audioRunnable != null) {
2045                 // Runnable appears to block until completed playing, hence
2046                 // start up another thread to handle playing.
2047                 new ManagedLocalsThread(audioRunnable).start();
2048             }
2049         }
2050     }
2051 
2052     /**
2053      * Gets an {@code Icon} from the native libraries if available,
2054      * otherwise gets it from an image resource file.
2055      */
2056     private static class LazyWindowsIcon implements UIDefaults.LazyValue {
2057         private String nativeImage;
2058         private String resource;
2059 
2060         LazyWindowsIcon(String nativeImage, String resource) {
2061             this.nativeImage = nativeImage;
2062             this.resource = resource;
2063         }
2064 
2065         public Object createValue(UIDefaults table) {
2066             if (nativeImage != null) {
2067                 Image image = (Image)ShellFolder.get(nativeImage);
2068                 if (image != null) {
2069                     return new ImageIcon(image);
2070                 }
2071             }
2072             return SwingUtilities2.makeIcon(getClass(),
2073                                             WindowsLookAndFeel.class,
2074                                             resource);
2075         }
2076     }
2077 
2078 
2079     /**
2080      * Gets an {@code Icon} from the native libraries if available.
2081      * A desktop property is used to trigger reloading the icon when needed.
2082      */
2083     private class ActiveWindowsIcon implements UIDefaults.ActiveValue {
2084         private Icon icon;
2085         private String nativeImageName;
2086         private String fallbackName;
2087         private DesktopProperty desktopProperty;
2088 
2089         ActiveWindowsIcon(String desktopPropertyName,
2090                             String nativeImageName, String fallbackName) {
2091             this.nativeImageName = nativeImageName;
2092             this.fallbackName = fallbackName;
2093 
2094             if (OSInfo.getOSType() == OSInfo.OSType.WINDOWS &&
2095                     OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_XP) < 0) {
2096                 // This desktop property is needed to trigger reloading the icon.
2097                 // It is kept in member variable to avoid GC.
2098                 this.desktopProperty = new TriggerDesktopProperty(desktopPropertyName) {
2099                     @Override protected void updateUI() {
2100                         icon = null;
2101                         super.updateUI();
2102                     }
2103                 };
2104             }
2105         }
2106 
2107         @Override
2108         public Object createValue(UIDefaults table) {
2109             if (icon == null) {
2110                 Image image = (Image)ShellFolder.get(nativeImageName);
2111                 if (image != null) {
2112                     icon = new ImageIconUIResource(image);
2113                 }
2114             }
2115             if (icon == null && fallbackName != null) {
2116                 UIDefaults.LazyValue fallback = (UIDefaults.LazyValue)
2117                         SwingUtilities2.makeIcon(WindowsLookAndFeel.class,
2118                             BasicLookAndFeel.class, fallbackName);
2119                 icon = (Icon) fallback.createValue(table);
2120             }
2121             return icon;
2122         }
2123     }
2124 
2125     /**
2126      * Icon backed-up by XP Skin.
2127      */
2128     private static class SkinIcon implements Icon, UIResource {
2129         private final Part part;
2130         private final State state;
2131         SkinIcon(Part part, State state) {
2132             this.part = part;
2133             this.state = state;
2134         }
2135 
2136         /**
2137          * Draw the icon at the specified location.  Icon implementations
2138          * may use the Component argument to get properties useful for
2139          * painting, e.g. the foreground or background color.
2140          */
2141         public void paintIcon(Component c, Graphics g, int x, int y) {
2142             XPStyle xp = XPStyle.getXP();
2143             assert xp != null;
2144             if (xp != null) {
2145                 Skin skin = xp.getSkin(null, part);
2146                 skin.paintSkin(g, x, y, state);
2147             }
2148         }
2149 
2150         /**
2151          * Returns the icon's width.
2152          *
2153          * @return an int specifying the fixed width of the icon.
2154          */
2155         public int getIconWidth() {
2156             int width = 0;
2157             XPStyle xp = XPStyle.getXP();
2158             assert xp != null;
2159             if (xp != null) {
2160                 Skin skin = xp.getSkin(null, part);
2161                 width = skin.getWidth();
2162             }
2163             return width;
2164         }
2165 
2166         /**
2167          * Returns the icon's height.
2168          *
2169          * @return an int specifying the fixed height of the icon.
2170          */
2171         public int getIconHeight() {
2172             int height = 0;
2173             XPStyle xp = XPStyle.getXP();
2174             if (xp != null) {
2175                 Skin skin = xp.getSkin(null, part);
2176                 height = skin.getHeight();
2177             }
2178             return height;
2179         }
2180 
2181     }
2182 
2183     /**
2184      * DesktopProperty for fonts. If a font with the name 'MS Sans Serif'
2185      * is returned, it is mapped to 'Microsoft Sans Serif'.
2186      */
2187     private static class WindowsFontProperty extends DesktopProperty {
2188         WindowsFontProperty(String key, Object backup) {
2189             super(key, backup);
2190         }
2191 
2192         public void invalidate(LookAndFeel laf) {
2193             if ("win.defaultGUI.font.height".equals(getKey())) {
2194                 ((WindowsLookAndFeel)laf).style = null;
2195             }
2196             super.invalidate(laf);
2197         }
2198 
2199         protected Object configureValue(Object value) {
2200             if (value instanceof Font) {
2201                 Font font = (Font)value;
2202                 if ("MS Sans Serif".equals(font.getName())) {
2203                     int size = font.getSize();
2204                     // 4950968: Workaround to mimic the way Windows maps the default
2205                     // font size of 6 pts to the smallest available bitmap font size.
2206                     // This happens mostly on Win 98/Me & NT.
2207                     int dpi;
2208                     try {
2209                         dpi = Toolkit.getDefaultToolkit().getScreenResolution();
2210                     } catch (HeadlessException ex) {
2211                         dpi = 96;
2212                     }
2213                     if (Math.round(size * 72F / dpi) < 8) {
2214                         size = Math.round(8 * dpi / 72F);
2215                     }
2216                     Font msFont = new FontUIResource("Microsoft Sans Serif",
2217                                           font.getStyle(), size);
2218                     if (msFont.getName() != null &&
2219                         msFont.getName().equals(msFont.getFamily())) {
2220                         font = msFont;
2221                     } else if (size != font.getSize()) {
2222                         font = new FontUIResource("MS Sans Serif",
2223                                                   font.getStyle(), size);
2224                     }
2225                 }
2226 
2227                 if (FontUtilities.fontSupportsDefaultEncoding(font)) {
2228                     if (!(font instanceof UIResource)) {
2229                         font = new FontUIResource(font);
2230                     }
2231                 }
2232                 else {
2233                     font = FontUtilities.getCompositeFontUIResource(font);
2234                 }
2235                 return font;
2236 
2237             }
2238             return super.configureValue(value);
2239         }
2240     }
2241 
2242 
2243     /**
2244      * DesktopProperty for fonts that only gets sizes from the desktop,
2245      * font name and style are passed into the constructor
2246      */
2247     private static class WindowsFontSizeProperty extends DesktopProperty {
2248         private String fontName;
2249         private int fontSize;
2250         private int fontStyle;
2251 
2252         WindowsFontSizeProperty(String key, String fontName,
2253                                 int fontStyle, int fontSize) {
2254             super(key, null);
2255             this.fontName = fontName;
2256             this.fontSize = fontSize;
2257             this.fontStyle = fontStyle;
2258         }
2259 
2260         protected Object configureValue(Object value) {
2261             if (value == null) {
2262                 value = new FontUIResource(fontName, fontStyle, fontSize);
2263             }
2264             else if (value instanceof Integer) {
2265                 value = new FontUIResource(fontName, fontStyle,
2266                                            ((Integer)value).intValue());
2267             }
2268             return value;
2269         }
2270     }
2271 
2272 
2273     /**
2274      * A value wrapper that actively retrieves values from xp or falls back
2275      * to the classic value if not running XP styles.
2276      */
2277     private static class XPValue implements UIDefaults.ActiveValue {
2278         protected Object classicValue, xpValue;
2279 
2280         // A constant that lets you specify null when using XP styles.
2281         private static final Object NULL_VALUE = new Object();
2282 
2283         XPValue(Object xpValue, Object classicValue) {
2284             this.xpValue = xpValue;
2285             this.classicValue = classicValue;
2286         }
2287 
2288         public Object createValue(UIDefaults table) {
2289             Object value = null;
2290             if (XPStyle.getXP() != null) {
2291                 value = getXPValue(table);
2292             }
2293 
2294             if (value == null) {
2295                 value = getClassicValue(table);
2296             } else if (value == NULL_VALUE) {
2297                 value = null;
2298             }
2299 
2300             return value;
2301         }
2302 
2303         protected Object getXPValue(UIDefaults table) {
2304             return recursiveCreateValue(xpValue, table);
2305         }
2306 
2307         protected Object getClassicValue(UIDefaults table) {
2308             return recursiveCreateValue(classicValue, table);
2309         }
2310 
2311         private Object recursiveCreateValue(Object value, UIDefaults table) {
2312             if (value instanceof UIDefaults.LazyValue) {
2313                 value = ((UIDefaults.LazyValue)value).createValue(table);
2314             }
2315             if (value instanceof UIDefaults.ActiveValue) {
2316                 return ((UIDefaults.ActiveValue)value).createValue(table);
2317             } else {
2318                 return value;
2319             }
2320         }
2321     }
2322 
2323     private static class XPBorderValue extends XPValue {
2324         private final Border extraMargin;
2325 
2326         XPBorderValue(Part xpValue, Object classicValue) {
2327             this(xpValue, classicValue, null);
2328         }
2329 
2330         XPBorderValue(Part xpValue, Object classicValue, Border extraMargin) {
2331             super(xpValue, classicValue);
2332             this.extraMargin = extraMargin;
2333         }
2334 
2335         public Object getXPValue(UIDefaults table) {
2336             XPStyle xp = XPStyle.getXP();
2337             Border xpBorder = xp != null ? xp.getBorder(null, (Part)xpValue) : null;
2338             if (xpBorder != null && extraMargin != null) {
2339                 return new BorderUIResource.
2340                         CompoundBorderUIResource(xpBorder, extraMargin);
2341             } else {
2342                 return xpBorder;
2343             }
2344         }
2345     }
2346 
2347     private static class XPColorValue extends XPValue {
2348         XPColorValue(Part part, State state, Prop prop, Object classicValue) {
2349             super(new XPColorValueKey(part, state, prop), classicValue);
2350         }
2351 
2352         public Object getXPValue(UIDefaults table) {
2353             XPColorValueKey key = (XPColorValueKey)xpValue;
2354             XPStyle xp = XPStyle.getXP();
2355             return xp != null ? xp.getColor(key.skin, key.prop, null) : null;
2356         }
2357 
2358         private static class XPColorValueKey {
2359             Skin skin;
2360             Prop prop;
2361 
2362             XPColorValueKey(Part part, State state, Prop prop) {
2363                 this.skin = new Skin(part, state);
2364                 this.prop = prop;
2365             }
2366         }
2367     }
2368 
2369     private class XPDLUValue extends XPValue {
2370         private int direction;
2371 
2372         XPDLUValue(int xpdlu, int classicdlu, int direction) {
2373             super(Integer.valueOf(xpdlu), Integer.valueOf(classicdlu));
2374             this.direction = direction;
2375         }
2376 
2377         public Object getXPValue(UIDefaults table) {
2378             int px = dluToPixels(((Integer)xpValue).intValue(), direction);
2379             return Integer.valueOf(px);
2380         }
2381 
2382         public Object getClassicValue(UIDefaults table) {
2383             int px = dluToPixels(((Integer)classicValue).intValue(), direction);
2384             return Integer.valueOf(px);
2385         }
2386     }
2387 
2388     private class TriggerDesktopProperty extends DesktopProperty {
2389         TriggerDesktopProperty(String key) {
2390             super(key, null);
2391             // This call adds a property change listener for the property,
2392             // which triggers a call to updateUI(). The value returned
2393             // is not interesting here.
2394             getValueFromDesktop();
2395         }
2396 
2397         protected void updateUI() {
2398             super.updateUI();
2399 
2400             // Make sure property change listener is readded each time
2401             getValueFromDesktop();
2402         }
2403     }
2404 
2405     private class FontDesktopProperty extends TriggerDesktopProperty {
2406         FontDesktopProperty(String key) {
2407             super(key);
2408         }
2409 
2410         protected void updateUI() {
2411             UIDefaults defaults = UIManager.getLookAndFeelDefaults();
2412             SwingUtilities2.putAATextInfo(true, defaults);
2413             super.updateUI();
2414         }
2415     }
2416 
2417     // Windows LayoutStyle.  From:
2418     // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwue/html/ch14e.asp
2419     @SuppressWarnings("fallthrough")
2420     private class WindowsLayoutStyle extends DefaultLayoutStyle {
2421         @Override
2422         public int getPreferredGap(JComponent component1,
2423                 JComponent component2, ComponentPlacement type, int position,
2424                 Container parent) {
2425             // Checks args
2426             super.getPreferredGap(component1, component2, type, position,
2427                                   parent);
2428 
2429             switch(type) {
2430             case INDENT:
2431                 // Windows doesn't spec this
2432                 if (position == SwingConstants.EAST ||
2433                         position == SwingConstants.WEST) {
2434                     int indent = getIndent(component1, position);
2435                     if (indent > 0) {
2436                         return indent;
2437                     }
2438                     return 10;
2439                 }
2440                 // Fall through to related.
2441             case RELATED:
2442                 if (isLabelAndNonlabel(component1, component2, position)) {
2443                     // Between text labels and their associated controls (for
2444                     // example, text boxes and list boxes): 3
2445                     // NOTE: We're not honoring:
2446                     // 'Text label beside a button 3 down from the top of
2447                     // the button,' but I suspect that is an attempt to
2448                     // enforce a baseline layout which will be handled
2449                     // separately.  In order to enforce this we would need
2450                     // this API to return a more complicated type (Insets,
2451                     // or something else).
2452                     return getButtonGap(component1, component2, position,
2453                                         dluToPixels(3, position));
2454                 }
2455                 // Between related controls: 4
2456                 return getButtonGap(component1, component2, position,
2457                                     dluToPixels(4, position));
2458             case UNRELATED:
2459                 // Between unrelated controls: 7
2460                 return getButtonGap(component1, component2, position,
2461                                     dluToPixels(7, position));
2462             }
2463             return 0;
2464         }
2465 
2466         @Override
2467         public int getContainerGap(JComponent component, int position,
2468                                    Container parent) {
2469             // Checks args
2470             super.getContainerGap(component, position, parent);
2471             return getButtonGap(component, position, dluToPixels(7, position));
2472         }
2473 
2474     }
2475 
2476     /**
2477      * Converts the dialog unit argument to pixels along the specified
2478      * axis.
2479      */
2480     private int dluToPixels(int dlu, int direction) {
2481         if (baseUnitX == 0) {
2482             calculateBaseUnits();
2483         }
2484         if (direction == SwingConstants.EAST ||
2485             direction == SwingConstants.WEST) {
2486             return dlu * baseUnitX / 4;
2487         }
2488         assert (direction == SwingConstants.NORTH ||
2489                 direction == SwingConstants.SOUTH);
2490         return dlu * baseUnitY / 8;
2491     }
2492 
2493     /**
2494      * Calculates the dialog unit mapping.
2495      */
2496     @SuppressWarnings("deprecation")
2497     private void calculateBaseUnits() {
2498         // This calculation comes from:
2499         // http://support.microsoft.com/default.aspx?scid=kb;EN-US;125681
2500         FontMetrics metrics = Toolkit.getDefaultToolkit().getFontMetrics(
2501                 UIManager.getFont("Button.font"));
2502         baseUnitX = metrics.stringWidth(
2503                 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
2504         baseUnitX = (baseUnitX / 26 + 1) / 2;
2505         // The -1 comes from experimentation.
2506         baseUnitY = metrics.getAscent() + metrics.getDescent() - 1;
2507     }
2508 
2509     /**
2510      * {@inheritDoc}
2511      *
2512      * @since 1.6
2513      */
2514     public Icon getDisabledIcon(JComponent component, Icon icon) {
2515         // if the component has a HI_RES_DISABLED_ICON_CLIENT_KEY
2516         // client property set to Boolean.TRUE, then use the new
2517         // hi res algorithm for creating the disabled icon (used
2518         // in particular by the WindowsFileChooserUI class)
2519         if (icon != null
2520                 && component != null
2521                 && Boolean.TRUE.equals(component.getClientProperty(HI_RES_DISABLED_ICON_CLIENT_KEY))
2522                 && icon.getIconWidth() > 0
2523                 && icon.getIconHeight() > 0) {
2524             BufferedImage img = new BufferedImage(icon.getIconWidth(),
2525                     icon.getIconWidth(), BufferedImage.TYPE_INT_ARGB);
2526             icon.paintIcon(component, img.getGraphics(), 0, 0);
2527             ImageFilter filter = new RGBGrayFilter();
2528             ImageProducer producer = new FilteredImageSource(img.getSource(), filter);
2529             Image resultImage = component.createImage(producer);
2530             return new ImageIconUIResource(resultImage);
2531         }
2532         return super.getDisabledIcon(component, icon);
2533     }
2534 
2535     private static class RGBGrayFilter extends RGBImageFilter {
2536         public RGBGrayFilter() {
2537             canFilterIndexColorModel = true;
2538         }
2539         public int filterRGB(int x, int y, int rgb) {
2540             // find the average of red, green, and blue
2541             float avg = (((rgb >> 16) & 0xff) / 255f +
2542                           ((rgb >>  8) & 0xff) / 255f +
2543                            (rgb        & 0xff) / 255f) / 3;
2544             // pull out the alpha channel
2545             float alpha = (((rgb>>24)&0xff)/255f);
2546             // calc the average
2547             avg = Math.min(1.0f, (1f-avg)/(100.0f/35.0f) + avg);
2548             // turn back into rgb
2549             int rgbval = (int)(alpha * 255f) << 24 |
2550                          (int)(avg   * 255f) << 16 |
2551                          (int)(avg   * 255f) <<  8 |
2552                          (int)(avg   * 255f);
2553             return rgbval;
2554         }
2555     }
2556 
2557     private static class FocusColorProperty extends DesktopProperty {
2558         public FocusColorProperty () {
2559             // Fallback value is never used because of the configureValue method doesn't return null
2560             super("win.3d.backgroundColor", Color.BLACK);
2561         }
2562 
2563         @Override
2564         protected Object configureValue(Object value) {
2565             Object highContrastOn = Toolkit.getDefaultToolkit().
2566                     getDesktopProperty("win.highContrast.on");
2567             if (highContrastOn == null || !((Boolean) highContrastOn).booleanValue()) {
2568                 return Color.BLACK;
2569             }
2570             return Color.BLACK.equals(value) ? Color.WHITE : Color.BLACK;
2571         }
2572     }
2573 
2574 }
--- EOF ---