1 /*
   2  * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package javax.swing.plaf.basic;
  27 
  28 import java.awt.Font;
  29 import java.awt.Color;
  30 import java.awt.SystemColor;
  31 import java.awt.event.*;
  32 import java.awt.Insets;
  33 import java.awt.Component;
  34 import java.awt.Container;
  35 import java.awt.FocusTraversalPolicy;
  36 import java.awt.AWTEvent;
  37 import java.awt.Toolkit;
  38 import java.awt.Point;
  39 import java.net.URL;
  40 import java.io.*;
  41 import java.awt.Dimension;
  42 import java.awt.KeyboardFocusManager;
  43 import java.security.AccessController;
  44 import java.security.PrivilegedAction;
  45 import java.util.*;
  46 import java.lang.reflect.*;
  47 import javax.sound.sampled.*;
  48 
  49 import sun.awt.AppContext;
  50 import sun.awt.SunToolkit;
  51 
  52 import sun.swing.SwingLazyValue;
  53 import sun.swing.SwingUtilities2;
  54 
  55 import javax.swing.LookAndFeel;
  56 import javax.swing.AbstractAction;
  57 import javax.swing.Action;
  58 import javax.swing.ActionMap;
  59 import javax.swing.BorderFactory;
  60 import javax.swing.JComponent;
  61 import javax.swing.ImageIcon;
  62 import javax.swing.UIDefaults;
  63 import javax.swing.UIManager;
  64 import javax.swing.KeyStroke;
  65 import javax.swing.JTextField;
  66 import javax.swing.DefaultListCellRenderer;
  67 import javax.swing.FocusManager;
  68 import javax.swing.LayoutFocusTraversalPolicy;
  69 import javax.swing.SwingUtilities;
  70 import javax.swing.MenuSelectionManager;
  71 import javax.swing.MenuElement;
  72 import javax.swing.border.*;
  73 import javax.swing.plaf.*;
  74 import javax.swing.text.JTextComponent;
  75 import javax.swing.text.DefaultEditorKit;
  76 import javax.swing.JInternalFrame;
  77 import java.beans.PropertyVetoException;
  78 import java.awt.Window;
  79 import java.beans.PropertyChangeListener;
  80 import java.beans.PropertyChangeEvent;
  81 
  82 
  83 /**
  84  * A base class to use in creating a look and feel for Swing.
  85  * <p>
  86  * Each of the {@code ComponentUI}s provided by {@code
  87  * BasicLookAndFeel} derives its behavior from the defaults
  88  * table. Unless otherwise noted each of the {@code ComponentUI}
  89  * implementations in this package document the set of defaults they
  90  * use. Unless otherwise noted the defaults are installed at the time
  91  * {@code installUI} is invoked, and follow the recommendations
  92  * outlined in {@code LookAndFeel} for installing defaults.
  93  * <p>
  94  * <strong>Warning:</strong>
  95  * Serialized objects of this class will not be compatible with
  96  * future Swing releases. The current serialization support is
  97  * appropriate for short term storage or RMI between applications running
  98  * the same version of Swing.  As of 1.4, support for long term storage
  99  * of all JavaBeans&trade;
 100  * has been added to the <code>java.beans</code> package.
 101  * Please see {@link java.beans.XMLEncoder}.
 102  *
 103  * @author unattributed
 104  */
 105 @SuppressWarnings("serial") // Same-version serialization only
 106 public abstract class BasicLookAndFeel extends LookAndFeel implements Serializable
 107 {
 108     /**
 109      * Whether or not the developer has created a JPopupMenu.
 110      */
 111     static boolean needsEventHelper;
 112 
 113     /**
 114      * Lock used when manipulating clipPlaying.
 115      */
 116     private transient Object audioLock = new Object();
 117     /**
 118      * The Clip that is currently playing (set in AudioAction).
 119      */
 120     private Clip clipPlaying;
 121 
 122     AWTEventHelper invocator = null;
 123 
 124     /*
 125      * Listen for our AppContext being disposed
 126      */
 127     private PropertyChangeListener disposer = null;
 128 
 129     /**
 130      * Returns the look and feel defaults. The returned {@code UIDefaults}
 131      * is populated by invoking, in order, {@code initClassDefaults},
 132      * {@code initSystemColorDefaults} and {@code initComponentDefaults}.
 133      * <p>
 134      * While this method is public, it should only be invoked by the
 135      * {@code UIManager} when the look and feel is set as the current
 136      * look and feel and after {@code initialize} has been invoked.
 137      *
 138      * @return the look and feel defaults
 139      *
 140      * @see #initClassDefaults
 141      * @see #initSystemColorDefaults
 142      * @see #initComponentDefaults
 143      */
 144     public UIDefaults getDefaults() {
 145         UIDefaults table = new UIDefaults(610, 0.75f);
 146 
 147         initClassDefaults(table);
 148         initSystemColorDefaults(table);
 149         initComponentDefaults(table);
 150 
 151         return table;
 152     }
 153 
 154     /**
 155      * {@inheritDoc}
 156      */
 157     public void initialize() {
 158         if (needsEventHelper) {
 159             installAWTEventListener();
 160         }
 161     }
 162 
 163     void installAWTEventListener() {
 164         if (invocator == null) {
 165             invocator = new AWTEventHelper();
 166             needsEventHelper = true;
 167 
 168             // Add a PropertyChangeListener to our AppContext so we're alerted
 169             // when the AppContext is disposed(), at which time this laf should
 170             // be uninitialize()d.
 171             disposer = new PropertyChangeListener() {
 172                 public void propertyChange(PropertyChangeEvent prpChg) {
 173                     uninitialize();
 174                 }
 175             };
 176             AppContext.getAppContext().addPropertyChangeListener(
 177                                                         AppContext.GUI_DISPOSED,
 178                                                         disposer);
 179         }
 180     }
 181 
 182     /**
 183      * {@inheritDoc}
 184      */
 185     public void uninitialize() {
 186         AppContext context = AppContext.getAppContext();
 187         synchronized (BasicPopupMenuUI.MOUSE_GRABBER_KEY) {
 188             Object grabber = context.get(BasicPopupMenuUI.MOUSE_GRABBER_KEY);
 189             if (grabber != null) {
 190                 ((BasicPopupMenuUI.MouseGrabber)grabber).uninstall();
 191             }
 192         }
 193         synchronized (BasicPopupMenuUI.MENU_KEYBOARD_HELPER_KEY) {
 194             Object helper =
 195                     context.get(BasicPopupMenuUI.MENU_KEYBOARD_HELPER_KEY);
 196             if (helper != null) {
 197                 ((BasicPopupMenuUI.MenuKeyboardHelper)helper).uninstall();
 198             }
 199         }
 200 
 201         if(invocator != null) {
 202             AccessController.doPrivileged(invocator);
 203             invocator = null;
 204         }
 205 
 206         if (disposer != null) {
 207             // Note that we're likely calling removePropertyChangeListener()
 208             // during the course of AppContext.firePropertyChange().
 209             // However, EventListenerAggreggate has code to safely modify
 210             // the list under such circumstances.
 211             context.removePropertyChangeListener(AppContext.GUI_DISPOSED,
 212                                                  disposer);
 213             disposer = null;
 214         }
 215     }
 216 
 217     /**
 218      * Populates {@code table} with mappings from {@code uiClassID} to the
 219      * fully qualified name of the ui class. The value for a
 220      * particular {@code uiClassID} is {@code
 221      * "javax.swing.plaf.basic.Basic + uiClassID"}. For example, the
 222      * value for the {@code uiClassID} {@code TreeUI} is {@code
 223      * "javax.swing.plaf.basic.BasicTreeUI"}.
 224      *
 225      * @param table the {@code UIDefaults} instance the entries are
 226      *        added to
 227      * @throws NullPointerException if {@code table} is {@code null}
 228      *
 229      * @see javax.swing.LookAndFeel
 230      * @see #getDefaults
 231      */
 232     protected void initClassDefaults(UIDefaults table)
 233     {
 234         final String basicPackageName = "javax.swing.plaf.basic.";
 235         Object[] uiDefaults = {
 236                    "ButtonUI", basicPackageName + "BasicButtonUI",
 237                  "CheckBoxUI", basicPackageName + "BasicCheckBoxUI",
 238              "ColorChooserUI", basicPackageName + "BasicColorChooserUI",
 239        "FormattedTextFieldUI", basicPackageName + "BasicFormattedTextFieldUI",
 240                   "MenuBarUI", basicPackageName + "BasicMenuBarUI",
 241                      "MenuUI", basicPackageName + "BasicMenuUI",
 242                  "MenuItemUI", basicPackageName + "BasicMenuItemUI",
 243          "CheckBoxMenuItemUI", basicPackageName + "BasicCheckBoxMenuItemUI",
 244       "RadioButtonMenuItemUI", basicPackageName + "BasicRadioButtonMenuItemUI",
 245               "RadioButtonUI", basicPackageName + "BasicRadioButtonUI",
 246              "ToggleButtonUI", basicPackageName + "BasicToggleButtonUI",
 247                 "PopupMenuUI", basicPackageName + "BasicPopupMenuUI",
 248               "ProgressBarUI", basicPackageName + "BasicProgressBarUI",
 249                 "ScrollBarUI", basicPackageName + "BasicScrollBarUI",
 250                "ScrollPaneUI", basicPackageName + "BasicScrollPaneUI",
 251                 "SplitPaneUI", basicPackageName + "BasicSplitPaneUI",
 252                    "SliderUI", basicPackageName + "BasicSliderUI",
 253                 "SeparatorUI", basicPackageName + "BasicSeparatorUI",
 254                   "SpinnerUI", basicPackageName + "BasicSpinnerUI",
 255          "ToolBarSeparatorUI", basicPackageName + "BasicToolBarSeparatorUI",
 256        "PopupMenuSeparatorUI", basicPackageName + "BasicPopupMenuSeparatorUI",
 257                "TabbedPaneUI", basicPackageName + "BasicTabbedPaneUI",
 258                  "TextAreaUI", basicPackageName + "BasicTextAreaUI",
 259                 "TextFieldUI", basicPackageName + "BasicTextFieldUI",
 260             "PasswordFieldUI", basicPackageName + "BasicPasswordFieldUI",
 261                  "TextPaneUI", basicPackageName + "BasicTextPaneUI",
 262                "EditorPaneUI", basicPackageName + "BasicEditorPaneUI",
 263                      "TreeUI", basicPackageName + "BasicTreeUI",
 264                     "LabelUI", basicPackageName + "BasicLabelUI",
 265                      "ListUI", basicPackageName + "BasicListUI",
 266                   "ToolBarUI", basicPackageName + "BasicToolBarUI",
 267                   "ToolTipUI", basicPackageName + "BasicToolTipUI",
 268                  "ComboBoxUI", basicPackageName + "BasicComboBoxUI",
 269                     "TableUI", basicPackageName + "BasicTableUI",
 270               "TableHeaderUI", basicPackageName + "BasicTableHeaderUI",
 271             "InternalFrameUI", basicPackageName + "BasicInternalFrameUI",
 272               "DesktopPaneUI", basicPackageName + "BasicDesktopPaneUI",
 273               "DesktopIconUI", basicPackageName + "BasicDesktopIconUI",
 274               "FileChooserUI", basicPackageName + "BasicFileChooserUI",
 275                "OptionPaneUI", basicPackageName + "BasicOptionPaneUI",
 276                     "PanelUI", basicPackageName + "BasicPanelUI",
 277                  "ViewportUI", basicPackageName + "BasicViewportUI",
 278                  "RootPaneUI", basicPackageName + "BasicRootPaneUI",
 279         };
 280 
 281         table.putDefaults(uiDefaults);
 282     }
 283 
 284     /**
 285      * Populates {@code table} with system colors. This creates an
 286      * array of {@code name-color} pairs and invokes {@code
 287      * loadSystemColors}.
 288      * <p>
 289      * The name is a {@code String} that corresponds to the name of
 290      * one of the static {@code SystemColor} fields in the {@code
 291      * SystemColor} class.  A name-color pair is created for every
 292      * such {@code SystemColor} field.
 293      * <p>
 294      * The {@code color} corresponds to a hex {@code String} as
 295      * understood by {@code Color.decode}. For example, one of the
 296      * {@code name-color} pairs is {@code
 297      * "desktop"-"#005C5C"}. This corresponds to the {@code
 298      * SystemColor} field {@code desktop}, with a color value of
 299      * {@code new Color(0x005C5C)}.
 300      * <p>
 301      * The following shows two of the {@code name-color} pairs:
 302      * <pre>
 303      *   String[] nameColorPairs = new String[] {
 304      *          "desktop", "#005C5C",
 305      *    "activeCaption", "#000080" };
 306      *   loadSystemColors(table, nameColorPairs, isNativeLookAndFeel());
 307      * </pre>
 308      *
 309      * As previously stated, this invokes {@code loadSystemColors}
 310      * with the supplied {@code table} and {@code name-color} pair
 311      * array. The last argument to {@code loadSystemColors} indicates
 312      * whether the value of the field in {@code SystemColor} should be
 313      * used. This method passes the value of {@code
 314      * isNativeLookAndFeel()} as the last argument to {@code loadSystemColors}.
 315      *
 316      * @param table the {@code UIDefaults} object the values are added to
 317      * @throws NullPointerException if {@code table} is {@code null}
 318      *
 319      * @see java.awt.SystemColor
 320      * @see #getDefaults
 321      * @see #loadSystemColors
 322      */
 323     protected void initSystemColorDefaults(UIDefaults table)
 324     {
 325         String[] defaultSystemColors = {
 326                 "desktop", "#005C5C", /* Color of the desktop background */
 327           "activeCaption", "#000080", /* Color for captions (title bars) when they are active. */
 328       "activeCaptionText", "#FFFFFF", /* Text color for text in captions (title bars). */
 329     "activeCaptionBorder", "#C0C0C0", /* Border color for caption (title bar) window borders. */
 330         "inactiveCaption", "#808080", /* Color for captions (title bars) when not active. */
 331     "inactiveCaptionText", "#C0C0C0", /* Text color for text in inactive captions (title bars). */
 332   "inactiveCaptionBorder", "#C0C0C0", /* Border color for inactive caption (title bar) window borders. */
 333                  "window", "#FFFFFF", /* Default color for the interior of windows */
 334            "windowBorder", "#000000", /* ??? */
 335              "windowText", "#000000", /* ??? */
 336                    "menu", "#C0C0C0", /* Background color for menus */
 337                "menuText", "#000000", /* Text color for menus  */
 338                    "text", "#C0C0C0", /* Text background color */
 339                "textText", "#000000", /* Text foreground color */
 340           "textHighlight", "#000080", /* Text background color when selected */
 341       "textHighlightText", "#FFFFFF", /* Text color when selected */
 342        "textInactiveText", "#808080", /* Text color when disabled */
 343                 "control", "#C0C0C0", /* Default color for controls (buttons, sliders, etc) */
 344             "controlText", "#000000", /* Default color for text in controls */
 345        "controlHighlight", "#C0C0C0", /* Specular highlight (opposite of the shadow) */
 346      "controlLtHighlight", "#FFFFFF", /* Highlight color for controls */
 347           "controlShadow", "#808080", /* Shadow color for controls */
 348         "controlDkShadow", "#000000", /* Dark shadow color for controls */
 349               "scrollbar", "#E0E0E0", /* Scrollbar background (usually the "track") */
 350                    "info", "#FFFFE1", /* ??? */
 351                "infoText", "#000000"  /* ??? */
 352         };
 353 
 354         loadSystemColors(table, defaultSystemColors, isNativeLookAndFeel());
 355     }
 356 
 357 
 358     /**
 359      * Populates {@code table} with the {@code name-color} pairs in
 360      * {@code systemColors}. Refer to
 361      * {@link #initSystemColorDefaults(UIDefaults)} for details on
 362      * the format of {@code systemColors}.
 363      * <p>
 364      * An entry is added to {@code table} for each of the {@code name-color}
 365      * pairs in {@code systemColors}. The entry key is
 366      * the {@code name} of the {@code name-color} pair.
 367      * <p>
 368      * The value of the entry corresponds to the {@code color} of the
 369      * {@code name-color} pair.  The value of the entry is calculated
 370      * in one of two ways. With either approach the value is always a
 371      * {@code ColorUIResource}.
 372      * <p>
 373      * If {@code useNative} is {@code false}, the {@code color} is
 374      * created by using {@code Color.decode} to convert the {@code
 375      * String} into a {@code Color}. If {@code decode} can not convert
 376      * the {@code String} into a {@code Color} ({@code
 377      * NumberFormatException} is thrown) then a {@code
 378      * ColorUIResource} of black is used.
 379      * <p>
 380      * If {@code useNative} is {@code true}, the {@code color} is the
 381      * value of the field in {@code SystemColor} with the same name as
 382      * the {@code name} of the {@code name-color} pair. If the field
 383      * is not valid, a {@code ColorUIResource} of black is used.
 384      *
 385      * @param table the {@code UIDefaults} object the values are added to
 386      * @param systemColors array of {@code name-color} pairs as described
 387      *        in {@link #initSystemColorDefaults(UIDefaults)}
 388      * @param useNative whether the color is obtained from {@code SystemColor}
 389      *        or {@code Color.decode}
 390      * @throws NullPointerException if {@code systemColors} is {@code null}; or
 391      *         {@code systemColors} is not empty, and {@code table} is
 392      *         {@code null}; or one of the
 393      *         names of the {@code name-color} pairs is {@code null}; or
 394      *         {@code useNative} is {@code false} and one of the
 395      *         {@code colors} of the {@code name-color} pairs is {@code null}
 396      * @throws ArrayIndexOutOfBoundsException if {@code useNative} is
 397      *         {@code false} and {@code systemColors.length} is odd
 398      *
 399      * @see #initSystemColorDefaults(javax.swing.UIDefaults)
 400      * @see java.awt.SystemColor
 401      * @see java.awt.Color#decode(String)
 402      */
 403     protected void loadSystemColors(UIDefaults table, String[] systemColors, boolean useNative)
 404     {
 405         /* PENDING(hmuller) We don't load the system colors below because
 406          * they're not reliable.  Hopefully we'll be able to do better in
 407          * a future version of AWT.
 408          */
 409         if (useNative) {
 410             for(int i = 0; i < systemColors.length; i += 2) {
 411                 Color color = Color.black;
 412                 try {
 413                     String name = systemColors[i];
 414                     color = (Color)(SystemColor.class.getField(name).get(null));
 415                 } catch (Exception e) {
 416                 }
 417                 table.put(systemColors[i], new ColorUIResource(color));
 418             }
 419         } else {
 420             for(int i = 0; i < systemColors.length; i += 2) {
 421                 Color color = Color.black;
 422                 try {
 423                     color = Color.decode(systemColors[i + 1]);
 424                 }
 425                 catch(NumberFormatException e) {
 426                     e.printStackTrace();
 427                 }
 428                 table.put(systemColors[i], new ColorUIResource(color));
 429             }
 430         }
 431     }
 432     /**
 433      * Initialize the defaults table with the name of the ResourceBundle
 434      * used for getting localized defaults.  Also initialize the default
 435      * locale used when no locale is passed into UIDefaults.get().  The
 436      * default locale should generally not be relied upon. It is here for
 437      * compatibility with releases prior to 1.4.
 438      */
 439     private void initResourceBundle(UIDefaults table) {
 440         table.setDefaultLocale( Locale.getDefault() );
 441         table.addResourceBundle( "com.sun.swing.internal.plaf.basic.resources.basic" );
 442     }
 443 
 444     /**
 445      * Populates {@code table} with the defaults for the basic look and
 446      * feel.
 447      *
 448      * @param table the {@code UIDefaults} to add the values to
 449      * @throws NullPointerException if {@code table} is {@code null}
 450      */
 451     protected void initComponentDefaults(UIDefaults table)
 452     {
 453 
 454         initResourceBundle(table);
 455 
 456         // *** Shared Integers
 457         Integer fiveHundred = new Integer(500);
 458 
 459         // *** Shared Longs
 460         Long oneThousand = new Long(1000);
 461 
 462         // *** Shared Fonts
 463         Integer twelve = new Integer(12);
 464         Integer fontPlain = new Integer(Font.PLAIN);
 465         Integer fontBold = new Integer(Font.BOLD);
 466         Object dialogPlain12 = new SwingLazyValue(
 467                           "javax.swing.plaf.FontUIResource",
 468                           null,
 469                           new Object[] {Font.DIALOG, fontPlain, twelve});
 470         Object serifPlain12 = new SwingLazyValue(
 471                           "javax.swing.plaf.FontUIResource",
 472                           null,
 473                           new Object[] {Font.SERIF, fontPlain, twelve});
 474         Object sansSerifPlain12 =  new SwingLazyValue(
 475                           "javax.swing.plaf.FontUIResource",
 476                           null,
 477                           new Object[] {Font.SANS_SERIF, fontPlain, twelve});
 478         Object monospacedPlain12 = new SwingLazyValue(
 479                           "javax.swing.plaf.FontUIResource",
 480                           null,
 481                           new Object[] {Font.MONOSPACED, fontPlain, twelve});
 482         Object dialogBold12 = new SwingLazyValue(
 483                           "javax.swing.plaf.FontUIResource",
 484                           null,
 485                           new Object[] {Font.DIALOG, fontBold, twelve});
 486 
 487 
 488         // *** Shared Colors
 489         ColorUIResource red = new ColorUIResource(Color.red);
 490         ColorUIResource black = new ColorUIResource(Color.black);
 491         ColorUIResource white = new ColorUIResource(Color.white);
 492         ColorUIResource yellow = new ColorUIResource(Color.yellow);
 493         ColorUIResource gray = new ColorUIResource(Color.gray);
 494         ColorUIResource lightGray = new ColorUIResource(Color.lightGray);
 495         ColorUIResource darkGray = new ColorUIResource(Color.darkGray);
 496         ColorUIResource scrollBarTrack = new ColorUIResource(224, 224, 224);
 497 
 498         Color control = table.getColor("control");
 499         Color controlDkShadow = table.getColor("controlDkShadow");
 500         Color controlHighlight = table.getColor("controlHighlight");
 501         Color controlLtHighlight = table.getColor("controlLtHighlight");
 502         Color controlShadow = table.getColor("controlShadow");
 503         Color controlText = table.getColor("controlText");
 504         Color menu = table.getColor("menu");
 505         Color menuText = table.getColor("menuText");
 506         Color textHighlight = table.getColor("textHighlight");
 507         Color textHighlightText = table.getColor("textHighlightText");
 508         Color textInactiveText = table.getColor("textInactiveText");
 509         Color textText = table.getColor("textText");
 510         Color window = table.getColor("window");
 511 
 512         // *** Shared Insets
 513         InsetsUIResource zeroInsets = new InsetsUIResource(0,0,0,0);
 514         InsetsUIResource twoInsets = new InsetsUIResource(2,2,2,2);
 515         InsetsUIResource threeInsets = new InsetsUIResource(3,3,3,3);
 516 
 517         // *** Shared Borders
 518         Object marginBorder = new SwingLazyValue(
 519                           "javax.swing.plaf.basic.BasicBorders$MarginBorder");
 520         Object etchedBorder = new SwingLazyValue(
 521                           "javax.swing.plaf.BorderUIResource",
 522                           "getEtchedBorderUIResource");
 523         Object loweredBevelBorder = new SwingLazyValue(
 524                           "javax.swing.plaf.BorderUIResource",
 525                           "getLoweredBevelBorderUIResource");
 526 
 527         Object popupMenuBorder = new SwingLazyValue(
 528                           "javax.swing.plaf.basic.BasicBorders",
 529                           "getInternalFrameBorder");
 530 
 531         Object blackLineBorder = new SwingLazyValue(
 532                           "javax.swing.plaf.BorderUIResource",
 533                           "getBlackLineBorderUIResource");
 534         Object focusCellHighlightBorder = new SwingLazyValue(
 535                           "javax.swing.plaf.BorderUIResource$LineBorderUIResource",
 536                           null,
 537                           new Object[] {yellow});
 538 
 539         Object noFocusBorder = new BorderUIResource.EmptyBorderUIResource(1,1,1,1);
 540 
 541         Object tableHeaderBorder = new SwingLazyValue(
 542                           "javax.swing.plaf.BorderUIResource$BevelBorderUIResource",
 543                           null,
 544                           new Object[] { new Integer(BevelBorder.RAISED),
 545                                          controlLtHighlight,
 546                                          control,
 547                                          controlDkShadow,
 548                                          controlShadow });
 549 
 550 
 551         // *** Button value objects
 552 
 553         Object buttonBorder =
 554             new SwingLazyValue(
 555                             "javax.swing.plaf.basic.BasicBorders",
 556                             "getButtonBorder");
 557 
 558         Object buttonToggleBorder =
 559             new SwingLazyValue(
 560                             "javax.swing.plaf.basic.BasicBorders",
 561                             "getToggleButtonBorder");
 562 
 563         Object radioButtonBorder =
 564             new SwingLazyValue(
 565                             "javax.swing.plaf.basic.BasicBorders",
 566                             "getRadioButtonBorder");
 567 
 568         // *** FileChooser / FileView value objects
 569 
 570         Object newFolderIcon = SwingUtilities2.makeIcon(getClass(),
 571                                                         BasicLookAndFeel.class,
 572                                                         "icons/NewFolder.gif");
 573         Object upFolderIcon = SwingUtilities2.makeIcon(getClass(),
 574                                                        BasicLookAndFeel.class,
 575                                                        "icons/UpFolder.gif");
 576         Object homeFolderIcon = SwingUtilities2.makeIcon(getClass(),
 577                                                          BasicLookAndFeel.class,
 578                                                          "icons/HomeFolder.gif");
 579         Object detailsViewIcon = SwingUtilities2.makeIcon(getClass(),
 580                                                           BasicLookAndFeel.class,
 581                                                           "icons/DetailsView.gif");
 582         Object listViewIcon = SwingUtilities2.makeIcon(getClass(),
 583                                                        BasicLookAndFeel.class,
 584                                                        "icons/ListView.gif");
 585         Object directoryIcon = SwingUtilities2.makeIcon(getClass(),
 586                                                         BasicLookAndFeel.class,
 587                                                         "icons/Directory.gif");
 588         Object fileIcon = SwingUtilities2.makeIcon(getClass(),
 589                                                    BasicLookAndFeel.class,
 590                                                    "icons/File.gif");
 591         Object computerIcon = SwingUtilities2.makeIcon(getClass(),
 592                                                        BasicLookAndFeel.class,
 593                                                        "icons/Computer.gif");
 594         Object hardDriveIcon = SwingUtilities2.makeIcon(getClass(),
 595                                                         BasicLookAndFeel.class,
 596                                                         "icons/HardDrive.gif");
 597         Object floppyDriveIcon = SwingUtilities2.makeIcon(getClass(),
 598                                                           BasicLookAndFeel.class,
 599                                                           "icons/FloppyDrive.gif");
 600 
 601 
 602         // *** InternalFrame value objects
 603 
 604         Object internalFrameBorder = new SwingLazyValue(
 605                 "javax.swing.plaf.basic.BasicBorders",
 606                 "getInternalFrameBorder");
 607 
 608         // *** List value objects
 609 
 610         Object listCellRendererActiveValue = new UIDefaults.ActiveValue() {
 611             public Object createValue(UIDefaults table) {
 612                 return new DefaultListCellRenderer.UIResource();
 613             }
 614         };
 615 
 616 
 617         // *** Menus value objects
 618 
 619         Object menuBarBorder =
 620             new SwingLazyValue(
 621                 "javax.swing.plaf.basic.BasicBorders",
 622                 "getMenuBarBorder");
 623 
 624         Object menuItemCheckIcon =
 625             new SwingLazyValue(
 626                 "javax.swing.plaf.basic.BasicIconFactory",
 627                 "getMenuItemCheckIcon");
 628 
 629         Object menuItemArrowIcon =
 630             new SwingLazyValue(
 631                 "javax.swing.plaf.basic.BasicIconFactory",
 632                 "getMenuItemArrowIcon");
 633 
 634 
 635         Object menuArrowIcon =
 636             new SwingLazyValue(
 637                 "javax.swing.plaf.basic.BasicIconFactory",
 638                 "getMenuArrowIcon");
 639 
 640         Object checkBoxIcon =
 641             new SwingLazyValue(
 642                 "javax.swing.plaf.basic.BasicIconFactory",
 643                 "getCheckBoxIcon");
 644 
 645         Object radioButtonIcon =
 646             new SwingLazyValue(
 647                 "javax.swing.plaf.basic.BasicIconFactory",
 648                 "getRadioButtonIcon");
 649 
 650         Object checkBoxMenuItemIcon =
 651             new SwingLazyValue(
 652                 "javax.swing.plaf.basic.BasicIconFactory",
 653                 "getCheckBoxMenuItemIcon");
 654 
 655         Object radioButtonMenuItemIcon =
 656             new SwingLazyValue(
 657                 "javax.swing.plaf.basic.BasicIconFactory",
 658                 "getRadioButtonMenuItemIcon");
 659 
 660         Object menuItemAcceleratorDelimiter = "+";
 661 
 662         // *** OptionPane value objects
 663 
 664         Object optionPaneMinimumSize = new DimensionUIResource(262, 90);
 665 
 666         Integer zero =  new Integer(0);
 667         Object zeroBorder = new SwingLazyValue(
 668                            "javax.swing.plaf.BorderUIResource$EmptyBorderUIResource",
 669                            new Object[] {zero, zero, zero, zero});
 670 
 671         Integer ten = new Integer(10);
 672         Object optionPaneBorder = new SwingLazyValue(
 673                            "javax.swing.plaf.BorderUIResource$EmptyBorderUIResource",
 674                            new Object[] {ten, ten, twelve, ten});
 675 
 676         Object optionPaneButtonAreaBorder = new SwingLazyValue(
 677                            "javax.swing.plaf.BorderUIResource$EmptyBorderUIResource",
 678                            new Object[] {new Integer(6), zero, zero, zero});
 679 
 680 
 681         // *** ProgessBar value objects
 682 
 683         Object progressBarBorder =
 684             new SwingLazyValue(
 685                             "javax.swing.plaf.basic.BasicBorders",
 686                             "getProgressBarBorder");
 687 
 688         // ** ScrollBar value objects
 689 
 690         Object minimumThumbSize = new DimensionUIResource(8,8);
 691         Object maximumThumbSize = new DimensionUIResource(4096,4096);
 692 
 693         // ** Slider value objects
 694 
 695         Object sliderFocusInsets = twoInsets;
 696 
 697         Object toolBarSeparatorSize = new DimensionUIResource( 10, 10 );
 698 
 699 
 700         // *** SplitPane value objects
 701 
 702         Object splitPaneBorder =
 703             new SwingLazyValue(
 704                             "javax.swing.plaf.basic.BasicBorders",
 705                             "getSplitPaneBorder");
 706         Object splitPaneDividerBorder =
 707             new SwingLazyValue(
 708                             "javax.swing.plaf.basic.BasicBorders",
 709                             "getSplitPaneDividerBorder");
 710 
 711         // ** TabbedBane value objects
 712 
 713         Object tabbedPaneTabInsets = new InsetsUIResource(0, 4, 1, 4);
 714 
 715         Object tabbedPaneTabPadInsets = new InsetsUIResource(2, 2, 2, 1);
 716 
 717         Object tabbedPaneTabAreaInsets = new InsetsUIResource(3, 2, 0, 2);
 718 
 719         Object tabbedPaneContentBorderInsets = new InsetsUIResource(2, 2, 3, 3);
 720 
 721 
 722         // *** Text value objects
 723 
 724         Object textFieldBorder =
 725             new SwingLazyValue(
 726                             "javax.swing.plaf.basic.BasicBorders",
 727                             "getTextFieldBorder");
 728 
 729         Object editorMargin = threeInsets;
 730 
 731         Object caretBlinkRate = fiveHundred;
 732         Integer four = new Integer(4);
 733 
 734         Object[] allAuditoryCues = new Object[] {
 735                 "CheckBoxMenuItem.commandSound",
 736                 "InternalFrame.closeSound",
 737                 "InternalFrame.maximizeSound",
 738                 "InternalFrame.minimizeSound",
 739                 "InternalFrame.restoreDownSound",
 740                 "InternalFrame.restoreUpSound",
 741                 "MenuItem.commandSound",
 742                 "OptionPane.errorSound",
 743                 "OptionPane.informationSound",
 744                 "OptionPane.questionSound",
 745                 "OptionPane.warningSound",
 746                 "PopupMenu.popupSound",
 747                 "RadioButtonMenuItem.commandSound"};
 748 
 749         Object[] noAuditoryCues = new Object[] {"mute"};
 750 
 751         // *** Component Defaults
 752 
 753         Object[] defaults = {
 754             // *** Auditory Feedback
 755             "AuditoryCues.cueList", allAuditoryCues,
 756             "AuditoryCues.allAuditoryCues", allAuditoryCues,
 757             "AuditoryCues.noAuditoryCues", noAuditoryCues,
 758             // this key defines which of the various cues to render.
 759             // L&Fs that want auditory feedback NEED to override playList.
 760             "AuditoryCues.playList", null,
 761 
 762             // *** Buttons
 763             "Button.defaultButtonFollowsFocus", Boolean.TRUE,
 764             "Button.font", dialogPlain12,
 765             "Button.background", control,
 766             "Button.foreground", controlText,
 767             "Button.shadow", controlShadow,
 768             "Button.darkShadow", controlDkShadow,
 769             "Button.light", controlHighlight,
 770             "Button.highlight", controlLtHighlight,
 771             "Button.border", buttonBorder,
 772             "Button.margin", new InsetsUIResource(2, 14, 2, 14),
 773             "Button.textIconGap", four,
 774             "Button.textShiftOffset", zero,
 775             "Button.focusInputMap", new UIDefaults.LazyInputMap(new Object[] {
 776                          "SPACE", "pressed",
 777                 "released SPACE", "released",
 778                          "ENTER", "pressed",
 779                 "released ENTER", "released"
 780               }),
 781 
 782             "ToggleButton.font", dialogPlain12,
 783             "ToggleButton.background", control,
 784             "ToggleButton.foreground", controlText,
 785             "ToggleButton.shadow", controlShadow,
 786             "ToggleButton.darkShadow", controlDkShadow,
 787             "ToggleButton.light", controlHighlight,
 788             "ToggleButton.highlight", controlLtHighlight,
 789             "ToggleButton.border", buttonToggleBorder,
 790             "ToggleButton.margin", new InsetsUIResource(2, 14, 2, 14),
 791             "ToggleButton.textIconGap", four,
 792             "ToggleButton.textShiftOffset", zero,
 793             "ToggleButton.focusInputMap",
 794               new UIDefaults.LazyInputMap(new Object[] {
 795                             "SPACE", "pressed",
 796                    "released SPACE", "released"
 797                 }),
 798 
 799             "RadioButton.font", dialogPlain12,
 800             "RadioButton.background", control,
 801             "RadioButton.foreground", controlText,
 802             "RadioButton.shadow", controlShadow,
 803             "RadioButton.darkShadow", controlDkShadow,
 804             "RadioButton.light", controlHighlight,
 805             "RadioButton.highlight", controlLtHighlight,
 806             "RadioButton.border", radioButtonBorder,
 807             "RadioButton.margin", twoInsets,
 808             "RadioButton.textIconGap", four,
 809             "RadioButton.textShiftOffset", zero,
 810             "RadioButton.icon", radioButtonIcon,
 811             "RadioButton.focusInputMap",
 812                new UIDefaults.LazyInputMap(new Object[] {
 813                           "SPACE", "pressed",
 814                  "released SPACE", "released",
 815                          "RETURN", "pressed"
 816               }),
 817 
 818             "CheckBox.font", dialogPlain12,
 819             "CheckBox.background", control,
 820             "CheckBox.foreground", controlText,
 821             "CheckBox.border", radioButtonBorder,
 822             "CheckBox.margin", twoInsets,
 823             "CheckBox.textIconGap", four,
 824             "CheckBox.textShiftOffset", zero,
 825             "CheckBox.icon", checkBoxIcon,
 826             "CheckBox.focusInputMap",
 827                new UIDefaults.LazyInputMap(new Object[] {
 828                             "SPACE", "pressed",
 829                    "released SPACE", "released"
 830                  }),
 831             "FileChooser.useSystemExtensionHiding", Boolean.FALSE,
 832 
 833             // *** ColorChooser
 834             "ColorChooser.font", dialogPlain12,
 835             "ColorChooser.background", control,
 836             "ColorChooser.foreground", controlText,
 837 
 838             "ColorChooser.swatchesSwatchSize", new Dimension(10, 10),
 839             "ColorChooser.swatchesRecentSwatchSize", new Dimension(10, 10),
 840             "ColorChooser.swatchesDefaultRecentColor", control,
 841 
 842             // *** ComboBox
 843             "ComboBox.font", sansSerifPlain12,
 844             "ComboBox.background", window,
 845             "ComboBox.foreground", textText,
 846             "ComboBox.buttonBackground", control,
 847             "ComboBox.buttonShadow", controlShadow,
 848             "ComboBox.buttonDarkShadow", controlDkShadow,
 849             "ComboBox.buttonHighlight", controlLtHighlight,
 850             "ComboBox.selectionBackground", textHighlight,
 851             "ComboBox.selectionForeground", textHighlightText,
 852             "ComboBox.disabledBackground", control,
 853             "ComboBox.disabledForeground", textInactiveText,
 854             "ComboBox.timeFactor", oneThousand,
 855             "ComboBox.isEnterSelectablePopup", Boolean.FALSE,
 856             "ComboBox.ancestorInputMap",
 857                new UIDefaults.LazyInputMap(new Object[] {
 858                       "ESCAPE", "hidePopup",
 859                      "PAGE_UP", "pageUpPassThrough",
 860                    "PAGE_DOWN", "pageDownPassThrough",
 861                         "HOME", "homePassThrough",
 862                          "END", "endPassThrough",
 863                        "ENTER", "enterPressed"
 864                  }),
 865             "ComboBox.noActionOnKeyNavigation", Boolean.FALSE,
 866 
 867             // *** FileChooser
 868 
 869             "FileChooser.newFolderIcon", newFolderIcon,
 870             "FileChooser.upFolderIcon", upFolderIcon,
 871             "FileChooser.homeFolderIcon", homeFolderIcon,
 872             "FileChooser.detailsViewIcon", detailsViewIcon,
 873             "FileChooser.listViewIcon", listViewIcon,
 874             "FileChooser.readOnly", Boolean.FALSE,
 875             "FileChooser.usesSingleFilePane", Boolean.FALSE,
 876             "FileChooser.ancestorInputMap",
 877                new UIDefaults.LazyInputMap(new Object[] {
 878                      "ESCAPE", "cancelSelection",
 879                      "F5", "refresh",
 880                  }),
 881 
 882             "FileView.directoryIcon", directoryIcon,
 883             "FileView.fileIcon", fileIcon,
 884             "FileView.computerIcon", computerIcon,
 885             "FileView.hardDriveIcon", hardDriveIcon,
 886             "FileView.floppyDriveIcon", floppyDriveIcon,
 887 
 888             // *** InternalFrame
 889             "InternalFrame.titleFont", dialogBold12,
 890             "InternalFrame.borderColor", control,
 891             "InternalFrame.borderShadow", controlShadow,
 892             "InternalFrame.borderDarkShadow", controlDkShadow,
 893             "InternalFrame.borderHighlight", controlLtHighlight,
 894             "InternalFrame.borderLight", controlHighlight,
 895             "InternalFrame.border", internalFrameBorder,
 896             "InternalFrame.icon",   SwingUtilities2.makeIcon(getClass(),
 897                                                              BasicLookAndFeel.class,
 898                                                              "icons/JavaCup16.png"),
 899 
 900             /* Default frame icons are undefined for Basic. */
 901             "InternalFrame.maximizeIcon",
 902             new SwingLazyValue(
 903                            "javax.swing.plaf.basic.BasicIconFactory",
 904                            "createEmptyFrameIcon"),
 905             "InternalFrame.minimizeIcon",
 906             new SwingLazyValue(
 907                            "javax.swing.plaf.basic.BasicIconFactory",
 908                            "createEmptyFrameIcon"),
 909             "InternalFrame.iconifyIcon",
 910             new SwingLazyValue(
 911                            "javax.swing.plaf.basic.BasicIconFactory",
 912                            "createEmptyFrameIcon"),
 913             "InternalFrame.closeIcon",
 914             new SwingLazyValue(
 915                            "javax.swing.plaf.basic.BasicIconFactory",
 916                            "createEmptyFrameIcon"),
 917             // InternalFrame Auditory Cue Mappings
 918             "InternalFrame.closeSound", null,
 919             "InternalFrame.maximizeSound", null,
 920             "InternalFrame.minimizeSound", null,
 921             "InternalFrame.restoreDownSound", null,
 922             "InternalFrame.restoreUpSound", null,
 923 
 924             "InternalFrame.activeTitleBackground", table.get("activeCaption"),
 925             "InternalFrame.activeTitleForeground", table.get("activeCaptionText"),
 926             "InternalFrame.inactiveTitleBackground", table.get("inactiveCaption"),
 927             "InternalFrame.inactiveTitleForeground", table.get("inactiveCaptionText"),
 928             "InternalFrame.windowBindings", new Object[] {
 929               "shift ESCAPE", "showSystemMenu",
 930                 "ctrl SPACE", "showSystemMenu",
 931                     "ESCAPE", "hideSystemMenu"},
 932 
 933             "InternalFrameTitlePane.iconifyButtonOpacity", Boolean.TRUE,
 934             "InternalFrameTitlePane.maximizeButtonOpacity", Boolean.TRUE,
 935             "InternalFrameTitlePane.closeButtonOpacity", Boolean.TRUE,
 936 
 937         "DesktopIcon.border", internalFrameBorder,
 938 
 939             "Desktop.minOnScreenInsets", threeInsets,
 940             "Desktop.background", table.get("desktop"),
 941             "Desktop.ancestorInputMap",
 942                new UIDefaults.LazyInputMap(new Object[] {
 943                  "ctrl F5", "restore",
 944                  "ctrl F4", "close",
 945                  "ctrl F7", "move",
 946                  "ctrl F8", "resize",
 947                    "RIGHT", "right",
 948                 "KP_RIGHT", "right",
 949              "shift RIGHT", "shrinkRight",
 950           "shift KP_RIGHT", "shrinkRight",
 951                     "LEFT", "left",
 952                  "KP_LEFT", "left",
 953               "shift LEFT", "shrinkLeft",
 954            "shift KP_LEFT", "shrinkLeft",
 955                       "UP", "up",
 956                    "KP_UP", "up",
 957                 "shift UP", "shrinkUp",
 958              "shift KP_UP", "shrinkUp",
 959                     "DOWN", "down",
 960                  "KP_DOWN", "down",
 961               "shift DOWN", "shrinkDown",
 962            "shift KP_DOWN", "shrinkDown",
 963                   "ESCAPE", "escape",
 964                  "ctrl F9", "minimize",
 965                 "ctrl F10", "maximize",
 966                  "ctrl F6", "selectNextFrame",
 967                 "ctrl TAB", "selectNextFrame",
 968              "ctrl alt F6", "selectNextFrame",
 969        "shift ctrl alt F6", "selectPreviousFrame",
 970                 "ctrl F12", "navigateNext",
 971           "shift ctrl F12", "navigatePrevious"
 972               }),
 973 
 974             // *** Label
 975             "Label.font", dialogPlain12,
 976             "Label.background", control,
 977             "Label.foreground", controlText,
 978             "Label.disabledForeground", white,
 979             "Label.disabledShadow", controlShadow,
 980             "Label.border", null,
 981 
 982             // *** List
 983             "List.font", dialogPlain12,
 984             "List.background", window,
 985             "List.foreground", textText,
 986             "List.selectionBackground", textHighlight,
 987             "List.selectionForeground", textHighlightText,
 988             "List.noFocusBorder", noFocusBorder,
 989             "List.focusCellHighlightBorder", focusCellHighlightBorder,
 990             "List.dropLineColor", controlShadow,
 991             "List.border", null,
 992             "List.cellRenderer", listCellRendererActiveValue,
 993             "List.timeFactor", oneThousand,
 994             "List.focusInputMap",
 995                new UIDefaults.LazyInputMap(new Object[] {
 996                            "ctrl C", "copy",
 997                            "ctrl V", "paste",
 998                            "ctrl X", "cut",
 999                              "COPY", "copy",
1000                             "PASTE", "paste",
1001                               "CUT", "cut",
1002                    "control INSERT", "copy",
1003                      "shift INSERT", "paste",
1004                      "shift DELETE", "cut",
1005                                "UP", "selectPreviousRow",
1006                             "KP_UP", "selectPreviousRow",
1007                          "shift UP", "selectPreviousRowExtendSelection",
1008                       "shift KP_UP", "selectPreviousRowExtendSelection",
1009                     "ctrl shift UP", "selectPreviousRowExtendSelection",
1010                  "ctrl shift KP_UP", "selectPreviousRowExtendSelection",
1011                           "ctrl UP", "selectPreviousRowChangeLead",
1012                        "ctrl KP_UP", "selectPreviousRowChangeLead",
1013                              "DOWN", "selectNextRow",
1014                           "KP_DOWN", "selectNextRow",
1015                        "shift DOWN", "selectNextRowExtendSelection",
1016                     "shift KP_DOWN", "selectNextRowExtendSelection",
1017                   "ctrl shift DOWN", "selectNextRowExtendSelection",
1018                "ctrl shift KP_DOWN", "selectNextRowExtendSelection",
1019                         "ctrl DOWN", "selectNextRowChangeLead",
1020                      "ctrl KP_DOWN", "selectNextRowChangeLead",
1021                              "LEFT", "selectPreviousColumn",
1022                           "KP_LEFT", "selectPreviousColumn",
1023                        "shift LEFT", "selectPreviousColumnExtendSelection",
1024                     "shift KP_LEFT", "selectPreviousColumnExtendSelection",
1025                   "ctrl shift LEFT", "selectPreviousColumnExtendSelection",
1026                "ctrl shift KP_LEFT", "selectPreviousColumnExtendSelection",
1027                         "ctrl LEFT", "selectPreviousColumnChangeLead",
1028                      "ctrl KP_LEFT", "selectPreviousColumnChangeLead",
1029                             "RIGHT", "selectNextColumn",
1030                          "KP_RIGHT", "selectNextColumn",
1031                       "shift RIGHT", "selectNextColumnExtendSelection",
1032                    "shift KP_RIGHT", "selectNextColumnExtendSelection",
1033                  "ctrl shift RIGHT", "selectNextColumnExtendSelection",
1034               "ctrl shift KP_RIGHT", "selectNextColumnExtendSelection",
1035                        "ctrl RIGHT", "selectNextColumnChangeLead",
1036                     "ctrl KP_RIGHT", "selectNextColumnChangeLead",
1037                              "HOME", "selectFirstRow",
1038                        "shift HOME", "selectFirstRowExtendSelection",
1039                   "ctrl shift HOME", "selectFirstRowExtendSelection",
1040                         "ctrl HOME", "selectFirstRowChangeLead",
1041                               "END", "selectLastRow",
1042                         "shift END", "selectLastRowExtendSelection",
1043                    "ctrl shift END", "selectLastRowExtendSelection",
1044                          "ctrl END", "selectLastRowChangeLead",
1045                           "PAGE_UP", "scrollUp",
1046                     "shift PAGE_UP", "scrollUpExtendSelection",
1047                "ctrl shift PAGE_UP", "scrollUpExtendSelection",
1048                      "ctrl PAGE_UP", "scrollUpChangeLead",
1049                         "PAGE_DOWN", "scrollDown",
1050                   "shift PAGE_DOWN", "scrollDownExtendSelection",
1051              "ctrl shift PAGE_DOWN", "scrollDownExtendSelection",
1052                    "ctrl PAGE_DOWN", "scrollDownChangeLead",
1053                            "ctrl A", "selectAll",
1054                        "ctrl SLASH", "selectAll",
1055                   "ctrl BACK_SLASH", "clearSelection",
1056                             "SPACE", "addToSelection",
1057                        "ctrl SPACE", "toggleAndAnchor",
1058                       "shift SPACE", "extendTo",
1059                  "ctrl shift SPACE", "moveSelectionTo"
1060                  }),
1061             "List.focusInputMap.RightToLeft",
1062                new UIDefaults.LazyInputMap(new Object[] {
1063                              "LEFT", "selectNextColumn",
1064                           "KP_LEFT", "selectNextColumn",
1065                        "shift LEFT", "selectNextColumnExtendSelection",
1066                     "shift KP_LEFT", "selectNextColumnExtendSelection",
1067                   "ctrl shift LEFT", "selectNextColumnExtendSelection",
1068                "ctrl shift KP_LEFT", "selectNextColumnExtendSelection",
1069                         "ctrl LEFT", "selectNextColumnChangeLead",
1070                      "ctrl KP_LEFT", "selectNextColumnChangeLead",
1071                             "RIGHT", "selectPreviousColumn",
1072                          "KP_RIGHT", "selectPreviousColumn",
1073                       "shift RIGHT", "selectPreviousColumnExtendSelection",
1074                    "shift KP_RIGHT", "selectPreviousColumnExtendSelection",
1075                  "ctrl shift RIGHT", "selectPreviousColumnExtendSelection",
1076               "ctrl shift KP_RIGHT", "selectPreviousColumnExtendSelection",
1077                        "ctrl RIGHT", "selectPreviousColumnChangeLead",
1078                     "ctrl KP_RIGHT", "selectPreviousColumnChangeLead",
1079                  }),
1080 
1081             // *** Menus
1082             "MenuBar.font", dialogPlain12,
1083             "MenuBar.background", menu,
1084             "MenuBar.foreground", menuText,
1085             "MenuBar.shadow", controlShadow,
1086             "MenuBar.highlight", controlLtHighlight,
1087             "MenuBar.border", menuBarBorder,
1088             "MenuBar.windowBindings", new Object[] {
1089                 "F10", "takeFocus" },
1090 
1091             "MenuItem.font", dialogPlain12,
1092             "MenuItem.acceleratorFont", dialogPlain12,
1093             "MenuItem.background", menu,
1094             "MenuItem.foreground", menuText,
1095             "MenuItem.selectionForeground", textHighlightText,
1096             "MenuItem.selectionBackground", textHighlight,
1097             "MenuItem.disabledForeground", null,
1098             "MenuItem.acceleratorForeground", menuText,
1099             "MenuItem.acceleratorSelectionForeground", textHighlightText,
1100             "MenuItem.acceleratorDelimiter", menuItemAcceleratorDelimiter,
1101             "MenuItem.border", marginBorder,
1102             "MenuItem.borderPainted", Boolean.FALSE,
1103             "MenuItem.margin", twoInsets,
1104             "MenuItem.checkIcon", menuItemCheckIcon,
1105             "MenuItem.arrowIcon", menuItemArrowIcon,
1106             "MenuItem.commandSound", null,
1107 
1108             "RadioButtonMenuItem.font", dialogPlain12,
1109             "RadioButtonMenuItem.acceleratorFont", dialogPlain12,
1110             "RadioButtonMenuItem.background", menu,
1111             "RadioButtonMenuItem.foreground", menuText,
1112             "RadioButtonMenuItem.selectionForeground", textHighlightText,
1113             "RadioButtonMenuItem.selectionBackground", textHighlight,
1114             "RadioButtonMenuItem.disabledForeground", null,
1115             "RadioButtonMenuItem.acceleratorForeground", menuText,
1116             "RadioButtonMenuItem.acceleratorSelectionForeground", textHighlightText,
1117             "RadioButtonMenuItem.border", marginBorder,
1118             "RadioButtonMenuItem.borderPainted", Boolean.FALSE,
1119             "RadioButtonMenuItem.margin", twoInsets,
1120             "RadioButtonMenuItem.checkIcon", radioButtonMenuItemIcon,
1121             "RadioButtonMenuItem.arrowIcon", menuItemArrowIcon,
1122             "RadioButtonMenuItem.commandSound", null,
1123 
1124             "CheckBoxMenuItem.font", dialogPlain12,
1125             "CheckBoxMenuItem.acceleratorFont", dialogPlain12,
1126             "CheckBoxMenuItem.background", menu,
1127             "CheckBoxMenuItem.foreground", menuText,
1128             "CheckBoxMenuItem.selectionForeground", textHighlightText,
1129             "CheckBoxMenuItem.selectionBackground", textHighlight,
1130             "CheckBoxMenuItem.disabledForeground", null,
1131             "CheckBoxMenuItem.acceleratorForeground", menuText,
1132             "CheckBoxMenuItem.acceleratorSelectionForeground", textHighlightText,
1133             "CheckBoxMenuItem.border", marginBorder,
1134             "CheckBoxMenuItem.borderPainted", Boolean.FALSE,
1135             "CheckBoxMenuItem.margin", twoInsets,
1136             "CheckBoxMenuItem.checkIcon", checkBoxMenuItemIcon,
1137             "CheckBoxMenuItem.arrowIcon", menuItemArrowIcon,
1138             "CheckBoxMenuItem.commandSound", null,
1139 
1140             "Menu.font", dialogPlain12,
1141             "Menu.acceleratorFont", dialogPlain12,
1142             "Menu.background", menu,
1143             "Menu.foreground", menuText,
1144             "Menu.selectionForeground", textHighlightText,
1145             "Menu.selectionBackground", textHighlight,
1146             "Menu.disabledForeground", null,
1147             "Menu.acceleratorForeground", menuText,
1148             "Menu.acceleratorSelectionForeground", textHighlightText,
1149             "Menu.border", marginBorder,
1150             "Menu.borderPainted", Boolean.FALSE,
1151             "Menu.margin", twoInsets,
1152             "Menu.checkIcon", menuItemCheckIcon,
1153             "Menu.arrowIcon", menuArrowIcon,
1154             "Menu.menuPopupOffsetX", new Integer(0),
1155             "Menu.menuPopupOffsetY", new Integer(0),
1156             "Menu.submenuPopupOffsetX", new Integer(0),
1157             "Menu.submenuPopupOffsetY", new Integer(0),
1158             "Menu.shortcutKeys", new int[]{
1159                 SwingUtilities2.getSystemMnemonicKeyMask()
1160             },
1161             "Menu.crossMenuMnemonic", Boolean.TRUE,
1162             // Menu.cancelMode affects the cancel menu action behaviour;
1163             // currently supports:
1164             // "hideLastSubmenu" (default)
1165             //     hides the last open submenu,
1166             //     and move selection one step back
1167             // "hideMenuTree"
1168             //     resets selection and
1169             //     hide the entire structure of open menu and its submenus
1170             "Menu.cancelMode", "hideLastSubmenu",
1171 
1172              // Menu.preserveTopLevelSelection affects
1173              // the cancel menu action behaviour
1174              // if set to true then top level menu selection
1175              // will be preserved when the last popup was cancelled;
1176              // the menu itself will be unselect with the next cancel action
1177              "Menu.preserveTopLevelSelection", Boolean.FALSE,
1178 
1179             // PopupMenu
1180             "PopupMenu.font", dialogPlain12,
1181             "PopupMenu.background", menu,
1182             "PopupMenu.foreground", menuText,
1183             "PopupMenu.border", popupMenuBorder,
1184                  // Internal Frame Auditory Cue Mappings
1185             "PopupMenu.popupSound", null,
1186             // These window InputMap bindings are used when the Menu is
1187             // selected.
1188             "PopupMenu.selectedWindowInputMapBindings", new Object[] {
1189                   "ESCAPE", "cancel",
1190                     "DOWN", "selectNext",
1191                  "KP_DOWN", "selectNext",
1192                       "UP", "selectPrevious",
1193                    "KP_UP", "selectPrevious",
1194                     "LEFT", "selectParent",
1195                  "KP_LEFT", "selectParent",
1196                    "RIGHT", "selectChild",
1197                 "KP_RIGHT", "selectChild",
1198                    "ENTER", "return",
1199               "ctrl ENTER", "return",
1200                    "SPACE", "return"
1201             },
1202             "PopupMenu.selectedWindowInputMapBindings.RightToLeft", new Object[] {
1203                     "LEFT", "selectChild",
1204                  "KP_LEFT", "selectChild",
1205                    "RIGHT", "selectParent",
1206                 "KP_RIGHT", "selectParent",
1207             },
1208             "PopupMenu.consumeEventOnClose", Boolean.FALSE,
1209 
1210             // *** OptionPane
1211             // You can additionaly define OptionPane.messageFont which will
1212             // dictate the fonts used for the message, and
1213             // OptionPane.buttonFont, which defines the font for the buttons.
1214             "OptionPane.font", dialogPlain12,
1215             "OptionPane.background", control,
1216             "OptionPane.foreground", controlText,
1217             "OptionPane.messageForeground", controlText,
1218             "OptionPane.border", optionPaneBorder,
1219             "OptionPane.messageAreaBorder", zeroBorder,
1220             "OptionPane.buttonAreaBorder", optionPaneButtonAreaBorder,
1221             "OptionPane.minimumSize", optionPaneMinimumSize,
1222             "OptionPane.errorIcon", SwingUtilities2.makeIcon(getClass(),
1223                                                              BasicLookAndFeel.class,
1224                                                              "icons/Error.gif"),
1225             "OptionPane.informationIcon", SwingUtilities2.makeIcon(getClass(),
1226                                                                    BasicLookAndFeel.class,
1227                                                                    "icons/Inform.gif"),
1228             "OptionPane.warningIcon", SwingUtilities2.makeIcon(getClass(),
1229                                                                BasicLookAndFeel.class,
1230                                                                "icons/Warn.gif"),
1231             "OptionPane.questionIcon", SwingUtilities2.makeIcon(getClass(),
1232                                                                 BasicLookAndFeel.class,
1233                                                                 "icons/Question.gif"),
1234             "OptionPane.windowBindings", new Object[] {
1235                 "ESCAPE", "close" },
1236                  // OptionPane Auditory Cue Mappings
1237             "OptionPane.errorSound", null,
1238             "OptionPane.informationSound", null, // Info and Plain
1239             "OptionPane.questionSound", null,
1240             "OptionPane.warningSound", null,
1241             "OptionPane.buttonClickThreshhold", fiveHundred,
1242 
1243             // *** Panel
1244             "Panel.font", dialogPlain12,
1245             "Panel.background", control,
1246             "Panel.foreground", textText,
1247 
1248             // *** ProgressBar
1249             "ProgressBar.font", dialogPlain12,
1250             "ProgressBar.foreground",  textHighlight,
1251             "ProgressBar.background", control,
1252             "ProgressBar.selectionForeground", control,
1253             "ProgressBar.selectionBackground", textHighlight,
1254             "ProgressBar.border", progressBarBorder,
1255             "ProgressBar.cellLength", new Integer(1),
1256             "ProgressBar.cellSpacing", zero,
1257             "ProgressBar.repaintInterval", new Integer(50),
1258             "ProgressBar.cycleTime", new Integer(3000),
1259             "ProgressBar.horizontalSize", new DimensionUIResource(146, 12),
1260             "ProgressBar.verticalSize", new DimensionUIResource(12, 146),
1261 
1262            // *** Separator
1263             "Separator.shadow", controlShadow,          // DEPRECATED - DO NOT USE!
1264             "Separator.highlight", controlLtHighlight,  // DEPRECATED - DO NOT USE!
1265 
1266             "Separator.background", controlLtHighlight,
1267             "Separator.foreground", controlShadow,
1268 
1269             // *** ScrollBar/ScrollPane/Viewport
1270             "ScrollBar.background", scrollBarTrack,
1271             "ScrollBar.foreground", control,
1272             "ScrollBar.track", table.get("scrollbar"),
1273             "ScrollBar.trackHighlight", controlDkShadow,
1274             "ScrollBar.thumb", control,
1275             "ScrollBar.thumbHighlight", controlLtHighlight,
1276             "ScrollBar.thumbDarkShadow", controlDkShadow,
1277             "ScrollBar.thumbShadow", controlShadow,
1278             "ScrollBar.border", null,
1279             "ScrollBar.minimumThumbSize", minimumThumbSize,
1280             "ScrollBar.maximumThumbSize", maximumThumbSize,
1281             "ScrollBar.ancestorInputMap",
1282                new UIDefaults.LazyInputMap(new Object[] {
1283                        "RIGHT", "positiveUnitIncrement",
1284                     "KP_RIGHT", "positiveUnitIncrement",
1285                         "DOWN", "positiveUnitIncrement",
1286                      "KP_DOWN", "positiveUnitIncrement",
1287                    "PAGE_DOWN", "positiveBlockIncrement",
1288                         "LEFT", "negativeUnitIncrement",
1289                      "KP_LEFT", "negativeUnitIncrement",
1290                           "UP", "negativeUnitIncrement",
1291                        "KP_UP", "negativeUnitIncrement",
1292                      "PAGE_UP", "negativeBlockIncrement",
1293                         "HOME", "minScroll",
1294                          "END", "maxScroll"
1295                  }),
1296             "ScrollBar.ancestorInputMap.RightToLeft",
1297                new UIDefaults.LazyInputMap(new Object[] {
1298                        "RIGHT", "negativeUnitIncrement",
1299                     "KP_RIGHT", "negativeUnitIncrement",
1300                         "LEFT", "positiveUnitIncrement",
1301                      "KP_LEFT", "positiveUnitIncrement",
1302                  }),
1303             "ScrollBar.width", new Integer(16),
1304 
1305             "ScrollPane.font", dialogPlain12,
1306             "ScrollPane.background", control,
1307             "ScrollPane.foreground", controlText,
1308             "ScrollPane.border", textFieldBorder,
1309             "ScrollPane.viewportBorder", null,
1310             "ScrollPane.ancestorInputMap",
1311                new UIDefaults.LazyInputMap(new Object[] {
1312                            "RIGHT", "unitScrollRight",
1313                         "KP_RIGHT", "unitScrollRight",
1314                             "DOWN", "unitScrollDown",
1315                          "KP_DOWN", "unitScrollDown",
1316                             "LEFT", "unitScrollLeft",
1317                          "KP_LEFT", "unitScrollLeft",
1318                               "UP", "unitScrollUp",
1319                            "KP_UP", "unitScrollUp",
1320                          "PAGE_UP", "scrollUp",
1321                        "PAGE_DOWN", "scrollDown",
1322                     "ctrl PAGE_UP", "scrollLeft",
1323                   "ctrl PAGE_DOWN", "scrollRight",
1324                        "ctrl HOME", "scrollHome",
1325                         "ctrl END", "scrollEnd"
1326                  }),
1327             "ScrollPane.ancestorInputMap.RightToLeft",
1328                new UIDefaults.LazyInputMap(new Object[] {
1329                     "ctrl PAGE_UP", "scrollRight",
1330                   "ctrl PAGE_DOWN", "scrollLeft",
1331                  }),
1332 
1333             "Viewport.font", dialogPlain12,
1334             "Viewport.background", control,
1335             "Viewport.foreground", textText,
1336 
1337             // *** Slider
1338             "Slider.font", dialogPlain12,
1339             "Slider.foreground", control,
1340             "Slider.background", control,
1341             "Slider.highlight", controlLtHighlight,
1342             "Slider.tickColor", Color.black,
1343             "Slider.shadow", controlShadow,
1344             "Slider.focus", controlDkShadow,
1345             "Slider.border", null,
1346             "Slider.horizontalSize", new Dimension(200, 21),
1347             "Slider.verticalSize", new Dimension(21, 200),
1348             "Slider.minimumHorizontalSize", new Dimension(36, 21),
1349             "Slider.minimumVerticalSize", new Dimension(21, 36),
1350             "Slider.focusInsets", sliderFocusInsets,
1351             "Slider.focusInputMap",
1352                new UIDefaults.LazyInputMap(new Object[] {
1353                        "RIGHT", "positiveUnitIncrement",
1354                     "KP_RIGHT", "positiveUnitIncrement",
1355                         "DOWN", "negativeUnitIncrement",
1356                      "KP_DOWN", "negativeUnitIncrement",
1357                    "PAGE_DOWN", "negativeBlockIncrement",
1358                         "LEFT", "negativeUnitIncrement",
1359                      "KP_LEFT", "negativeUnitIncrement",
1360                           "UP", "positiveUnitIncrement",
1361                        "KP_UP", "positiveUnitIncrement",
1362                      "PAGE_UP", "positiveBlockIncrement",
1363                         "HOME", "minScroll",
1364                          "END", "maxScroll"
1365                  }),
1366             "Slider.focusInputMap.RightToLeft",
1367                new UIDefaults.LazyInputMap(new Object[] {
1368                        "RIGHT", "negativeUnitIncrement",
1369                     "KP_RIGHT", "negativeUnitIncrement",
1370                         "LEFT", "positiveUnitIncrement",
1371                      "KP_LEFT", "positiveUnitIncrement",
1372                  }),
1373             "Slider.onlyLeftMouseButtonDrag", Boolean.TRUE,
1374 
1375             // *** Spinner
1376             "Spinner.font", monospacedPlain12,
1377             "Spinner.background", control,
1378             "Spinner.foreground", control,
1379             "Spinner.border", textFieldBorder,
1380             "Spinner.arrowButtonBorder", null,
1381             "Spinner.arrowButtonInsets", null,
1382             "Spinner.arrowButtonSize", new Dimension(16, 5),
1383             "Spinner.ancestorInputMap",
1384                new UIDefaults.LazyInputMap(new Object[] {
1385                                "UP", "increment",
1386                             "KP_UP", "increment",
1387                              "DOWN", "decrement",
1388                           "KP_DOWN", "decrement",
1389                }),
1390             "Spinner.editorBorderPainted", Boolean.FALSE,
1391             "Spinner.editorAlignment", JTextField.TRAILING,
1392 
1393             // *** SplitPane
1394             "SplitPane.background", control,
1395             "SplitPane.highlight", controlLtHighlight,
1396             "SplitPane.shadow", controlShadow,
1397             "SplitPane.darkShadow", controlDkShadow,
1398             "SplitPane.border", splitPaneBorder,
1399             "SplitPane.dividerSize", new Integer(7),
1400             "SplitPaneDivider.border", splitPaneDividerBorder,
1401             "SplitPaneDivider.draggingColor", darkGray,
1402             "SplitPane.ancestorInputMap",
1403                new UIDefaults.LazyInputMap(new Object[] {
1404                         "UP", "negativeIncrement",
1405                       "DOWN", "positiveIncrement",
1406                       "LEFT", "negativeIncrement",
1407                      "RIGHT", "positiveIncrement",
1408                      "KP_UP", "negativeIncrement",
1409                    "KP_DOWN", "positiveIncrement",
1410                    "KP_LEFT", "negativeIncrement",
1411                   "KP_RIGHT", "positiveIncrement",
1412                       "HOME", "selectMin",
1413                        "END", "selectMax",
1414                         "F8", "startResize",
1415                         "F6", "toggleFocus",
1416                   "ctrl TAB", "focusOutForward",
1417             "ctrl shift TAB", "focusOutBackward"
1418                  }),
1419 
1420             // *** TabbedPane
1421             "TabbedPane.font", dialogPlain12,
1422             "TabbedPane.background", control,
1423             "TabbedPane.foreground", controlText,
1424             "TabbedPane.highlight", controlLtHighlight,
1425             "TabbedPane.light", controlHighlight,
1426             "TabbedPane.shadow", controlShadow,
1427             "TabbedPane.darkShadow", controlDkShadow,
1428             "TabbedPane.selected", null,
1429             "TabbedPane.focus", controlText,
1430             "TabbedPane.textIconGap", four,
1431 
1432             // Causes tabs to be painted on top of the content area border.
1433             // The amount of overlap is then controlled by tabAreaInsets.bottom,
1434             // which is zero by default
1435             "TabbedPane.tabsOverlapBorder", Boolean.FALSE,
1436             "TabbedPane.selectionFollowsFocus", Boolean.TRUE,
1437 
1438             "TabbedPane.labelShift", 1,
1439             "TabbedPane.selectedLabelShift", -1,
1440             "TabbedPane.tabInsets", tabbedPaneTabInsets,
1441             "TabbedPane.selectedTabPadInsets", tabbedPaneTabPadInsets,
1442             "TabbedPane.tabAreaInsets", tabbedPaneTabAreaInsets,
1443             "TabbedPane.contentBorderInsets", tabbedPaneContentBorderInsets,
1444             "TabbedPane.tabRunOverlay", new Integer(2),
1445             "TabbedPane.tabsOpaque", Boolean.TRUE,
1446             "TabbedPane.contentOpaque", Boolean.TRUE,
1447             "TabbedPane.focusInputMap",
1448               new UIDefaults.LazyInputMap(new Object[] {
1449                          "RIGHT", "navigateRight",
1450                       "KP_RIGHT", "navigateRight",
1451                           "LEFT", "navigateLeft",
1452                        "KP_LEFT", "navigateLeft",
1453                             "UP", "navigateUp",
1454                          "KP_UP", "navigateUp",
1455                           "DOWN", "navigateDown",
1456                        "KP_DOWN", "navigateDown",
1457                      "ctrl DOWN", "requestFocusForVisibleComponent",
1458                   "ctrl KP_DOWN", "requestFocusForVisibleComponent",
1459                 }),
1460             "TabbedPane.ancestorInputMap",
1461                new UIDefaults.LazyInputMap(new Object[] {
1462                    "ctrl PAGE_DOWN", "navigatePageDown",
1463                      "ctrl PAGE_UP", "navigatePageUp",
1464                           "ctrl UP", "requestFocus",
1465                        "ctrl KP_UP", "requestFocus",
1466                  }),
1467 
1468 
1469             // *** Table
1470             "Table.font", dialogPlain12,
1471             "Table.foreground", controlText,  // cell text color
1472             "Table.background", window,  // cell background color
1473             "Table.selectionForeground", textHighlightText,
1474             "Table.selectionBackground", textHighlight,
1475             "Table.dropLineColor", controlShadow,
1476             "Table.dropLineShortColor", black,
1477             "Table.gridColor", gray,  // grid line color
1478             "Table.focusCellBackground", window,
1479             "Table.focusCellForeground", controlText,
1480             "Table.focusCellHighlightBorder", focusCellHighlightBorder,
1481             "Table.scrollPaneBorder", loweredBevelBorder,
1482             "Table.ancestorInputMap",
1483                new UIDefaults.LazyInputMap(new Object[] {
1484                                "ctrl C", "copy",
1485                                "ctrl V", "paste",
1486                                "ctrl X", "cut",
1487                                  "COPY", "copy",
1488                                 "PASTE", "paste",
1489                                   "CUT", "cut",
1490                        "control INSERT", "copy",
1491                          "shift INSERT", "paste",
1492                          "shift DELETE", "cut",
1493                                 "RIGHT", "selectNextColumn",
1494                              "KP_RIGHT", "selectNextColumn",
1495                           "shift RIGHT", "selectNextColumnExtendSelection",
1496                        "shift KP_RIGHT", "selectNextColumnExtendSelection",
1497                      "ctrl shift RIGHT", "selectNextColumnExtendSelection",
1498                   "ctrl shift KP_RIGHT", "selectNextColumnExtendSelection",
1499                            "ctrl RIGHT", "selectNextColumnChangeLead",
1500                         "ctrl KP_RIGHT", "selectNextColumnChangeLead",
1501                                  "LEFT", "selectPreviousColumn",
1502                               "KP_LEFT", "selectPreviousColumn",
1503                            "shift LEFT", "selectPreviousColumnExtendSelection",
1504                         "shift KP_LEFT", "selectPreviousColumnExtendSelection",
1505                       "ctrl shift LEFT", "selectPreviousColumnExtendSelection",
1506                    "ctrl shift KP_LEFT", "selectPreviousColumnExtendSelection",
1507                             "ctrl LEFT", "selectPreviousColumnChangeLead",
1508                          "ctrl KP_LEFT", "selectPreviousColumnChangeLead",
1509                                  "DOWN", "selectNextRow",
1510                               "KP_DOWN", "selectNextRow",
1511                            "shift DOWN", "selectNextRowExtendSelection",
1512                         "shift KP_DOWN", "selectNextRowExtendSelection",
1513                       "ctrl shift DOWN", "selectNextRowExtendSelection",
1514                    "ctrl shift KP_DOWN", "selectNextRowExtendSelection",
1515                             "ctrl DOWN", "selectNextRowChangeLead",
1516                          "ctrl KP_DOWN", "selectNextRowChangeLead",
1517                                    "UP", "selectPreviousRow",
1518                                 "KP_UP", "selectPreviousRow",
1519                              "shift UP", "selectPreviousRowExtendSelection",
1520                           "shift KP_UP", "selectPreviousRowExtendSelection",
1521                         "ctrl shift UP", "selectPreviousRowExtendSelection",
1522                      "ctrl shift KP_UP", "selectPreviousRowExtendSelection",
1523                               "ctrl UP", "selectPreviousRowChangeLead",
1524                            "ctrl KP_UP", "selectPreviousRowChangeLead",
1525                                  "HOME", "selectFirstColumn",
1526                            "shift HOME", "selectFirstColumnExtendSelection",
1527                       "ctrl shift HOME", "selectFirstRowExtendSelection",
1528                             "ctrl HOME", "selectFirstRow",
1529                                   "END", "selectLastColumn",
1530                             "shift END", "selectLastColumnExtendSelection",
1531                        "ctrl shift END", "selectLastRowExtendSelection",
1532                              "ctrl END", "selectLastRow",
1533                               "PAGE_UP", "scrollUpChangeSelection",
1534                         "shift PAGE_UP", "scrollUpExtendSelection",
1535                    "ctrl shift PAGE_UP", "scrollLeftExtendSelection",
1536                          "ctrl PAGE_UP", "scrollLeftChangeSelection",
1537                             "PAGE_DOWN", "scrollDownChangeSelection",
1538                       "shift PAGE_DOWN", "scrollDownExtendSelection",
1539                  "ctrl shift PAGE_DOWN", "scrollRightExtendSelection",
1540                        "ctrl PAGE_DOWN", "scrollRightChangeSelection",
1541                                   "TAB", "selectNextColumnCell",
1542                             "shift TAB", "selectPreviousColumnCell",
1543                                 "ENTER", "selectNextRowCell",
1544                           "shift ENTER", "selectPreviousRowCell",
1545                                "ctrl A", "selectAll",
1546                            "ctrl SLASH", "selectAll",
1547                       "ctrl BACK_SLASH", "clearSelection",
1548                                "ESCAPE", "cancel",
1549                                    "F2", "startEditing",
1550                                 "SPACE", "addToSelection",
1551                            "ctrl SPACE", "toggleAndAnchor",
1552                           "shift SPACE", "extendTo",
1553                      "ctrl shift SPACE", "moveSelectionTo",
1554                                    "F8", "focusHeader"
1555                  }),
1556             "Table.ancestorInputMap.RightToLeft",
1557                new UIDefaults.LazyInputMap(new Object[] {
1558                                 "RIGHT", "selectPreviousColumn",
1559                              "KP_RIGHT", "selectPreviousColumn",
1560                           "shift RIGHT", "selectPreviousColumnExtendSelection",
1561                        "shift KP_RIGHT", "selectPreviousColumnExtendSelection",
1562                      "ctrl shift RIGHT", "selectPreviousColumnExtendSelection",
1563                   "ctrl shift KP_RIGHT", "selectPreviousColumnExtendSelection",
1564                            "ctrl RIGHT", "selectPreviousColumnChangeLead",
1565                         "ctrl KP_RIGHT", "selectPreviousColumnChangeLead",
1566                                  "LEFT", "selectNextColumn",
1567                               "KP_LEFT", "selectNextColumn",
1568                            "shift LEFT", "selectNextColumnExtendSelection",
1569                         "shift KP_LEFT", "selectNextColumnExtendSelection",
1570                       "ctrl shift LEFT", "selectNextColumnExtendSelection",
1571                    "ctrl shift KP_LEFT", "selectNextColumnExtendSelection",
1572                             "ctrl LEFT", "selectNextColumnChangeLead",
1573                          "ctrl KP_LEFT", "selectNextColumnChangeLead",
1574                          "ctrl PAGE_UP", "scrollRightChangeSelection",
1575                        "ctrl PAGE_DOWN", "scrollLeftChangeSelection",
1576                    "ctrl shift PAGE_UP", "scrollRightExtendSelection",
1577                  "ctrl shift PAGE_DOWN", "scrollLeftExtendSelection",
1578                  }),
1579             "Table.ascendingSortIcon",  new SwingLazyValue(
1580                      "sun.swing.icon.SortArrowIcon",
1581                      null, new Object[] { Boolean.TRUE,
1582                                           "Table.sortIconColor" }),
1583             "Table.descendingSortIcon",  new SwingLazyValue(
1584                      "sun.swing.icon.SortArrowIcon",
1585                      null, new Object[] { Boolean.FALSE,
1586                                           "Table.sortIconColor" }),
1587             "Table.sortIconColor", controlShadow,
1588 
1589             "TableHeader.font", dialogPlain12,
1590             "TableHeader.foreground", controlText, // header text color
1591             "TableHeader.background", control, // header background
1592             "TableHeader.cellBorder", tableHeaderBorder,
1593 
1594             // Support for changing the background/border of the currently
1595             // selected header column when the header has the keyboard focus.
1596             "TableHeader.focusCellBackground", table.getColor("text"), // like text component bg
1597             "TableHeader.focusCellForeground", null,
1598             "TableHeader.focusCellBorder", null,
1599             "TableHeader.ancestorInputMap",
1600                new UIDefaults.LazyInputMap(new Object[] {
1601                                 "SPACE", "toggleSortOrder",
1602                                  "LEFT", "selectColumnToLeft",
1603                               "KP_LEFT", "selectColumnToLeft",
1604                                 "RIGHT", "selectColumnToRight",
1605                              "KP_RIGHT", "selectColumnToRight",
1606                              "alt LEFT", "moveColumnLeft",
1607                           "alt KP_LEFT", "moveColumnLeft",
1608                             "alt RIGHT", "moveColumnRight",
1609                          "alt KP_RIGHT", "moveColumnRight",
1610                        "alt shift LEFT", "resizeLeft",
1611                     "alt shift KP_LEFT", "resizeLeft",
1612                       "alt shift RIGHT", "resizeRight",
1613                    "alt shift KP_RIGHT", "resizeRight",
1614                                "ESCAPE", "focusTable",
1615                }),
1616 
1617             // *** Text
1618             "TextField.font", sansSerifPlain12,
1619             "TextField.background", window,
1620             "TextField.foreground", textText,
1621             "TextField.shadow", controlShadow,
1622             "TextField.darkShadow", controlDkShadow,
1623             "TextField.light", controlHighlight,
1624             "TextField.highlight", controlLtHighlight,
1625             "TextField.inactiveForeground", textInactiveText,
1626             "TextField.inactiveBackground", control,
1627             "TextField.selectionBackground", textHighlight,
1628             "TextField.selectionForeground", textHighlightText,
1629             "TextField.caretForeground", textText,
1630             "TextField.caretBlinkRate", caretBlinkRate,
1631             "TextField.border", textFieldBorder,
1632             "TextField.margin", zeroInsets,
1633 
1634             "FormattedTextField.font", sansSerifPlain12,
1635             "FormattedTextField.background", window,
1636             "FormattedTextField.foreground", textText,
1637             "FormattedTextField.inactiveForeground", textInactiveText,
1638             "FormattedTextField.inactiveBackground", control,
1639             "FormattedTextField.selectionBackground", textHighlight,
1640             "FormattedTextField.selectionForeground", textHighlightText,
1641             "FormattedTextField.caretForeground", textText,
1642             "FormattedTextField.caretBlinkRate", caretBlinkRate,
1643             "FormattedTextField.border", textFieldBorder,
1644             "FormattedTextField.margin", zeroInsets,
1645             "FormattedTextField.focusInputMap",
1646               new UIDefaults.LazyInputMap(new Object[] {
1647                            "ctrl C", DefaultEditorKit.copyAction,
1648                            "ctrl V", DefaultEditorKit.pasteAction,
1649                            "ctrl X", DefaultEditorKit.cutAction,
1650                              "COPY", DefaultEditorKit.copyAction,
1651                             "PASTE", DefaultEditorKit.pasteAction,
1652                               "CUT", DefaultEditorKit.cutAction,
1653                    "control INSERT", DefaultEditorKit.copyAction,
1654                      "shift INSERT", DefaultEditorKit.pasteAction,
1655                      "shift DELETE", DefaultEditorKit.cutAction,
1656                        "shift LEFT", DefaultEditorKit.selectionBackwardAction,
1657                     "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction,
1658                       "shift RIGHT", DefaultEditorKit.selectionForwardAction,
1659                    "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction,
1660                         "ctrl LEFT", DefaultEditorKit.previousWordAction,
1661                      "ctrl KP_LEFT", DefaultEditorKit.previousWordAction,
1662                        "ctrl RIGHT", DefaultEditorKit.nextWordAction,
1663                     "ctrl KP_RIGHT", DefaultEditorKit.nextWordAction,
1664                   "ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
1665                "ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction,
1666                  "ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction,
1667               "ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction,
1668                            "ctrl A", DefaultEditorKit.selectAllAction,
1669                              "HOME", DefaultEditorKit.beginLineAction,
1670                               "END", DefaultEditorKit.endLineAction,
1671                        "shift HOME", DefaultEditorKit.selectionBeginLineAction,
1672                         "shift END", DefaultEditorKit.selectionEndLineAction,
1673                        "BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
1674                  "shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
1675                            "ctrl H", DefaultEditorKit.deletePrevCharAction,
1676                            "DELETE", DefaultEditorKit.deleteNextCharAction,
1677                       "ctrl DELETE", DefaultEditorKit.deleteNextWordAction,
1678                   "ctrl BACK_SPACE", DefaultEditorKit.deletePrevWordAction,
1679                             "RIGHT", DefaultEditorKit.forwardAction,
1680                              "LEFT", DefaultEditorKit.backwardAction,
1681                          "KP_RIGHT", DefaultEditorKit.forwardAction,
1682                           "KP_LEFT", DefaultEditorKit.backwardAction,
1683                             "ENTER", JTextField.notifyAction,
1684                   "ctrl BACK_SLASH", "unselect",
1685                   "control shift O", "toggle-componentOrientation",
1686                            "ESCAPE", "reset-field-edit",
1687                                "UP", "increment",
1688                             "KP_UP", "increment",
1689                              "DOWN", "decrement",
1690                           "KP_DOWN", "decrement",
1691               }),
1692 
1693             "PasswordField.font", monospacedPlain12,
1694             "PasswordField.background", window,
1695             "PasswordField.foreground", textText,
1696             "PasswordField.inactiveForeground", textInactiveText,
1697             "PasswordField.inactiveBackground", control,
1698             "PasswordField.selectionBackground", textHighlight,
1699             "PasswordField.selectionForeground", textHighlightText,
1700             "PasswordField.caretForeground", textText,
1701             "PasswordField.caretBlinkRate", caretBlinkRate,
1702             "PasswordField.border", textFieldBorder,
1703             "PasswordField.margin", zeroInsets,
1704             "PasswordField.echoChar", '*',
1705 
1706             "TextArea.font", monospacedPlain12,
1707             "TextArea.background", window,
1708             "TextArea.foreground", textText,
1709             "TextArea.inactiveForeground", textInactiveText,
1710             "TextArea.selectionBackground", textHighlight,
1711             "TextArea.selectionForeground", textHighlightText,
1712             "TextArea.caretForeground", textText,
1713             "TextArea.caretBlinkRate", caretBlinkRate,
1714             "TextArea.border", marginBorder,
1715             "TextArea.margin", zeroInsets,
1716 
1717             "TextPane.font", serifPlain12,
1718             "TextPane.background", white,
1719             "TextPane.foreground", textText,
1720             "TextPane.selectionBackground", textHighlight,
1721             "TextPane.selectionForeground", textHighlightText,
1722             "TextPane.caretForeground", textText,
1723             "TextPane.caretBlinkRate", caretBlinkRate,
1724             "TextPane.inactiveForeground", textInactiveText,
1725             "TextPane.border", marginBorder,
1726             "TextPane.margin", editorMargin,
1727 
1728             "EditorPane.font", serifPlain12,
1729             "EditorPane.background", white,
1730             "EditorPane.foreground", textText,
1731             "EditorPane.selectionBackground", textHighlight,
1732             "EditorPane.selectionForeground", textHighlightText,
1733             "EditorPane.caretForeground", textText,
1734             "EditorPane.caretBlinkRate", caretBlinkRate,
1735             "EditorPane.inactiveForeground", textInactiveText,
1736             "EditorPane.border", marginBorder,
1737             "EditorPane.margin", editorMargin,
1738 
1739             "html.pendingImage", SwingUtilities2.makeIcon(getClass(),
1740                                     BasicLookAndFeel.class,
1741                                     "icons/image-delayed.png"),
1742             "html.missingImage", SwingUtilities2.makeIcon(getClass(),
1743                                     BasicLookAndFeel.class,
1744                                     "icons/image-failed.png"),
1745             // *** TitledBorder
1746             "TitledBorder.font", dialogPlain12,
1747             "TitledBorder.titleColor", controlText,
1748             "TitledBorder.border", etchedBorder,
1749 
1750             // *** ToolBar
1751             "ToolBar.font", dialogPlain12,
1752             "ToolBar.background", control,
1753             "ToolBar.foreground", controlText,
1754             "ToolBar.shadow", controlShadow,
1755             "ToolBar.darkShadow", controlDkShadow,
1756             "ToolBar.light", controlHighlight,
1757             "ToolBar.highlight", controlLtHighlight,
1758             "ToolBar.dockingBackground", control,
1759             "ToolBar.dockingForeground", red,
1760             "ToolBar.floatingBackground", control,
1761             "ToolBar.floatingForeground", darkGray,
1762             "ToolBar.border", etchedBorder,
1763             "ToolBar.separatorSize", toolBarSeparatorSize,
1764             "ToolBar.ancestorInputMap",
1765                new UIDefaults.LazyInputMap(new Object[] {
1766                         "UP", "navigateUp",
1767                      "KP_UP", "navigateUp",
1768                       "DOWN", "navigateDown",
1769                    "KP_DOWN", "navigateDown",
1770                       "LEFT", "navigateLeft",
1771                    "KP_LEFT", "navigateLeft",
1772                      "RIGHT", "navigateRight",
1773                   "KP_RIGHT", "navigateRight"
1774                  }),
1775 
1776             // *** ToolTips
1777             "ToolTip.font", sansSerifPlain12,
1778             "ToolTip.background", table.get("info"),
1779             "ToolTip.foreground", table.get("infoText"),
1780             "ToolTip.border", blackLineBorder,
1781             // ToolTips also support backgroundInactive, borderInactive,
1782             // and foregroundInactive
1783 
1784         // *** ToolTipManager
1785             // ToolTipManager.enableToolTipMode currently supports:
1786             // "allWindows" (default):
1787             //     enables tool tips for all windows of all java applications,
1788             //     whether the windows are active or inactive
1789             // "activeApplication"
1790             //     enables tool tips for windows of an application only when
1791             //     the application has an active window
1792             "ToolTipManager.enableToolTipMode", "allWindows",
1793 
1794         // *** Tree
1795             "Tree.paintLines", Boolean.TRUE,
1796             "Tree.lineTypeDashed", Boolean.FALSE,
1797             "Tree.font", dialogPlain12,
1798             "Tree.background", window,
1799             "Tree.foreground", textText,
1800             "Tree.hash", gray,
1801             "Tree.textForeground", textText,
1802             "Tree.textBackground", table.get("text"),
1803             "Tree.selectionForeground", textHighlightText,
1804             "Tree.selectionBackground", textHighlight,
1805             "Tree.selectionBorderColor", black,
1806             "Tree.dropLineColor", controlShadow,
1807             "Tree.editorBorder", blackLineBorder,
1808             "Tree.leftChildIndent", new Integer(7),
1809             "Tree.rightChildIndent", new Integer(13),
1810             "Tree.rowHeight", new Integer(16),
1811             "Tree.scrollsOnExpand", Boolean.TRUE,
1812             "Tree.openIcon", SwingUtilities2.makeIcon(getClass(),
1813                                                       BasicLookAndFeel.class,
1814                                                       "icons/TreeOpen.gif"),
1815             "Tree.closedIcon", SwingUtilities2.makeIcon(getClass(),
1816                                                         BasicLookAndFeel.class,
1817                                                         "icons/TreeClosed.gif"),
1818             "Tree.leafIcon", SwingUtilities2.makeIcon(getClass(),
1819                                                       BasicLookAndFeel.class,
1820                                                       "icons/TreeLeaf.gif"),
1821             "Tree.expandedIcon", null,
1822             "Tree.collapsedIcon", null,
1823             "Tree.changeSelectionWithFocus", Boolean.TRUE,
1824             "Tree.drawsFocusBorderAroundIcon", Boolean.FALSE,
1825             "Tree.timeFactor", oneThousand,
1826             "Tree.focusInputMap",
1827                new UIDefaults.LazyInputMap(new Object[] {
1828                                  "ctrl C", "copy",
1829                                  "ctrl V", "paste",
1830                                  "ctrl X", "cut",
1831                                    "COPY", "copy",
1832                                   "PASTE", "paste",
1833                                     "CUT", "cut",
1834                          "control INSERT", "copy",
1835                            "shift INSERT", "paste",
1836                            "shift DELETE", "cut",
1837                                      "UP", "selectPrevious",
1838                                   "KP_UP", "selectPrevious",
1839                                "shift UP", "selectPreviousExtendSelection",
1840                             "shift KP_UP", "selectPreviousExtendSelection",
1841                           "ctrl shift UP", "selectPreviousExtendSelection",
1842                        "ctrl shift KP_UP", "selectPreviousExtendSelection",
1843                                 "ctrl UP", "selectPreviousChangeLead",
1844                              "ctrl KP_UP", "selectPreviousChangeLead",
1845                                    "DOWN", "selectNext",
1846                                 "KP_DOWN", "selectNext",
1847                              "shift DOWN", "selectNextExtendSelection",
1848                           "shift KP_DOWN", "selectNextExtendSelection",
1849                         "ctrl shift DOWN", "selectNextExtendSelection",
1850                      "ctrl shift KP_DOWN", "selectNextExtendSelection",
1851                               "ctrl DOWN", "selectNextChangeLead",
1852                            "ctrl KP_DOWN", "selectNextChangeLead",
1853                                   "RIGHT", "selectChild",
1854                                "KP_RIGHT", "selectChild",
1855                                    "LEFT", "selectParent",
1856                                 "KP_LEFT", "selectParent",
1857                                 "PAGE_UP", "scrollUpChangeSelection",
1858                           "shift PAGE_UP", "scrollUpExtendSelection",
1859                      "ctrl shift PAGE_UP", "scrollUpExtendSelection",
1860                            "ctrl PAGE_UP", "scrollUpChangeLead",
1861                               "PAGE_DOWN", "scrollDownChangeSelection",
1862                         "shift PAGE_DOWN", "scrollDownExtendSelection",
1863                    "ctrl shift PAGE_DOWN", "scrollDownExtendSelection",
1864                          "ctrl PAGE_DOWN", "scrollDownChangeLead",
1865                                    "HOME", "selectFirst",
1866                              "shift HOME", "selectFirstExtendSelection",
1867                         "ctrl shift HOME", "selectFirstExtendSelection",
1868                               "ctrl HOME", "selectFirstChangeLead",
1869                                     "END", "selectLast",
1870                               "shift END", "selectLastExtendSelection",
1871                          "ctrl shift END", "selectLastExtendSelection",
1872                                "ctrl END", "selectLastChangeLead",
1873                                      "F2", "startEditing",
1874                                  "ctrl A", "selectAll",
1875                              "ctrl SLASH", "selectAll",
1876                         "ctrl BACK_SLASH", "clearSelection",
1877                               "ctrl LEFT", "scrollLeft",
1878                            "ctrl KP_LEFT", "scrollLeft",
1879                              "ctrl RIGHT", "scrollRight",
1880                           "ctrl KP_RIGHT", "scrollRight",
1881                                   "SPACE", "addToSelection",
1882                              "ctrl SPACE", "toggleAndAnchor",
1883                             "shift SPACE", "extendTo",
1884                        "ctrl shift SPACE", "moveSelectionTo"
1885                  }),
1886             "Tree.focusInputMap.RightToLeft",
1887                new UIDefaults.LazyInputMap(new Object[] {
1888                                   "RIGHT", "selectParent",
1889                                "KP_RIGHT", "selectParent",
1890                                    "LEFT", "selectChild",
1891                                 "KP_LEFT", "selectChild",
1892                  }),
1893             "Tree.ancestorInputMap",
1894                new UIDefaults.LazyInputMap(new Object[] {
1895                      "ESCAPE", "cancel"
1896                  }),
1897             // Bind specific keys that can invoke popup on currently
1898             // focused JComponent
1899             "RootPane.ancestorInputMap",
1900                 new UIDefaults.LazyInputMap(new Object[] {
1901                      "shift F10", "postPopup",
1902                   "CONTEXT_MENU", "postPopup"
1903                   }),
1904 
1905             // These bindings are only enabled when there is a default
1906             // button set on the rootpane.
1907             "RootPane.defaultButtonWindowKeyBindings", new Object[] {
1908                              "ENTER", "press",
1909                     "released ENTER", "release",
1910                         "ctrl ENTER", "press",
1911                "ctrl released ENTER", "release"
1912               },
1913         };
1914 
1915         table.putDefaults(defaults);
1916     }
1917 
1918     static int getFocusAcceleratorKeyMask() {
1919         Toolkit tk = Toolkit.getDefaultToolkit();
1920         if (tk instanceof SunToolkit) {
1921             return ((SunToolkit)tk).getFocusAcceleratorKeyMask();
1922         }
1923         return ActionEvent.ALT_MASK;
1924     }
1925 
1926 
1927 
1928     /**
1929      * Returns the ui that is of type <code>klass</code>, or null if
1930      * one can not be found.
1931      */
1932     static Object getUIOfType(ComponentUI ui, Class klass) {
1933         if (klass.isInstance(ui)) {
1934             return ui;
1935         }
1936         return null;
1937     }
1938 
1939     // ********* Auditory Cue support methods and objects *********
1940     // also see the "AuditoryCues" section of the defaults table
1941 
1942     /**
1943      * Returns an <code>ActionMap</code> containing the audio actions
1944      * for this look and feel.
1945      * <P>
1946      * The returned <code>ActionMap</code> contains <code>Actions</code> that
1947      * embody the ability to render an auditory cue. These auditory
1948      * cues map onto user and system activities that may be useful
1949      * for an end user to know about (such as a dialog box appearing).
1950      * <P>
1951      * At the appropriate time,
1952      * the {@code ComponentUI} is responsible for obtaining an
1953      * <code>Action</code> out of the <code>ActionMap</code> and passing
1954      * it to <code>playSound</code>.
1955      * <P>
1956      * This method first looks up the {@code ActionMap} from the
1957      * defaults using the key {@code "AuditoryCues.actionMap"}.
1958      * <p>
1959      * If the value is {@code non-null}, it is returned. If the value
1960      * of the default {@code "AuditoryCues.actionMap"} is {@code null}
1961      * and the value of the default {@code "AuditoryCues.cueList"} is
1962      * {@code non-null}, an {@code ActionMapUIResource} is created and
1963      * populated. Population is done by iterating over each of the
1964      * elements of the {@code "AuditoryCues.cueList"} array, and
1965      * invoking {@code createAudioAction()} to create an {@code
1966      * Action} for each element.  The resulting {@code Action} is
1967      * placed in the {@code ActionMapUIResource}, using the array
1968      * element as the key.  For example, if the {@code
1969      * "AuditoryCues.cueList"} array contains a single-element, {@code
1970      * "audioKey"}, the {@code ActionMapUIResource} is created, then
1971      * populated by way of {@code actionMap.put(cueList[0],
1972      * createAudioAction(cueList[0]))}.
1973      * <p>
1974      * If the value of the default {@code "AuditoryCues.actionMap"} is
1975      * {@code null} and the value of the default
1976      * {@code "AuditoryCues.cueList"} is {@code null}, an empty
1977      * {@code ActionMapUIResource} is created.
1978      *
1979      *
1980      * @return      an ActionMap containing {@code Actions}
1981      *              responsible for playing auditory cues
1982      * @throws ClassCastException if the value of the
1983      *         default {@code "AuditoryCues.actionMap"} is not an
1984      *         {@code ActionMap}, or the value of the default
1985      *         {@code "AuditoryCues.cueList"} is not an {@code Object[]}
1986      * @see #createAudioAction
1987      * @see #playSound(Action)
1988      * @since 1.4
1989      */
1990     protected ActionMap getAudioActionMap() {
1991         ActionMap audioActionMap = (ActionMap)UIManager.get(
1992                                               "AuditoryCues.actionMap");
1993         if (audioActionMap == null) {
1994             Object[] acList = (Object[])UIManager.get("AuditoryCues.cueList");
1995             if (acList != null) {
1996                 audioActionMap = new ActionMapUIResource();
1997                 for(int counter = acList.length-1; counter >= 0; counter--) {
1998                     audioActionMap.put(acList[counter],
1999                                        createAudioAction(acList[counter]));
2000                 }
2001             }
2002             UIManager.getLookAndFeelDefaults().put("AuditoryCues.actionMap",
2003                                                    audioActionMap);
2004         }
2005         return audioActionMap;
2006     }
2007 
2008     /**
2009      * Creates and returns an {@code Action} used to play a sound.
2010      * <p>
2011      * If {@code key} is {@code non-null}, an {@code Action} is created
2012      * using the value from the defaults with key {@code key}. The value
2013      * identifies the sound resource to load when
2014      * {@code actionPerformed} is invoked on the {@code Action}. The
2015      * sound resource is loaded into a {@code byte[]} by way of
2016      * {@code getClass().getResourceAsStream()}.
2017      *
2018      * @param key the key identifying the audio action
2019      * @return      an {@code Action} used to play the source, or {@code null}
2020      *              if {@code key} is {@code null}
2021      * @see #playSound(Action)
2022      * @since 1.4
2023      */
2024     protected Action createAudioAction(Object key) {
2025         if (key != null) {
2026             String audioKey = (String)key;
2027             String audioValue = (String)UIManager.get(key);
2028             return new AudioAction(audioKey, audioValue);
2029         } else {
2030             return null;
2031         }
2032     }
2033 
2034     /**
2035      * Pass the name String to the super constructor. This is used
2036      * later to identify the Action and decide whether to play it or
2037      * not. Store the resource String. I is used to get the audio
2038      * resource. In this case, the resource is an audio file.
2039      *
2040      * @since 1.4
2041      */
2042     private class AudioAction extends AbstractAction implements LineListener {
2043         // We strive to only play one sound at a time (other platforms
2044         // appear to do this). This is done by maintaining the field
2045         // clipPlaying. Every time a sound is to be played,
2046         // cancelCurrentSound is invoked to cancel any sound that may be
2047         // playing.
2048         private String audioResource;
2049         private byte[] audioBuffer;
2050 
2051         /**
2052          * The String is the name of the Action and
2053          * points to the audio resource.
2054          * The byte[] is a buffer of the audio bits.
2055          */
2056         public AudioAction(String name, String resource) {
2057             super(name);
2058             audioResource = resource;
2059         }
2060 
2061         public void actionPerformed(ActionEvent e) {
2062             if (audioBuffer == null) {
2063                 audioBuffer = loadAudioData(audioResource);
2064             }
2065             if (audioBuffer != null) {
2066                 cancelCurrentSound(null);
2067                 try {
2068                     AudioInputStream soundStream =
2069                         AudioSystem.getAudioInputStream(
2070                             new ByteArrayInputStream(audioBuffer));
2071                     DataLine.Info info =
2072                         new DataLine.Info(Clip.class, soundStream.getFormat());
2073                     Clip clip = (Clip) AudioSystem.getLine(info);
2074                     clip.open(soundStream);
2075                     clip.addLineListener(this);
2076 
2077                     synchronized(audioLock) {
2078                         clipPlaying = clip;
2079                     }
2080 
2081                     clip.start();
2082                 } catch (Exception ex) {}
2083             }
2084         }
2085 
2086         public void update(LineEvent event) {
2087             if (event.getType() == LineEvent.Type.STOP) {
2088                 cancelCurrentSound((Clip)event.getLine());
2089             }
2090         }
2091 
2092         /**
2093          * If the parameter is null, or equal to the currently
2094          * playing sound, then cancel the currently playing sound.
2095          */
2096         private void cancelCurrentSound(Clip clip) {
2097             Clip lastClip = null;
2098 
2099             synchronized(audioLock) {
2100                 if (clip == null || clip == clipPlaying) {
2101                     lastClip = clipPlaying;
2102                     clipPlaying = null;
2103                 }
2104             }
2105 
2106             if (lastClip != null) {
2107                 lastClip.removeLineListener(this);
2108                 lastClip.close();
2109             }
2110         }
2111     }
2112 
2113     /**
2114      * Utility method that loads audio bits for the specified
2115      * <code>soundFile</code> filename. If this method is unable to
2116      * build a viable path name from the <code>baseClass</code> and
2117      * <code>soundFile</code> passed into this method, it will
2118      * return <code>null</code>.
2119      *
2120      * @param soundFile    the name of the audio file to be retrieved
2121      *                     from disk
2122      * @return             A byte[] with audio data or null
2123      * @since 1.4
2124      */
2125     private byte[] loadAudioData(final String soundFile){
2126         if (soundFile == null) {
2127             return null;
2128         }
2129         /* Copy resource into a byte array.  This is
2130          * necessary because several browsers consider
2131          * Class.getResource a security risk since it
2132          * can be used to load additional classes.
2133          * Class.getResourceAsStream just returns raw
2134          * bytes, which we can convert to a sound.
2135          */
2136         byte[] buffer = AccessController.doPrivileged(
2137                                                  new PrivilegedAction<byte[]>() {
2138                 public byte[] run() {
2139                     try {
2140                         InputStream resource = BasicLookAndFeel.this.
2141                             getClass().getResourceAsStream(soundFile);
2142                         if (resource == null) {
2143                             return null;
2144                         }
2145                         BufferedInputStream in =
2146                             new BufferedInputStream(resource);
2147                         ByteArrayOutputStream out =
2148                             new ByteArrayOutputStream(1024);
2149                         byte[] buffer = new byte[1024];
2150                         int n;
2151                         while ((n = in.read(buffer)) > 0) {
2152                             out.write(buffer, 0, n);
2153                         }
2154                         in.close();
2155                         out.flush();
2156                         buffer = out.toByteArray();
2157                         return buffer;
2158                     } catch (IOException ioe) {
2159                         System.err.println(ioe.toString());
2160                         return null;
2161                     }
2162                 }
2163             });
2164         if (buffer == null) {
2165             System.err.println(getClass().getName() + "/" +
2166                                soundFile + " not found.");
2167             return null;
2168         }
2169         if (buffer.length == 0) {
2170             System.err.println("warning: " + soundFile +
2171                                " is zero-length");
2172             return null;
2173         }
2174         return buffer;
2175     }
2176 
2177     /**
2178      * If necessary, invokes {@code actionPerformed} on
2179      * {@code audioAction} to play a sound.
2180      * The {@code actionPerformed} method is invoked if the value of
2181      * the {@code "AuditoryCues.playList"} default is a {@code
2182      * non-null} {@code Object[]} containing a {@code String} entry
2183      * equal to the name of the {@code audioAction}.
2184      *
2185      * @param audioAction an Action that knows how to render the audio
2186      *                    associated with the system or user activity
2187      *                    that is occurring; a value of {@code null}, is
2188      *                    ignored
2189      * @throws ClassCastException if {@code audioAction} is {@code non-null}
2190      *         and the value of the default {@code "AuditoryCues.playList"}
2191      *         is not an {@code Object[]}
2192      * @since 1.4
2193      */
2194     protected void playSound(Action audioAction) {
2195         if (audioAction != null) {
2196             Object[] audioStrings = (Object[])
2197                                     UIManager.get("AuditoryCues.playList");
2198             if (audioStrings != null) {
2199                 // create a HashSet to help us decide to play or not
2200                 HashSet<Object> audioCues = new HashSet<Object>();
2201                 for (Object audioString : audioStrings) {
2202                     audioCues.add(audioString);
2203                 }
2204                 // get the name of the Action
2205                 String actionName = (String)audioAction.getValue(Action.NAME);
2206                 // if the actionName is in the audioCues HashSet, play it.
2207                 if (audioCues.contains(actionName)) {
2208                     audioAction.actionPerformed(new
2209                         ActionEvent(this, ActionEvent.ACTION_PERFORMED,
2210                                     actionName));
2211                 }
2212             }
2213         }
2214     }
2215 
2216 
2217     /**
2218      * Sets the parent of the passed in ActionMap to be the audio action
2219      * map.
2220      */
2221     static void installAudioActionMap(ActionMap map) {
2222         LookAndFeel laf = UIManager.getLookAndFeel();
2223         if (laf instanceof BasicLookAndFeel) {
2224             map.setParent(((BasicLookAndFeel)laf).getAudioActionMap());
2225         }
2226     }
2227 
2228 
2229     /**
2230      * Helper method to play a named sound.
2231      *
2232      * @param c JComponent to play the sound for.
2233      * @param actionKey Key for the sound.
2234      */
2235     static void playSound(JComponent c, Object actionKey) {
2236         LookAndFeel laf = UIManager.getLookAndFeel();
2237         if (laf instanceof BasicLookAndFeel) {
2238             ActionMap map = c.getActionMap();
2239             if (map != null) {
2240                 Action audioAction = map.get(actionKey);
2241                 if (audioAction != null) {
2242                     // pass off firing the Action to a utility method
2243                     ((BasicLookAndFeel)laf).playSound(audioAction);
2244                 }
2245             }
2246         }
2247     }
2248 
2249     /**
2250      * This class contains listener that watches for all the mouse
2251      * events that can possibly invoke popup on the component
2252      */
2253     class AWTEventHelper implements AWTEventListener,PrivilegedAction<Object> {
2254         AWTEventHelper() {
2255             super();
2256             AccessController.doPrivileged(this);
2257         }
2258 
2259         public Object run() {
2260             Toolkit tk = Toolkit.getDefaultToolkit();
2261             if(invocator == null) {
2262                 tk.addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK);
2263             } else {
2264                 tk.removeAWTEventListener(invocator);
2265             }
2266             // Return value not used.
2267             return null;
2268         }
2269 
2270         public void eventDispatched(AWTEvent ev) {
2271             int eventID = ev.getID();
2272             if((eventID & AWTEvent.MOUSE_EVENT_MASK) != 0) {
2273                 MouseEvent me = (MouseEvent) ev;
2274                 if(me.isPopupTrigger()) {
2275                     MenuElement[] elems = MenuSelectionManager
2276                             .defaultManager()
2277                             .getSelectedPath();
2278                     if(elems != null && elems.length != 0) {
2279                         return;
2280                         // We shall not interfere with already opened menu
2281                     }
2282                     Object c = me.getSource();
2283                     JComponent src = null;
2284                     if(c instanceof JComponent) {
2285                         src = (JComponent) c;
2286                     } else if(c instanceof BasicSplitPaneDivider) {
2287                         // Special case - if user clicks on divider we must
2288                         // invoke popup from the SplitPane
2289                         src = (JComponent)
2290                             ((BasicSplitPaneDivider)c).getParent();
2291                     }
2292                     if(src != null) {
2293                         if(src.getComponentPopupMenu() != null) {
2294                             Point pt = src.getPopupLocation(me);
2295                             if(pt == null) {
2296                                 pt = me.getPoint();
2297                                 pt = SwingUtilities.convertPoint((Component)c,
2298                                                                   pt, src);
2299                             }
2300                             src.getComponentPopupMenu().show(src, pt.x, pt.y);
2301                             me.consume();
2302                         }
2303                     }
2304                 }
2305             }
2306             /* Activate a JInternalFrame if necessary. */
2307             if (eventID == MouseEvent.MOUSE_PRESSED) {
2308                 Object object = ev.getSource();
2309                 if (!(object instanceof Component)) {
2310                     return;
2311                 }
2312                 Component component = (Component)object;
2313                 if (component != null) {
2314                     Component parent = component;
2315                     while (parent != null && !(parent instanceof Window)) {
2316                         if (parent instanceof JInternalFrame) {
2317                             // Activate the frame.
2318                             try { ((JInternalFrame)parent).setSelected(true); }
2319                             catch (PropertyVetoException e1) { }
2320                         }
2321                         parent = parent.getParent();
2322                     }
2323                 }
2324             }
2325         }
2326     }
2327 }