0001 /*
0002 * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
0003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0004 *
0005 * This code is free software; you can redistribute it and/or modify it
0006 * under the terms of the GNU General Public License version 2 only, as
0007 * published by the Free Software Foundation. Sun designates this
0008 * particular file as subject to the "Classpath" exception as provided
0009 * by Sun in the LICENSE file that accompanied this code.
0010 *
0011 * This code is distributed in the hope that it will be useful, but WITHOUT
0012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0014 * version 2 for more details (a copy is included in the LICENSE file that
0015 * accompanied this code).
0016 *
0017 * You should have received a copy of the GNU General Public License version
0018 * 2 along with this work; if not, write to the Free Software Foundation,
0019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0020 *
0021 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
0022 * CA 95054 USA or visit www.sun.com if you need additional information or
0023 * have any questions.
0024 */
0025
0026 package javax.swing.plaf.basic;
0027
0028 import java.awt.Font;
0029 import java.awt.Color;
0030 import java.awt.SystemColor;
0031 import java.awt.event.*;
0032 import java.awt.Insets;
0033 import java.awt.Component;
0034 import java.awt.Container;
0035 import java.awt.FocusTraversalPolicy;
0036 import java.awt.AWTEvent;
0037 import java.awt.Toolkit;
0038 import java.awt.Point;
0039 import java.net.URL;
0040 import java.io.*;
0041 import java.awt.Dimension;
0042 import java.awt.KeyboardFocusManager;
0043 import java.security.AccessController;
0044 import java.security.PrivilegedAction;
0045 import java.util.*;
0046 import java.lang.reflect.*;
0047 import javax.sound.sampled.*;
0048
0049 import sun.awt.AppContext;
0050
0051 import sun.swing.SwingLazyValue;
0052 import sun.swing.SwingUtilities2;
0053
0054 import javax.swing.LookAndFeel;
0055 import javax.swing.AbstractAction;
0056 import javax.swing.Action;
0057 import javax.swing.ActionMap;
0058 import javax.swing.BorderFactory;
0059 import javax.swing.JComponent;
0060 import javax.swing.ImageIcon;
0061 import javax.swing.UIDefaults;
0062 import javax.swing.UIManager;
0063 import javax.swing.KeyStroke;
0064 import javax.swing.JTextField;
0065 import javax.swing.DefaultListCellRenderer;
0066 import javax.swing.FocusManager;
0067 import javax.swing.LayoutFocusTraversalPolicy;
0068 import javax.swing.SwingUtilities;
0069 import javax.swing.MenuSelectionManager;
0070 import javax.swing.MenuElement;
0071 import javax.swing.border.*;
0072 import javax.swing.plaf.*;
0073 import javax.swing.text.JTextComponent;
0074 import javax.swing.text.DefaultEditorKit;
0075 import javax.swing.JInternalFrame;
0076 import java.beans.PropertyVetoException;
0077 import java.awt.Window;
0078 import java.beans.PropertyChangeListener;
0079 import java.beans.PropertyChangeEvent;
0080
0081 /**
0082 * A base class to use in creating a look and feel for Swing.
0083 * <p>
0084 * Each of the {@code ComponentUI}s provided by {@code
0085 * BasicLookAndFeel} derives its behavior from the defaults
0086 * table. Unless otherwise noted each of the {@code ComponentUI}
0087 * implementations in this package document the set of defaults they
0088 * use. Unless otherwise noted the defaults are installed at the time
0089 * {@code installUI} is invoked, and follow the recommendations
0090 * outlined in {@code LookAndFeel} for installing defaults.
0091 * <p>
0092 * <strong>Warning:</strong>
0093 * Serialized objects of this class will not be compatible with
0094 * future Swing releases. The current serialization support is
0095 * appropriate for short term storage or RMI between applications running
0096 * the same version of Swing. As of 1.4, support for long term storage
0097 * of all JavaBeans<sup><font size="-2">TM</font></sup>
0098 * has been added to the <code>java.beans</code> package.
0099 * Please see {@link java.beans.XMLEncoder}.
0100 *
0101 * @version 1.283 05/09/07
0102 * @author unattributed
0103 */
0104 public abstract class BasicLookAndFeel extends LookAndFeel implements
0105 Serializable {
0106 /**
0107 * Whether or not the developer has created a JPopupMenu.
0108 */
0109 static boolean needsEventHelper;
0110
0111 /**
0112 * Lock used when manipulating clipPlaying.
0113 */
0114 private Object audioLock = new Object();
0115 /**
0116 * The Clip that is currently playing (set in AudioAction).
0117 */
0118 private Clip clipPlaying;
0119
0120 AWTEventHelper invocator = null;
0121
0122 /*
0123 * Listen for our AppContext being disposed
0124 */
0125 private PropertyChangeListener disposer = null;
0126
0127 /**
0128 * Returns the look and feel defaults. The returned {@code UIDefaults}
0129 * is populated by invoking, in order, {@code initClassDefaults},
0130 * {@code initSystemColorDefaults} and {@code initComponentDefaults}.
0131 * <p>
0132 * While this method is public, it should only be invoked by the
0133 * {@code UIManager} when the look and feel is set as the current
0134 * look and feel and after {@code initialize} has been invoked.
0135 *
0136 * @return the look and feel defaults
0137 *
0138 * @see #initClassDefaults
0139 * @see #initSystemColorDefaults
0140 * @see #initComponentDefaults
0141 */
0142 public UIDefaults getDefaults() {
0143 UIDefaults table = new UIDefaults(610, 0.75f);
0144
0145 initClassDefaults(table);
0146 initSystemColorDefaults(table);
0147 initComponentDefaults(table);
0148
0149 return table;
0150 }
0151
0152 /**
0153 * {@inheritDoc}
0154 */
0155 public void initialize() {
0156 if (needsEventHelper) {
0157 installAWTEventListener();
0158 }
0159 }
0160
0161 void installAWTEventListener() {
0162 if (invocator == null) {
0163 invocator = new AWTEventHelper();
0164 needsEventHelper = true;
0165
0166 // Add a PropertyChangeListener to our AppContext so we're alerted
0167 // when the AppContext is disposed(), at which time this laf should
0168 // be uninitialize()d.
0169 disposer = new PropertyChangeListener() {
0170 public void propertyChange(PropertyChangeEvent prpChg) {
0171 uninitialize();
0172 }
0173 };
0174 AppContext.getAppContext().addPropertyChangeListener(
0175 AppContext.GUI_DISPOSED, disposer);
0176 }
0177 }
0178
0179 /**
0180 * {@inheritDoc}
0181 */
0182 public void uninitialize() {
0183 AppContext context = AppContext.getAppContext();
0184 synchronized (BasicPopupMenuUI.MOUSE_GRABBER_KEY) {
0185 Object grabber = context
0186 .get(BasicPopupMenuUI.MOUSE_GRABBER_KEY);
0187 if (grabber != null) {
0188 ((BasicPopupMenuUI.MouseGrabber) grabber).uninstall();
0189 }
0190 }
0191 synchronized (BasicPopupMenuUI.MENU_KEYBOARD_HELPER_KEY) {
0192 Object helper = context
0193 .get(BasicPopupMenuUI.MENU_KEYBOARD_HELPER_KEY);
0194 if (helper != null) {
0195 ((BasicPopupMenuUI.MenuKeyboardHelper) helper)
0196 .uninstall();
0197 }
0198 }
0199
0200 if (invocator != null) {
0201 AccessController.doPrivileged(invocator);
0202 invocator = null;
0203 }
0204
0205 if (disposer != null) {
0206 // Note that we're likely calling removePropertyChangeListener()
0207 // during the course of AppContext.firePropertyChange().
0208 // However, EventListenerAggreggate has code to safely modify
0209 // the list under such circumstances.
0210 context.removePropertyChangeListener(
0211 AppContext.GUI_DISPOSED, disposer);
0212 disposer = null;
0213 }
0214 }
0215
0216 /**
0217 * Populates {@code table} with mappings from {@code uiClassID} to the
0218 * fully qualified name of the ui class. The value for a
0219 * particular {@code uiClassID} is {@code
0220 * "javax.swing.plaf.basic.Basic + uiClassID"}. For example, the
0221 * value for the {@code uiClassID} {@code TreeUI} is {@code
0222 * "javax.swing.plaf.basic.BasicTreeUI"}.
0223 *
0224 * @param table the {@code UIDefaults} instance the entries are
0225 * added to
0226 * @throws NullPointerException if {@code table} is {@code null}
0227 *
0228 * @see javax.swing.LookAndFeel
0229 * @see #getDefaults
0230 */
0231 protected void initClassDefaults(UIDefaults table) {
0232 final String basicPackageName = "javax.swing.plaf.basic.";
0233 Object[] uiDefaults = { "ButtonUI",
0234 basicPackageName + "BasicButtonUI", "CheckBoxUI",
0235 basicPackageName + "BasicCheckBoxUI", "ColorChooserUI",
0236 basicPackageName + "BasicColorChooserUI",
0237 "FormattedTextFieldUI",
0238 basicPackageName + "BasicFormattedTextFieldUI",
0239 "MenuBarUI", basicPackageName + "BasicMenuBarUI",
0240 "MenuUI", basicPackageName + "BasicMenuUI",
0241 "MenuItemUI", basicPackageName + "BasicMenuItemUI",
0242 "CheckBoxMenuItemUI",
0243 basicPackageName + "BasicCheckBoxMenuItemUI",
0244 "RadioButtonMenuItemUI",
0245 basicPackageName + "BasicRadioButtonMenuItemUI",
0246 "RadioButtonUI",
0247 basicPackageName + "BasicRadioButtonUI",
0248 "ToggleButtonUI",
0249 basicPackageName + "BasicToggleButtonUI",
0250 "PopupMenuUI", basicPackageName + "BasicPopupMenuUI",
0251 "ProgressBarUI",
0252 basicPackageName + "BasicProgressBarUI", "ScrollBarUI",
0253 basicPackageName + "BasicScrollBarUI", "ScrollPaneUI",
0254 basicPackageName + "BasicScrollPaneUI", "SplitPaneUI",
0255 basicPackageName + "BasicSplitPaneUI", "SliderUI",
0256 basicPackageName + "BasicSliderUI", "SeparatorUI",
0257 basicPackageName + "BasicSeparatorUI", "SpinnerUI",
0258 basicPackageName + "BasicSpinnerUI",
0259 "ToolBarSeparatorUI",
0260 basicPackageName + "BasicToolBarSeparatorUI",
0261 "PopupMenuSeparatorUI",
0262 basicPackageName + "BasicPopupMenuSeparatorUI",
0263 "TabbedPaneUI", basicPackageName + "BasicTabbedPaneUI",
0264 "TextAreaUI", basicPackageName + "BasicTextAreaUI",
0265 "TextFieldUI", basicPackageName + "BasicTextFieldUI",
0266 "PasswordFieldUI",
0267 basicPackageName + "BasicPasswordFieldUI",
0268 "TextPaneUI", basicPackageName + "BasicTextPaneUI",
0269 "EditorPaneUI", basicPackageName + "BasicEditorPaneUI",
0270 "TreeUI", basicPackageName + "BasicTreeUI", "LabelUI",
0271 basicPackageName + "BasicLabelUI", "ListUI",
0272 basicPackageName + "BasicListUI", "ToolBarUI",
0273 basicPackageName + "BasicToolBarUI", "ToolTipUI",
0274 basicPackageName + "BasicToolTipUI", "ComboBoxUI",
0275 basicPackageName + "BasicComboBoxUI", "TableUI",
0276 basicPackageName + "BasicTableUI", "TableHeaderUI",
0277 basicPackageName + "BasicTableHeaderUI",
0278 "InternalFrameUI",
0279 basicPackageName + "BasicInternalFrameUI",
0280 "DesktopPaneUI",
0281 basicPackageName + "BasicDesktopPaneUI",
0282 "DesktopIconUI",
0283 basicPackageName + "BasicDesktopIconUI",
0284 "OptionPaneUI", basicPackageName + "BasicOptionPaneUI",
0285 "PanelUI", basicPackageName + "BasicPanelUI",
0286 "ViewportUI", basicPackageName + "BasicViewportUI",
0287 "RootPaneUI", basicPackageName + "BasicRootPaneUI", };
0288
0289 table.putDefaults(uiDefaults);
0290 }
0291
0292 /**
0293 * Populates {@code table} with system colors. This creates an
0294 * array of {@code name-color} pairs and invokes {@code
0295 * loadSystemColors}.
0296 * <p>
0297 * The name is a {@code String} that corresponds to the name of
0298 * one of the static {@code SystemColor} fields in the {@code
0299 * SystemColor} class. A name-color pair is created for every
0300 * such {@code SystemColor} field.
0301 * <p>
0302 * The {@code color} corresponds to a hex {@code String} as
0303 * understood by {@code Color.decode}. For example, one of the
0304 * {@code name-color} pairs is {@code
0305 * "desktop"-"#005C5C"}. This corresponds to the {@code
0306 * SystemColor} field {@code desktop}, with a color value of
0307 * {@code new Color(0x005C5C)}.
0308 * <p>
0309 * The following shows two of the {@code name-color} pairs:
0310 * <pre>
0311 * String[] nameColorPairs = new String[] {
0312 * "desktop", "#005C5C",
0313 * "activeCaption", "#000080" };
0314 * loadSystemColors(table, nameColorPairs, isNativeLookAndFeel());
0315 * </pre>
0316 *
0317 * As previously stated, this invokes {@code loadSystemColors}
0318 * with the supplied {@code table} and {@code name-color} pair
0319 * array. The last argument to {@code loadSystemColors} indicates
0320 * whether the value of the field in {@code SystemColor} should be
0321 * used. This method passes the value of {@code
0322 * isNativeLookAndFeel()} as the last argument to {@code loadSystemColors}.
0323 *
0324 * @param table the {@code UIDefaults} object the values are added to
0325 * @throws NullPointerException if {@code table} is {@code null}
0326 *
0327 * @see java.awt.SystemColor
0328 * @see #getDefaults
0329 * @see #loadSystemColors
0330 */
0331 protected void initSystemColorDefaults(UIDefaults table) {
0332 String[] defaultSystemColors = { "desktop", "#005C5C", /* Color of the desktop background */
0333 "activeCaption", "#000080", /* Color for captions (title bars) when they are active. */
0334 "activeCaptionText", "#FFFFFF", /* Text color for text in captions (title bars). */
0335 "activeCaptionBorder", "#C0C0C0", /* Border color for caption (title bar) window borders. */
0336 "inactiveCaption", "#808080", /* Color for captions (title bars) when not active. */
0337 "inactiveCaptionText", "#C0C0C0", /* Text color for text in inactive captions (title bars). */
0338 "inactiveCaptionBorder", "#C0C0C0", /* Border color for inactive caption (title bar) window borders. */
0339 "window", "#FFFFFF", /* Default color for the interior of windows */
0340 "windowBorder", "#000000", /* ??? */
0341 "windowText", "#000000", /* ??? */
0342 "menu", "#C0C0C0", /* Background color for menus */
0343 "menuText", "#000000", /* Text color for menus */
0344 "text", "#C0C0C0", /* Text background color */
0345 "textText", "#000000", /* Text foreground color */
0346 "textHighlight", "#000080", /* Text background color when selected */
0347 "textHighlightText", "#FFFFFF", /* Text color when selected */
0348 "textInactiveText", "#808080", /* Text color when disabled */
0349 "control", "#C0C0C0", /* Default color for controls (buttons, sliders, etc) */
0350 "controlText", "#000000", /* Default color for text in controls */
0351 "controlHighlight", "#C0C0C0", /* Specular highlight (opposite of the shadow) */
0352 "controlLtHighlight", "#FFFFFF", /* Highlight color for controls */
0353 "controlShadow", "#808080", /* Shadow color for controls */
0354 "controlDkShadow", "#000000", /* Dark shadow color for controls */
0355 "scrollbar", "#E0E0E0", /* Scrollbar background (usually the "track") */
0356 "info", "#FFFFE1", /* ??? */
0357 "infoText", "#000000" /* ??? */
0358 };
0359
0360 loadSystemColors(table, defaultSystemColors,
0361 isNativeLookAndFeel());
0362 }
0363
0364 /**
0365 * Populates {@code table} with the {@code name-color} pairs in
0366 * {@code systemColors}. Refer to
0367 * {@link #initSystemColorDefaults(UIDefaults)} for details on
0368 * the format of {@code systemColors}.
0369 * <p>
0370 * An entry is added to {@code table} for each of the {@code name-color}
0371 * pairs in {@code systemColors}. The entry key is
0372 * the {@code name} of the {@code name-color} pair.
0373 * <p>
0374 * The value of the entry corresponds to the {@code color} of the
0375 * {@code name-color} pair. The value of the entry is calculated
0376 * in one of two ways. With either approach the value is always a
0377 * {@code ColorUIResource}.
0378 * <p>
0379 * If {@code useNative} is {@code false}, the {@code color} is
0380 * created by using {@code Color.decode} to convert the {@code
0381 * String} into a {@code Color}. If {@code decode} can not convert
0382 * the {@code String} into a {@code Color} ({@code
0383 * NumberFormatException} is thrown) then a {@code
0384 * ColorUIResource} of black is used.
0385 * <p>
0386 * If {@code useNative} is {@code true}, the {@code color} is the
0387 * value of the field in {@code SystemColor} with the same name as
0388 * the {@code name} of the {@code name-color} pair. If the field
0389 * is not valid, a {@code ColorUIResource} of black is used.
0390 *
0391 * @param table the {@code UIDefaults} object the values are added to
0392 * @param systemColors array of {@code name-color} pairs as described
0393 * in {@link #initSystemColorDefaults(UIDefaults)}
0394 * @param useNative whether the color is obtained from {@code SystemColor}
0395 * or {@code Color.decode}
0396 * @throws NullPointerException if {@code systemColors} is {@code null}; or
0397 * {@code systemColors} is not empty, and {@code table} is
0398 * {@code null}; or one of the
0399 * names of the {@code name-color} pairs is {@code null}; or
0400 * {@code useNative} is {@code false} and one of the
0401 * {@code colors} of the {@code name-color} pairs is {@code null}
0402 * @throws ArrayIndexOutOfBoundsException if {@code useNative} is
0403 * {@code false} and {@code systemColors.length} is odd
0404 *
0405 * @see #initSystemColorDefaults(javax.swing.UIDefaults)
0406 * @see java.awt.SystemColor
0407 * @see java.awt.Color#decode(String)
0408 */
0409 protected void loadSystemColors(UIDefaults table,
0410 String[] systemColors, boolean useNative) {
0411 /* PENDING(hmuller) We don't load the system colors below because
0412 * they're not reliable. Hopefully we'll be able to do better in
0413 * a future version of AWT.
0414 */
0415 if (useNative) {
0416 for (int i = 0; i < systemColors.length; i += 2) {
0417 Color color = Color.black;
0418 try {
0419 String name = systemColors[i];
0420 color = (Color) (SystemColor.class.getField(name)
0421 .get(null));
0422 } catch (Exception e) {
0423 }
0424 table.put(systemColors[i], new ColorUIResource(color));
0425 }
0426 } else {
0427 for (int i = 0; i < systemColors.length; i += 2) {
0428 Color color = Color.black;
0429 try {
0430 color = Color.decode(systemColors[i + 1]);
0431 } catch (NumberFormatException e) {
0432 e.printStackTrace();
0433 }
0434 table.put(systemColors[i], new ColorUIResource(color));
0435 }
0436 }
0437 }
0438
0439 /**
0440 * Initialize the defaults table with the name of the ResourceBundle
0441 * used for getting localized defaults. Also initialize the default
0442 * locale used when no locale is passed into UIDefaults.get(). The
0443 * default locale should generally not be relied upon. It is here for
0444 * compatability with releases prior to 1.4.
0445 */
0446 private void initResourceBundle(UIDefaults table) {
0447 table.setDefaultLocale(Locale.getDefault());
0448 table
0449 .addResourceBundle("com.sun.swing.internal.plaf.basic.resources.basic");
0450 }
0451
0452 /**
0453 * Populates {@code table} with the defaults for the basic look and
0454 * feel.
0455 *
0456 * @param table the {@code UIDefaults} to add the values to
0457 * @throws NullPointerException if {@code table} is {@code null}
0458 */
0459 protected void initComponentDefaults(UIDefaults table) {
0460
0461 initResourceBundle(table);
0462
0463 // *** Shared Integers
0464 Integer fiveHundred = new Integer(500);
0465
0466 // *** Shared Longs
0467 Long oneThousand = new Long(1000);
0468
0469 // *** Shared Fonts
0470 Integer twelve = new Integer(12);
0471 Integer fontPlain = new Integer(Font.PLAIN);
0472 Integer fontBold = new Integer(Font.BOLD);
0473 Object dialogPlain12 = new SwingLazyValue(
0474 "javax.swing.plaf.FontUIResource", null, new Object[] {
0475 Font.DIALOG, fontPlain, twelve });
0476 Object serifPlain12 = new SwingLazyValue(
0477 "javax.swing.plaf.FontUIResource", null, new Object[] {
0478 Font.SERIF, fontPlain, twelve });
0479 Object sansSerifPlain12 = new SwingLazyValue(
0480 "javax.swing.plaf.FontUIResource", null, new Object[] {
0481 Font.SANS_SERIF, fontPlain, twelve });
0482 Object monospacedPlain12 = new SwingLazyValue(
0483 "javax.swing.plaf.FontUIResource", null, new Object[] {
0484 Font.MONOSPACED, fontPlain, twelve });
0485 Object dialogBold12 = new SwingLazyValue(
0486 "javax.swing.plaf.FontUIResource", null, new Object[] {
0487 Font.DIALOG, fontBold, twelve });
0488
0489 // *** Shared Colors
0490 ColorUIResource red = new ColorUIResource(Color.red);
0491 ColorUIResource black = new ColorUIResource(Color.black);
0492 ColorUIResource white = new ColorUIResource(Color.white);
0493 ColorUIResource yellow = new ColorUIResource(Color.yellow);
0494 ColorUIResource gray = new ColorUIResource(Color.gray);
0495 ColorUIResource lightGray = new ColorUIResource(Color.lightGray);
0496 ColorUIResource darkGray = new ColorUIResource(Color.darkGray);
0497 ColorUIResource scrollBarTrack = new ColorUIResource(224, 224,
0498 224);
0499
0500 Color control = table.getColor("control");
0501 Color controlDkShadow = table.getColor("controlDkShadow");
0502 Color controlHighlight = table.getColor("controlHighlight");
0503 Color controlLtHighlight = table.getColor("controlLtHighlight");
0504 Color controlShadow = table.getColor("controlShadow");
0505 Color controlText = table.getColor("controlText");
0506 Color menu = table.getColor("menu");
0507 Color menuText = table.getColor("menuText");
0508 Color textHighlight = table.getColor("textHighlight");
0509 Color textHighlightText = table.getColor("textHighlightText");
0510 Color textInactiveText = table.getColor("textInactiveText");
0511 Color textText = table.getColor("textText");
0512 Color window = table.getColor("window");
0513
0514 // *** Shared Insets
0515 InsetsUIResource zeroInsets = new InsetsUIResource(0, 0, 0, 0);
0516 InsetsUIResource twoInsets = new InsetsUIResource(2, 2, 2, 2);
0517 InsetsUIResource threeInsets = new InsetsUIResource(3, 3, 3, 3);
0518
0519 // *** Shared Borders
0520 Object marginBorder = new SwingLazyValue(
0521 "javax.swing.plaf.basic.BasicBorders$MarginBorder");
0522 Object etchedBorder = new SwingLazyValue(
0523 "javax.swing.plaf.BorderUIResource",
0524 "getEtchedBorderUIResource");
0525 Object loweredBevelBorder = new SwingLazyValue(
0526 "javax.swing.plaf.BorderUIResource",
0527 "getLoweredBevelBorderUIResource");
0528
0529 Object popupMenuBorder = new SwingLazyValue(
0530 "javax.swing.plaf.basic.BasicBorders",
0531 "getInternalFrameBorder");
0532
0533 Object blackLineBorder = new SwingLazyValue(
0534 "javax.swing.plaf.BorderUIResource",
0535 "getBlackLineBorderUIResource");
0536 Object focusCellHighlightBorder = new SwingLazyValue(
0537 "javax.swing.plaf.BorderUIResource$LineBorderUIResource",
0538 null, new Object[] { yellow });
0539
0540 Object noFocusBorder = new BorderUIResource.EmptyBorderUIResource(
0541 1, 1, 1, 1);
0542
0543 Object tableHeaderBorder = new SwingLazyValue(
0544 "javax.swing.plaf.BorderUIResource$BevelBorderUIResource",
0545 null, new Object[] { new Integer(BevelBorder.RAISED),
0546 controlLtHighlight, control, controlDkShadow,
0547 controlShadow });
0548
0549 // *** Button value objects
0550
0551 Object buttonBorder = new SwingLazyValue(
0552 "javax.swing.plaf.basic.BasicBorders",
0553 "getButtonBorder");
0554
0555 Object buttonToggleBorder = new SwingLazyValue(
0556 "javax.swing.plaf.basic.BasicBorders",
0557 "getToggleButtonBorder");
0558
0559 Object radioButtonBorder = new SwingLazyValue(
0560 "javax.swing.plaf.basic.BasicBorders",
0561 "getRadioButtonBorder");
0562
0563 // *** FileChooser / FileView value objects
0564
0565 Object newFolderIcon = SwingUtilities2.makeIcon(getClass(),
0566 BasicLookAndFeel.class, "icons/NewFolder.gif");
0567 Object upFolderIcon = SwingUtilities2.makeIcon(getClass(),
0568 BasicLookAndFeel.class, "icons/UpFolder.gif");
0569 Object homeFolderIcon = SwingUtilities2.makeIcon(getClass(),
0570 BasicLookAndFeel.class, "icons/HomeFolder.gif");
0571 Object detailsViewIcon = SwingUtilities2.makeIcon(getClass(),
0572 BasicLookAndFeel.class, "icons/DetailsView.gif");
0573 Object listViewIcon = SwingUtilities2.makeIcon(getClass(),
0574 BasicLookAndFeel.class, "icons/ListView.gif");
0575 Object directoryIcon = SwingUtilities2.makeIcon(getClass(),
0576 BasicLookAndFeel.class, "icons/Directory.gif");
0577 Object fileIcon = SwingUtilities2.makeIcon(getClass(),
0578 BasicLookAndFeel.class, "icons/File.gif");
0579 Object computerIcon = SwingUtilities2.makeIcon(getClass(),
0580 BasicLookAndFeel.class, "icons/Computer.gif");
0581 Object hardDriveIcon = SwingUtilities2.makeIcon(getClass(),
0582 BasicLookAndFeel.class, "icons/HardDrive.gif");
0583 Object floppyDriveIcon = SwingUtilities2.makeIcon(getClass(),
0584 BasicLookAndFeel.class, "icons/FloppyDrive.gif");
0585
0586 // *** InternalFrame value objects
0587
0588 Object internalFrameBorder = new SwingLazyValue(
0589 "javax.swing.plaf.basic.BasicBorders",
0590 "getInternalFrameBorder");
0591
0592 // *** List value objects
0593
0594 Object listCellRendererActiveValue = new UIDefaults.ActiveValue() {
0595 public Object createValue(UIDefaults table) {
0596 return new DefaultListCellRenderer.UIResource();
0597 }
0598 };
0599
0600 // *** Menus value objects
0601
0602 Object menuBarBorder = new SwingLazyValue(
0603 "javax.swing.plaf.basic.BasicBorders",
0604 "getMenuBarBorder");
0605
0606 Object menuItemCheckIcon = new SwingLazyValue(
0607 "javax.swing.plaf.basic.BasicIconFactory",
0608 "getMenuItemCheckIcon");
0609
0610 Object menuItemArrowIcon = new SwingLazyValue(
0611 "javax.swing.plaf.basic.BasicIconFactory",
0612 "getMenuItemArrowIcon");
0613
0614 Object menuArrowIcon = new SwingLazyValue(
0615 "javax.swing.plaf.basic.BasicIconFactory",
0616 "getMenuArrowIcon");
0617
0618 Object checkBoxIcon = new SwingLazyValue(
0619 "javax.swing.plaf.basic.BasicIconFactory",
0620 "getCheckBoxIcon");
0621
0622 Object radioButtonIcon = new SwingLazyValue(
0623 "javax.swing.plaf.basic.BasicIconFactory",
0624 "getRadioButtonIcon");
0625
0626 Object checkBoxMenuItemIcon = new SwingLazyValue(
0627 "javax.swing.plaf.basic.BasicIconFactory",
0628 "getCheckBoxMenuItemIcon");
0629
0630 Object radioButtonMenuItemIcon = new SwingLazyValue(
0631 "javax.swing.plaf.basic.BasicIconFactory",
0632 "getRadioButtonMenuItemIcon");
0633
0634 Object menuItemAcceleratorDelimiter = new String("+");
0635
0636 // *** OptionPane value objects
0637
0638 Object optionPaneMinimumSize = new DimensionUIResource(262, 90);
0639
0640 Integer zero = new Integer(0);
0641 Object zeroBorder = new SwingLazyValue(
0642 "javax.swing.plaf.BorderUIResource$EmptyBorderUIResource",
0643 new Object[] { zero, zero, zero, zero });
0644
0645 Integer ten = new Integer(10);
0646 Object optionPaneBorder = new SwingLazyValue(
0647 "javax.swing.plaf.BorderUIResource$EmptyBorderUIResource",
0648 new Object[] { ten, ten, twelve, ten });
0649
0650 Object optionPaneButtonAreaBorder = new SwingLazyValue(
0651 "javax.swing.plaf.BorderUIResource$EmptyBorderUIResource",
0652 new Object[] { new Integer(6), zero, zero, zero });
0653
0654 // *** ProgessBar value objects
0655
0656 Object progressBarBorder = new SwingLazyValue(
0657 "javax.swing.plaf.basic.BasicBorders",
0658 "getProgressBarBorder");
0659
0660 // ** ScrollBar value objects
0661
0662 Object minimumThumbSize = new DimensionUIResource(8, 8);
0663 Object maximumThumbSize = new DimensionUIResource(4096, 4096);
0664
0665 // ** Slider value objects
0666
0667 Object sliderFocusInsets = twoInsets;
0668
0669 Object toolBarSeparatorSize = new DimensionUIResource(10, 10);
0670
0671 // *** SplitPane value objects
0672
0673 Object splitPaneBorder = new SwingLazyValue(
0674 "javax.swing.plaf.basic.BasicBorders",
0675 "getSplitPaneBorder");
0676 Object splitPaneDividerBorder = new SwingLazyValue(
0677 "javax.swing.plaf.basic.BasicBorders",
0678 "getSplitPaneDividerBorder");
0679
0680 // ** TabbedBane value objects
0681
0682 Object tabbedPaneTabInsets = new InsetsUIResource(0, 4, 1, 4);
0683
0684 Object tabbedPaneTabPadInsets = new InsetsUIResource(2, 2, 2, 1);
0685
0686 Object tabbedPaneTabAreaInsets = new InsetsUIResource(3, 2, 0,
0687 2);
0688
0689 Object tabbedPaneContentBorderInsets = new InsetsUIResource(2,
0690 2, 3, 3);
0691
0692 // *** Text value objects
0693
0694 Object textFieldBorder = new SwingLazyValue(
0695 "javax.swing.plaf.basic.BasicBorders",
0696 "getTextFieldBorder");
0697
0698 Object editorMargin = threeInsets;
0699
0700 Object caretBlinkRate = fiveHundred;
0701 Integer four = new Integer(4);
0702
0703 Object[] allAuditoryCues = new Object[] {
0704 "CheckBoxMenuItem.commandSound",
0705 "InternalFrame.closeSound",
0706 "InternalFrame.maximizeSound",
0707 "InternalFrame.minimizeSound",
0708 "InternalFrame.restoreDownSound",
0709 "InternalFrame.restoreUpSound",
0710 "MenuItem.commandSound", "OptionPane.errorSound",
0711 "OptionPane.informationSound",
0712 "OptionPane.questionSound", "OptionPane.warningSound",
0713 "PopupMenu.popupSound",
0714 "RadioButtonMenuItem.commandSound" };
0715
0716 Object[] noAuditoryCues = new Object[] { "mute" };
0717
0718 // *** Component Defaults
0719
0720 Object[] defaults = {
0721 // *** Auditory Feedback
0722 "AuditoryCues.cueList",
0723 allAuditoryCues,
0724 "AuditoryCues.allAuditoryCues",
0725 allAuditoryCues,
0726 "AuditoryCues.noAuditoryCues",
0727 noAuditoryCues,
0728 // this key defines which of the various cues to render.
0729 // L&Fs that want auditory feedback NEED to override playList.
0730 "AuditoryCues.playList",
0731 null,
0732
0733 // *** Buttons
0734 "Button.defaultButtonFollowsFocus",
0735 Boolean.TRUE,
0736 "Button.font",
0737 dialogPlain12,
0738 "Button.background",
0739 control,
0740 "Button.foreground",
0741 controlText,
0742 "Button.shadow",
0743 controlShadow,
0744 "Button.darkShadow",
0745 controlDkShadow,
0746 "Button.light",
0747 controlHighlight,
0748 "Button.highlight",
0749 controlLtHighlight,
0750 "Button.border",
0751 buttonBorder,
0752 "Button.margin",
0753 new InsetsUIResource(2, 14, 2, 14),
0754 "Button.textIconGap",
0755 four,
0756 "Button.textShiftOffset",
0757 zero,
0758 "Button.focusInputMap",
0759 new UIDefaults.LazyInputMap(new Object[] { "SPACE",
0760 "pressed", "released SPACE", "released",
0761 "ENTER", "pressed", "released ENTER",
0762 "released" }),
0763
0764 "ToggleButton.font",
0765 dialogPlain12,
0766 "ToggleButton.background",
0767 control,
0768 "ToggleButton.foreground",
0769 controlText,
0770 "ToggleButton.shadow",
0771 controlShadow,
0772 "ToggleButton.darkShadow",
0773 controlDkShadow,
0774 "ToggleButton.light",
0775 controlHighlight,
0776 "ToggleButton.highlight",
0777 controlLtHighlight,
0778 "ToggleButton.border",
0779 buttonToggleBorder,
0780 "ToggleButton.margin",
0781 new InsetsUIResource(2, 14, 2, 14),
0782 "ToggleButton.textIconGap",
0783 four,
0784 "ToggleButton.textShiftOffset",
0785 zero,
0786 "ToggleButton.focusInputMap",
0787 new UIDefaults.LazyInputMap(new Object[] { "SPACE",
0788 "pressed", "released SPACE", "released" }),
0789
0790 "RadioButton.font",
0791 dialogPlain12,
0792 "RadioButton.background",
0793 control,
0794 "RadioButton.foreground",
0795 controlText,
0796 "RadioButton.shadow",
0797 controlShadow,
0798 "RadioButton.darkShadow",
0799 controlDkShadow,
0800 "RadioButton.light",
0801 controlHighlight,
0802 "RadioButton.highlight",
0803 controlLtHighlight,
0804 "RadioButton.border",
0805 radioButtonBorder,
0806 "RadioButton.margin",
0807 twoInsets,
0808 "RadioButton.textIconGap",
0809 four,
0810 "RadioButton.textShiftOffset",
0811 zero,
0812 "RadioButton.icon",
0813 radioButtonIcon,
0814 "RadioButton.focusInputMap",
0815 new UIDefaults.LazyInputMap(new Object[] { "SPACE",
0816 "pressed", "released SPACE", "released",
0817 "RETURN", "pressed" }),
0818
0819 "CheckBox.font",
0820 dialogPlain12,
0821 "CheckBox.background",
0822 control,
0823 "CheckBox.foreground",
0824 controlText,
0825 "CheckBox.border",
0826 radioButtonBorder,
0827 "CheckBox.margin",
0828 twoInsets,
0829 "CheckBox.textIconGap",
0830 four,
0831 "CheckBox.textShiftOffset",
0832 zero,
0833 "CheckBox.icon",
0834 checkBoxIcon,
0835 "CheckBox.focusInputMap",
0836 new UIDefaults.LazyInputMap(new Object[] { "SPACE",
0837 "pressed", "released SPACE", "released" }),
0838 "FileChooser.useSystemExtensionHiding",
0839 Boolean.FALSE,
0840
0841 // *** ColorChooser
0842 "ColorChooser.font",
0843 dialogPlain12,
0844 "ColorChooser.background",
0845 control,
0846 "ColorChooser.foreground",
0847 controlText,
0848
0849 "ColorChooser.swatchesSwatchSize",
0850 new Dimension(10, 10),
0851 "ColorChooser.swatchesRecentSwatchSize",
0852 new Dimension(10, 10),
0853 "ColorChooser.swatchesDefaultRecentColor",
0854 control,
0855
0856 // *** ComboBox
0857 "ComboBox.font",
0858 sansSerifPlain12,
0859 "ComboBox.background",
0860 window,
0861 "ComboBox.foreground",
0862 textText,
0863 "ComboBox.buttonBackground",
0864 control,
0865 "ComboBox.buttonShadow",
0866 controlShadow,
0867 "ComboBox.buttonDarkShadow",
0868 controlDkShadow,
0869 "ComboBox.buttonHighlight",
0870 controlLtHighlight,
0871 "ComboBox.selectionBackground",
0872 textHighlight,
0873 "ComboBox.selectionForeground",
0874 textHighlightText,
0875 "ComboBox.disabledBackground",
0876 control,
0877 "ComboBox.disabledForeground",
0878 textInactiveText,
0879 "ComboBox.timeFactor",
0880 oneThousand,
0881 "ComboBox.isEnterSelectablePopup",
0882 Boolean.FALSE,
0883 "ComboBox.ancestorInputMap",
0884 new UIDefaults.LazyInputMap(new Object[] { "ESCAPE",
0885 "hidePopup", "PAGE_UP", "pageUpPassThrough",
0886 "PAGE_DOWN", "pageDownPassThrough", "HOME",
0887 "homePassThrough", "END", "endPassThrough",
0888 "ENTER", "enterPressed" }),
0889
0890 // *** FileChooser
0891
0892 "FileChooser.newFolderIcon",
0893 newFolderIcon,
0894 "FileChooser.upFolderIcon",
0895 upFolderIcon,
0896 "FileChooser.homeFolderIcon",
0897 homeFolderIcon,
0898 "FileChooser.detailsViewIcon",
0899 detailsViewIcon,
0900 "FileChooser.listViewIcon",
0901 listViewIcon,
0902 "FileChooser.readOnly",
0903 Boolean.FALSE,
0904 "FileChooser.usesSingleFilePane",
0905 Boolean.FALSE,
0906 "FileChooser.ancestorInputMap",
0907 new UIDefaults.LazyInputMap(new Object[] { "ESCAPE",
0908 "cancelSelection", "F5", "refresh", }),
0909
0910 "FileView.directoryIcon",
0911 directoryIcon,
0912 "FileView.fileIcon",
0913 fileIcon,
0914 "FileView.computerIcon",
0915 computerIcon,
0916 "FileView.hardDriveIcon",
0917 hardDriveIcon,
0918 "FileView.floppyDriveIcon",
0919 floppyDriveIcon,
0920
0921 // *** InternalFrame
0922 "InternalFrame.titleFont",
0923 dialogBold12,
0924 "InternalFrame.borderColor",
0925 control,
0926 "InternalFrame.borderShadow",
0927 controlShadow,
0928 "InternalFrame.borderDarkShadow",
0929 controlDkShadow,
0930 "InternalFrame.borderHighlight",
0931 controlLtHighlight,
0932 "InternalFrame.borderLight",
0933 controlHighlight,
0934 "InternalFrame.border",
0935 internalFrameBorder,
0936 "InternalFrame.icon",
0937 SwingUtilities2.makeIcon(getClass(),
0938 BasicLookAndFeel.class, "icons/JavaCup16.png"),
0939
0940 /* Default frame icons are undefined for Basic. */
0941 "InternalFrame.maximizeIcon",
0942 new SwingLazyValue(
0943 "javax.swing.plaf.basic.BasicIconFactory",
0944 "createEmptyFrameIcon"),
0945 "InternalFrame.minimizeIcon",
0946 new SwingLazyValue(
0947 "javax.swing.plaf.basic.BasicIconFactory",
0948 "createEmptyFrameIcon"),
0949 "InternalFrame.iconifyIcon",
0950 new SwingLazyValue(
0951 "javax.swing.plaf.basic.BasicIconFactory",
0952 "createEmptyFrameIcon"),
0953 "InternalFrame.closeIcon",
0954 new SwingLazyValue(
0955 "javax.swing.plaf.basic.BasicIconFactory",
0956 "createEmptyFrameIcon"),
0957 // InternalFrame Auditory Cue Mappings
0958 "InternalFrame.closeSound",
0959 null,
0960 "InternalFrame.maximizeSound",
0961 null,
0962 "InternalFrame.minimizeSound",
0963 null,
0964 "InternalFrame.restoreDownSound",
0965 null,
0966 "InternalFrame.restoreUpSound",
0967 null,
0968
0969 "InternalFrame.activeTitleBackground",
0970 table.get("activeCaption"),
0971 "InternalFrame.activeTitleForeground",
0972 table.get("activeCaptionText"),
0973 "InternalFrame.inactiveTitleBackground",
0974 table.get("inactiveCaption"),
0975 "InternalFrame.inactiveTitleForeground",
0976 table.get("inactiveCaptionText"),
0977 "InternalFrame.windowBindings",
0978 new Object[] { "shift ESCAPE", "showSystemMenu",
0979 "ctrl SPACE", "showSystemMenu", "ESCAPE",
0980 "hideSystemMenu" },
0981
0982 "InternalFrameTitlePane.iconifyButtonOpacity",
0983 Boolean.TRUE,
0984 "InternalFrameTitlePane.maximizeButtonOpacity",
0985 Boolean.TRUE,
0986 "InternalFrameTitlePane.closeButtonOpacity",
0987 Boolean.TRUE,
0988
0989 "DesktopIcon.border",
0990 internalFrameBorder,
0991
0992 "Desktop.minOnScreenInsets",
0993 threeInsets,
0994 "Desktop.background",
0995 table.get("desktop"),
0996 "Desktop.ancestorInputMap",
0997 new UIDefaults.LazyInputMap(new Object[] { "ctrl F5",
0998 "restore", "ctrl F4", "close", "ctrl F7",
0999 "move", "ctrl F8", "resize", "RIGHT", "right",
1000 "KP_RIGHT", "right", "shift RIGHT",
1001 "shrinkRight", "shift KP_RIGHT", "shrinkRight",
1002 "LEFT", "left", "KP_LEFT", "left",
1003 "shift LEFT", "shrinkLeft", "shift KP_LEFT",
1004 "shrinkLeft", "UP", "up", "KP_UP", "up",
1005 "shift UP", "shrinkUp", "shift KP_UP",
1006 "shrinkUp", "DOWN", "down", "KP_DOWN", "down",
1007 "shift DOWN", "shrinkDown", "shift KP_DOWN",
1008 "shrinkDown", "ESCAPE", "escape", "ctrl F9",
1009 "minimize", "ctrl F10", "maximize", "ctrl F6",
1010 "selectNextFrame", "ctrl TAB",
1011 "selectNextFrame", "ctrl alt F6",
1012 "selectNextFrame", "shift ctrl alt F6",
1013 "selectPreviousFrame", "ctrl F12",
1014 "navigateNext", "shift ctrl F12",
1015 "navigatePrevious" }),
1016
1017 // *** Label
1018 "Label.font",
1019 dialogPlain12,
1020 "Label.background",
1021 control,
1022 "Label.foreground",
1023 controlText,
1024 "Label.disabledForeground",
1025 white,
1026 "Label.disabledShadow",
1027 controlShadow,
1028 "Label.border",
1029 null,
1030
1031 // *** List
1032 "List.font",
1033 dialogPlain12,
1034 "List.background",
1035 window,
1036 "List.foreground",
1037 textText,
1038 "List.selectionBackground",
1039 textHighlight,
1040 "List.selectionForeground",
1041 textHighlightText,
1042 "List.noFocusBorder",
1043 noFocusBorder,
1044 "List.focusCellHighlightBorder",
1045 focusCellHighlightBorder,
1046 "List.dropLineColor",
1047 controlShadow,
1048 "List.border",
1049 null,
1050 "List.cellRenderer",
1051 listCellRendererActiveValue,
1052 "List.timeFactor",
1053 oneThousand,
1054 "List.focusInputMap",
1055 new UIDefaults.LazyInputMap(new Object[] { "ctrl C",
1056 "copy", "ctrl V", "paste", "ctrl X", "cut",
1057 "COPY", "copy", "PASTE", "paste", "CUT", "cut",
1058 "control INSERT", "copy", "shift INSERT",
1059 "paste", "shift DELETE", "cut", "UP",
1060 "selectPreviousRow", "KP_UP",
1061 "selectPreviousRow", "shift UP",
1062 "selectPreviousRowExtendSelection",
1063 "shift KP_UP",
1064 "selectPreviousRowExtendSelection",
1065 "ctrl shift UP",
1066 "selectPreviousRowExtendSelection",
1067 "ctrl shift KP_UP",
1068 "selectPreviousRowExtendSelection", "ctrl UP",
1069 "selectPreviousRowChangeLead", "ctrl KP_UP",
1070 "selectPreviousRowChangeLead", "DOWN",
1071 "selectNextRow", "KP_DOWN", "selectNextRow",
1072 "shift DOWN", "selectNextRowExtendSelection",
1073 "shift KP_DOWN",
1074 "selectNextRowExtendSelection",
1075 "ctrl shift DOWN",
1076 "selectNextRowExtendSelection",
1077 "ctrl shift KP_DOWN",
1078 "selectNextRowExtendSelection", "ctrl DOWN",
1079 "selectNextRowChangeLead", "ctrl KP_DOWN",
1080 "selectNextRowChangeLead", "LEFT",
1081 "selectPreviousColumn", "KP_LEFT",
1082 "selectPreviousColumn", "shift LEFT",
1083 "selectPreviousColumnExtendSelection",
1084 "shift KP_LEFT",
1085 "selectPreviousColumnExtendSelection",
1086 "ctrl shift LEFT",
1087 "selectPreviousColumnExtendSelection",
1088 "ctrl shift KP_LEFT",
1089 "selectPreviousColumnExtendSelection",
1090 "ctrl LEFT", "selectPreviousColumnChangeLead",
1091 "ctrl KP_LEFT",
1092 "selectPreviousColumnChangeLead", "RIGHT",
1093 "selectNextColumn", "KP_RIGHT",
1094 "selectNextColumn", "shift RIGHT",
1095 "selectNextColumnExtendSelection",
1096 "shift KP_RIGHT",
1097 "selectNextColumnExtendSelection",
1098 "ctrl shift RIGHT",
1099 "selectNextColumnExtendSelection",
1100 "ctrl shift KP_RIGHT",
1101 "selectNextColumnExtendSelection",
1102 "ctrl RIGHT", "selectNextColumnChangeLead",
1103 "ctrl KP_RIGHT", "selectNextColumnChangeLead",
1104 "HOME", "selectFirstRow", "shift HOME",
1105 "selectFirstRowExtendSelection",
1106 "ctrl shift HOME",
1107 "selectFirstRowExtendSelection", "ctrl HOME",
1108 "selectFirstRowChangeLead", "END",
1109 "selectLastRow", "shift END",
1110 "selectLastRowExtendSelection",
1111 "ctrl shift END",
1112 "selectLastRowExtendSelection", "ctrl END",
1113 "selectLastRowChangeLead", "PAGE_UP",
1114 "scrollUp", "shift PAGE_UP",
1115 "scrollUpExtendSelection",
1116 "ctrl shift PAGE_UP",
1117 "scrollUpExtendSelection", "ctrl PAGE_UP",
1118 "scrollUpChangeLead", "PAGE_DOWN",
1119 "scrollDown", "shift PAGE_DOWN",
1120 "scrollDownExtendSelection",
1121 "ctrl shift PAGE_DOWN",
1122 "scrollDownExtendSelection", "ctrl PAGE_DOWN",
1123 "scrollDownChangeLead", "ctrl A", "selectAll",
1124 "ctrl SLASH", "selectAll", "ctrl BACK_SLASH",
1125 "clearSelection", "SPACE", "addToSelection",
1126 "ctrl SPACE", "toggleAndAnchor", "shift SPACE",
1127 "extendTo", "ctrl shift SPACE",
1128 "moveSelectionTo" }),
1129 "List.focusInputMap.RightToLeft",
1130 new UIDefaults.LazyInputMap(new Object[] { "LEFT",
1131 "selectNextColumn", "KP_LEFT",
1132 "selectNextColumn", "shift LEFT",
1133 "selectNextColumnExtendSelection",
1134 "shift KP_LEFT",
1135 "selectNextColumnExtendSelection",
1136 "ctrl shift LEFT",
1137 "selectNextColumnExtendSelection",
1138 "ctrl shift KP_LEFT",
1139 "selectNextColumnExtendSelection", "ctrl LEFT",
1140 "selectNextColumnChangeLead", "ctrl KP_LEFT",
1141 "selectNextColumnChangeLead", "RIGHT",
1142 "selectPreviousColumn", "KP_RIGHT",
1143 "selectPreviousColumn", "shift RIGHT",
1144 "selectPreviousColumnExtendSelection",
1145 "shift KP_RIGHT",
1146 "selectPreviousColumnExtendSelection",
1147 "ctrl shift RIGHT",
1148 "selectPreviousColumnExtendSelection",
1149 "ctrl shift KP_RIGHT",
1150 "selectPreviousColumnExtendSelection",
1151 "ctrl RIGHT", "selectPreviousColumnChangeLead",
1152 "ctrl KP_RIGHT",
1153 "selectPreviousColumnChangeLead", }),
1154
1155 // *** Menus
1156 "MenuBar.font",
1157 dialogPlain12,
1158 "MenuBar.background",
1159 menu,
1160 "MenuBar.foreground",
1161 menuText,
1162 "MenuBar.shadow",
1163 controlShadow,
1164 "MenuBar.highlight",
1165 controlLtHighlight,
1166 "MenuBar.border",
1167 menuBarBorder,
1168 "MenuBar.windowBindings",
1169 new Object[] { "F10", "takeFocus" },
1170
1171 "MenuItem.font",
1172 dialogPlain12,
1173 "MenuItem.acceleratorFont",
1174 dialogPlain12,
1175 "MenuItem.background",
1176 menu,
1177 "MenuItem.foreground",
1178 menuText,
1179 "MenuItem.selectionForeground",
1180 textHighlightText,
1181 "MenuItem.selectionBackground",
1182 textHighlight,
1183 "MenuItem.disabledForeground",
1184 null,
1185 "MenuItem.acceleratorForeground",
1186 menuText,
1187 "MenuItem.acceleratorSelectionForeground",
1188 textHighlightText,
1189 "MenuItem.acceleratorDelimiter",
1190 menuItemAcceleratorDelimiter,
1191 "MenuItem.border",
1192 marginBorder,
1193 "MenuItem.borderPainted",
1194 Boolean.FALSE,
1195 "MenuItem.margin",
1196 twoInsets,
1197 "MenuItem.checkIcon",
1198 menuItemCheckIcon,
1199 "MenuItem.arrowIcon",
1200 menuItemArrowIcon,
1201 "MenuItem.commandSound",
1202 null,
1203
1204 "RadioButtonMenuItem.font",
1205 dialogPlain12,
1206 "RadioButtonMenuItem.acceleratorFont",
1207 dialogPlain12,
1208 "RadioButtonMenuItem.background",
1209 menu,
1210 "RadioButtonMenuItem.foreground",
1211 menuText,
1212 "RadioButtonMenuItem.selectionForeground",
1213 textHighlightText,
1214 "RadioButtonMenuItem.selectionBackground",
1215 textHighlight,
1216 "RadioButtonMenuItem.disabledForeground",
1217 null,
1218 "RadioButtonMenuItem.acceleratorForeground",
1219 menuText,
1220 "RadioButtonMenuItem.acceleratorSelectionForeground",
1221 textHighlightText,
1222 "RadioButtonMenuItem.border",
1223 marginBorder,
1224 "RadioButtonMenuItem.borderPainted",
1225 Boolean.FALSE,
1226 "RadioButtonMenuItem.margin",
1227 twoInsets,
1228 "RadioButtonMenuItem.checkIcon",
1229 radioButtonMenuItemIcon,
1230 "RadioButtonMenuItem.arrowIcon",
1231 menuItemArrowIcon,
1232 "RadioButtonMenuItem.commandSound",
1233 null,
1234
1235 "CheckBoxMenuItem.font",
1236 dialogPlain12,
1237 "CheckBoxMenuItem.acceleratorFont",
1238 dialogPlain12,
1239 "CheckBoxMenuItem.background",
1240 menu,
1241 "CheckBoxMenuItem.foreground",
1242 menuText,
1243 "CheckBoxMenuItem.selectionForeground",
1244 textHighlightText,
1245 "CheckBoxMenuItem.selectionBackground",
1246 textHighlight,
1247 "CheckBoxMenuItem.disabledForeground",
1248 null,
1249 "CheckBoxMenuItem.acceleratorForeground",
1250 menuText,
1251 "CheckBoxMenuItem.acceleratorSelectionForeground",
1252 textHighlightText,
1253 "CheckBoxMenuItem.border",
1254 marginBorder,
1255 "CheckBoxMenuItem.borderPainted",
1256 Boolean.FALSE,
1257 "CheckBoxMenuItem.margin",
1258 twoInsets,
1259 "CheckBoxMenuItem.checkIcon",
1260 checkBoxMenuItemIcon,
1261 "CheckBoxMenuItem.arrowIcon",
1262 menuItemArrowIcon,
1263 "CheckBoxMenuItem.commandSound",
1264 null,
1265
1266 "Menu.font",
1267 dialogPlain12,
1268 "Menu.acceleratorFont",
1269 dialogPlain12,
1270 "Menu.background",
1271 menu,
1272 "Menu.foreground",
1273 menuText,
1274 "Menu.selectionForeground",
1275 textHighlightText,
1276 "Menu.selectionBackground",
1277 textHighlight,
1278 "Menu.disabledForeground",
1279 null,
1280 "Menu.acceleratorForeground",
1281 menuText,
1282 "Menu.acceleratorSelectionForeground",
1283 textHighlightText,
1284 "Menu.border",
1285 marginBorder,
1286 "Menu.borderPainted",
1287 Boolean.FALSE,
1288 "Menu.margin",
1289 twoInsets,
1290 "Menu.checkIcon",
1291 menuItemCheckIcon,
1292 "Menu.arrowIcon",
1293 menuArrowIcon,
1294 "Menu.menuPopupOffsetX",
1295 new Integer(0),
1296 "Menu.menuPopupOffsetY",
1297 new Integer(0),
1298 "Menu.submenuPopupOffsetX",
1299 new Integer(0),
1300 "Menu.submenuPopupOffsetY",
1301 new Integer(0),
1302 "Menu.shortcutKeys",
1303 new int[] { KeyEvent.ALT_MASK },
1304 "Menu.crossMenuMnemonic",
1305 Boolean.TRUE,
1306 // Menu.cancelMode affects the cancel menu action behaviour;
1307 // currently supports:
1308 // "hideLastSubmenu" (default)
1309 // hides the last open submenu,
1310 // and move selection one step back
1311 // "hideMenuTree"
1312 // resets selection and
1313 // hide the entire structure of open menu and its submenus
1314 "Menu.cancelMode",
1315 "hideLastSubmenu",
1316
1317 // Menu.preserveTopLevelSelection affects
1318 // the cancel menu action behaviour
1319 // if set to true then top level menu selection
1320 // will be preserved when the last popup was cancelled;
1321 // the menu itself will be unselect with the next cancel action
1322 "Menu.preserveTopLevelSelection",
1323 Boolean.FALSE,
1324
1325 // PopupMenu
1326 "PopupMenu.font",
1327 dialogPlain12,
1328 "PopupMenu.background",
1329 menu,
1330 "PopupMenu.foreground",
1331 menuText,
1332 "PopupMenu.border",
1333 popupMenuBorder,
1334 // Internal Frame Auditory Cue Mappings
1335 "PopupMenu.popupSound",
1336 null,
1337 // These window InputMap bindings are used when the Menu is
1338 // selected.
1339 "PopupMenu.selectedWindowInputMapBindings",
1340 new Object[] { "ESCAPE", "cancel", "DOWN",
1341 "selectNext", "KP_DOWN", "selectNext", "UP",
1342 "selectPrevious", "KP_UP", "selectPrevious",
1343 "LEFT", "selectParent", "KP_LEFT",
1344 "selectParent", "RIGHT", "selectChild",
1345 "KP_RIGHT", "selectChild", "ENTER", "return",
1346 "ctrl ENTER", "return", "SPACE", "return" },
1347 "PopupMenu.selectedWindowInputMapBindings.RightToLeft",
1348 new Object[] { "LEFT", "selectChild", "KP_LEFT",
1349 "selectChild", "RIGHT", "selectParent",
1350 "KP_RIGHT", "selectParent", },
1351 "PopupMenu.consumeEventOnClose",
1352 Boolean.FALSE,
1353
1354 // *** OptionPane
1355 // You can additionaly define OptionPane.messageFont which will
1356 // dictate the fonts used for the message, and
1357 // OptionPane.buttonFont, which defines the font for the buttons.
1358 "OptionPane.font",
1359 dialogPlain12,
1360 "OptionPane.background",
1361 control,
1362 "OptionPane.foreground",
1363 controlText,
1364 "OptionPane.messageForeground",
1365 controlText,
1366 "OptionPane.border",
1367 optionPaneBorder,
1368 "OptionPane.messageAreaBorder",
1369 zeroBorder,
1370 "OptionPane.buttonAreaBorder",
1371 optionPaneButtonAreaBorder,
1372 "OptionPane.minimumSize",
1373 optionPaneMinimumSize,
1374 "OptionPane.errorIcon",
1375 SwingUtilities2.makeIcon(getClass(),
1376 BasicLookAndFeel.class, "icons/Error.gif"),
1377 "OptionPane.informationIcon",
1378 SwingUtilities2.makeIcon(getClass(),
1379 BasicLookAndFeel.class, "icons/Inform.gif"),
1380 "OptionPane.warningIcon",
1381 SwingUtilities2.makeIcon(getClass(),
1382 BasicLookAndFeel.class, "icons/Warn.gif"),
1383 "OptionPane.questionIcon",
1384 SwingUtilities2.makeIcon(getClass(),
1385 BasicLookAndFeel.class, "icons/Question.gif"),
1386 "OptionPane.windowBindings",
1387 new Object[] { "ESCAPE", "close" },
1388 // OptionPane Auditory Cue Mappings
1389 "OptionPane.errorSound",
1390 null,
1391 "OptionPane.informationSound",
1392 null, // Info and Plain
1393 "OptionPane.questionSound",
1394 null,
1395 "OptionPane.warningSound",
1396 null,
1397 "OptionPane.buttonClickThreshhold",
1398 fiveHundred,
1399
1400 // *** Panel
1401 "Panel.font",
1402 dialogPlain12,
1403 "Panel.background",
1404 control,
1405 "Panel.foreground",
1406 textText,
1407
1408 // *** ProgressBar
1409 "ProgressBar.font",
1410 dialogPlain12,
1411 "ProgressBar.foreground",
1412 textHighlight,
1413 "ProgressBar.background",
1414 control,
1415 "ProgressBar.selectionForeground",
1416 control,
1417 "ProgressBar.selectionBackground",
1418 textHighlight,
1419 "ProgressBar.border",
1420 progressBarBorder,
1421 "ProgressBar.cellLength",
1422 new Integer(1),
1423 "ProgressBar.cellSpacing",
1424 zero,
1425 "ProgressBar.repaintInterval",
1426 new Integer(50),
1427 "ProgressBar.cycleTime",
1428 new Integer(3000),
1429 "ProgressBar.horizontalSize",
1430 new DimensionUIResource(146, 12),
1431 "ProgressBar.verticalSize",
1432 new DimensionUIResource(12, 146),
1433
1434 // *** Separator
1435 "Separator.shadow",
1436 controlShadow, // DEPRECATED - DO NOT USE!
1437 "Separator.highlight",
1438 controlLtHighlight, // DEPRECATED - DO NOT USE!
1439
1440 "Separator.background",
1441 controlLtHighlight,
1442 "Separator.foreground",
1443 controlShadow,
1444
1445 // *** ScrollBar/ScrollPane/Viewport
1446 "ScrollBar.background",
1447 scrollBarTrack,
1448 "ScrollBar.foreground",
1449 control,
1450 "ScrollBar.track",
1451 table.get("scrollbar"),
1452 "ScrollBar.trackHighlight",
1453 controlDkShadow,
1454 "ScrollBar.thumb",
1455 control,
1456 "ScrollBar.thumbHighlight",
1457 controlLtHighlight,
1458 "ScrollBar.thumbDarkShadow",
1459 controlDkShadow,
1460 "ScrollBar.thumbShadow",
1461 controlShadow,
1462 "ScrollBar.border",
1463 null,
1464 "ScrollBar.minimumThumbSize",
1465 minimumThumbSize,
1466 "ScrollBar.maximumThumbSize",
1467 maximumThumbSize,
1468 "ScrollBar.ancestorInputMap",
1469 new UIDefaults.LazyInputMap(new Object[] { "RIGHT",
1470 "positiveUnitIncrement", "KP_RIGHT",
1471 "positiveUnitIncrement", "DOWN",
1472 "positiveUnitIncrement", "KP_DOWN",
1473 "positiveUnitIncrement", "PAGE_DOWN",
1474 "positiveBlockIncrement", "LEFT",
1475 "negativeUnitIncrement", "KP_LEFT",
1476 "negativeUnitIncrement", "UP",
1477 "negativeUnitIncrement", "KP_UP",
1478 "negativeUnitIncrement", "PAGE_UP",
1479 "negativeBlockIncrement", "HOME", "minScroll",
1480 "END", "maxScroll" }),
1481 "ScrollBar.ancestorInputMap.RightToLeft",
1482 new UIDefaults.LazyInputMap(new Object[] { "RIGHT",
1483 "negativeUnitIncrement", "KP_RIGHT",
1484 "negativeUnitIncrement", "LEFT",
1485 "positiveUnitIncrement", "KP_LEFT",
1486 "positiveUnitIncrement", }),
1487 "ScrollBar.width",
1488 new Integer(16),
1489
1490 "ScrollPane.font",
1491 dialogPlain12,
1492 "ScrollPane.background",
1493 control,
1494 "ScrollPane.foreground",
1495 controlText,
1496 "ScrollPane.border",
1497 textFieldBorder,
1498 "ScrollPane.viewportBorder",
1499 null,
1500 "ScrollPane.ancestorInputMap",
1501 new UIDefaults.LazyInputMap(new Object[] { "RIGHT",
1502 "unitScrollRight", "KP_RIGHT",
1503 "unitScrollRight", "DOWN", "unitScrollDown",
1504 "KP_DOWN", "unitScrollDown", "LEFT",
1505 "unitScrollLeft", "KP_LEFT", "unitScrollLeft",
1506 "UP", "unitScrollUp", "KP_UP", "unitScrollUp",
1507 "PAGE_UP", "scrollUp", "PAGE_DOWN",
1508 "scrollDown", "ctrl PAGE_UP", "scrollLeft",
1509 "ctrl PAGE_DOWN", "scrollRight", "ctrl HOME",
1510 "scrollHome", "ctrl END", "scrollEnd" }),
1511 "ScrollPane.ancestorInputMap.RightToLeft",
1512 new UIDefaults.LazyInputMap(new Object[] {
1513 "ctrl PAGE_UP", "scrollRight",
1514 "ctrl PAGE_DOWN", "scrollLeft", }),
1515
1516 "Viewport.font",
1517 dialogPlain12,
1518 "Viewport.background",
1519 control,
1520 "Viewport.foreground",
1521 textText,
1522
1523 // *** Slider
1524 "Slider.font",
1525 dialogPlain12,
1526 "Slider.foreground",
1527 control,
1528 "Slider.background",
1529 control,
1530 "Slider.highlight",
1531 controlLtHighlight,
1532 "Slider.tickColor",
1533 Color.black,
1534 "Slider.shadow",
1535 controlShadow,
1536 "Slider.focus",
1537 controlDkShadow,
1538 "Slider.border",
1539 null,
1540 "Slider.horizontalSize",
1541 new Dimension(200, 21),
1542 "Slider.verticalSize",
1543 new Dimension(21, 200),
1544 "Slider.minimumHorizontalSize",
1545 new Dimension(36, 21),
1546 "Slider.minimumVerticalSize",
1547 new Dimension(21, 36),
1548 "Slider.focusInsets",
1549 sliderFocusInsets,
1550 "Slider.focusInputMap",
1551 new UIDefaults.LazyInputMap(new Object[] { "RIGHT",
1552 "positiveUnitIncrement", "KP_RIGHT",
1553 "positiveUnitIncrement", "DOWN",
1554 "negativeUnitIncrement", "KP_DOWN",
1555 "negativeUnitIncrement", "PAGE_DOWN",
1556 "negativeBlockIncrement", "LEFT",
1557 "negativeUnitIncrement", "KP_LEFT",
1558 "negativeUnitIncrement", "UP",
1559 "positiveUnitIncrement", "KP_UP",
1560 "positiveUnitIncrement", "PAGE_UP",
1561 "positiveBlockIncrement", "HOME", "minScroll",
1562 "END", "maxScroll" }),
1563 "Slider.focusInputMap.RightToLeft",
1564 new UIDefaults.LazyInputMap(new Object[] { "RIGHT",
1565 "negativeUnitIncrement", "KP_RIGHT",
1566 "negativeUnitIncrement", "LEFT",
1567 "positiveUnitIncrement", "KP_LEFT",
1568 "positiveUnitIncrement", }),
1569
1570 // *** Spinner
1571 "Spinner.font",
1572 monospacedPlain12,
1573 "Spinner.background",
1574 control,
1575 "Spinner.foreground",
1576 control,
1577 "Spinner.border",
1578 textFieldBorder,
1579 "Spinner.arrowButtonBorder",
1580 null,
1581 "Spinner.arrowButtonInsets",
1582 null,
1583 "Spinner.arrowButtonSize",
1584 new Dimension(16, 5),
1585 "Spinner.ancestorInputMap",
1586 new UIDefaults.LazyInputMap(new Object[] { "UP",
1587 "increment", "KP_UP", "increment", "DOWN",
1588 "decrement", "KP_DOWN", "decrement", }),
1589 "Spinner.editorBorderPainted",
1590 Boolean.FALSE,
1591 "Spinner.editorAlignment",
1592 JTextField.TRAILING,
1593
1594 // *** SplitPane
1595 "SplitPane.background",
1596 control,
1597 "SplitPane.highlight",
1598 controlLtHighlight,
1599 "SplitPane.shadow",
1600 controlShadow,
1601 "SplitPane.darkShadow",
1602 controlDkShadow,
1603 "SplitPane.border",
1604 splitPaneBorder,
1605 "SplitPane.dividerSize",
1606 new Integer(7),
1607 "SplitPaneDivider.border",
1608 splitPaneDividerBorder,
1609 "SplitPaneDivider.draggingColor",
1610 darkGray,
1611 "SplitPane.ancestorInputMap",
1612 new UIDefaults.LazyInputMap(new Object[] { "UP",
1613 "negativeIncrement", "DOWN",
1614 "positiveIncrement", "LEFT",
1615 "negativeIncrement", "RIGHT",
1616 "positiveIncrement", "KP_UP",
1617 "negativeIncrement", "KP_DOWN",
1618 "positiveIncrement", "KP_LEFT",
1619 "negativeIncrement", "KP_RIGHT",
1620 "positiveIncrement", "HOME", "selectMin",
1621 "END", "selectMax", "F8", "startResize", "F6",
1622 "toggleFocus", "ctrl TAB", "focusOutForward",
1623 "ctrl shift TAB", "focusOutBackward" }),
1624
1625 // *** TabbedPane
1626 "TabbedPane.font",
1627 dialogPlain12,
1628 "TabbedPane.background",
1629 control,
1630 "TabbedPane.foreground",
1631 controlText,
1632 "TabbedPane.highlight",
1633 controlLtHighlight,
1634 "TabbedPane.light",
1635 controlHighlight,
1636 "TabbedPane.shadow",
1637 controlShadow,
1638 "TabbedPane.darkShadow",
1639 controlDkShadow,
1640 "TabbedPane.selected",
1641 null,
1642 "TabbedPane.focus",
1643 controlText,
1644 "TabbedPane.textIconGap",
1645 four,
1646
1647 // Causes tabs to be painted on top of the content area border.
1648 // The amount of overlap is then controlled by tabAreaInsets.bottom,
1649 // which is zero by default
1650 "TabbedPane.tabsOverlapBorder",
1651 Boolean.FALSE,
1652 "TabbedPane.selectionFollowsFocus",
1653 Boolean.TRUE,
1654
1655 "TabbedPane.labelShift",
1656 1,
1657 "TabbedPane.selectedLabelShift",
1658 -1,
1659 "TabbedPane.tabInsets",
1660 tabbedPaneTabInsets,
1661 "TabbedPane.selectedTabPadInsets",
1662 tabbedPaneTabPadInsets,
1663 "TabbedPane.tabAreaInsets",
1664 tabbedPaneTabAreaInsets,
1665 "TabbedPane.contentBorderInsets",
1666 tabbedPaneContentBorderInsets,
1667 "TabbedPane.tabRunOverlay",
1668 new Integer(2),
1669 "TabbedPane.tabsOpaque",
1670 Boolean.TRUE,
1671 "TabbedPane.contentOpaque",
1672 Boolean.TRUE,
1673 "TabbedPane.focusInputMap",
1674 new UIDefaults.LazyInputMap(new Object[] { "RIGHT",
1675 "navigateRight", "KP_RIGHT", "navigateRight",
1676 "LEFT", "navigateLeft", "KP_LEFT",
1677 "navigateLeft", "UP", "navigateUp", "KP_UP",
1678 "navigateUp", "DOWN", "navigateDown",
1679 "KP_DOWN", "navigateDown", "ctrl DOWN",
1680 "requestFocusForVisibleComponent",
1681 "ctrl KP_DOWN",
1682 "requestFocusForVisibleComponent", }),
1683 "TabbedPane.ancestorInputMap",
1684 new UIDefaults.LazyInputMap(new Object[] {
1685 "ctrl PAGE_DOWN", "navigatePageDown",
1686 "ctrl PAGE_UP", "navigatePageUp", "ctrl UP",
1687 "requestFocus", "ctrl KP_UP", "requestFocus", }),
1688
1689 // *** Table
1690 "Table.font",
1691 dialogPlain12,
1692 "Table.foreground",
1693 controlText, // cell text color
1694 "Table.background",
1695 window, // cell background color
1696 "Table.selectionForeground",
1697 textHighlightText,
1698 "Table.selectionBackground",
1699 textHighlight,
1700 "Table.dropLineColor",
1701 controlShadow,
1702 "Table.dropLineShortColor",
1703 black,
1704 "Table.gridColor",
1705 gray, // grid line color
1706 "Table.focusCellBackground",
1707 window,
1708 "Table.focusCellForeground",
1709 controlText,
1710 "Table.focusCellHighlightBorder",
1711 focusCellHighlightBorder,
1712 "Table.scrollPaneBorder",
1713 loweredBevelBorder,
1714 "Table.ancestorInputMap",
1715 new UIDefaults.LazyInputMap(new Object[] { "ctrl C",
1716 "copy", "ctrl V", "paste", "ctrl X", "cut",
1717 "COPY", "copy", "PASTE", "paste", "CUT", "cut",
1718 "control INSERT", "copy", "shift INSERT",
1719 "paste", "shift DELETE", "cut", "RIGHT",
1720 "selectNextColumn", "KP_RIGHT",
1721 "selectNextColumn", "shift RIGHT",
1722 "selectNextColumnExtendSelection",
1723 "shift KP_RIGHT",
1724 "selectNextColumnExtendSelection",
1725 "ctrl shift RIGHT",
1726 "selectNextColumnExtendSelection",
1727 "ctrl shift KP_RIGHT",
1728 "selectNextColumnExtendSelection",
1729 "ctrl RIGHT", "selectNextColumnChangeLead",
1730 "ctrl KP_RIGHT", "selectNextColumnChangeLead",
1731 "LEFT", "selectPreviousColumn", "KP_LEFT",
1732 "selectPreviousColumn", "shift LEFT",
1733 "selectPreviousColumnExtendSelection",
1734 "shift KP_LEFT",
1735 "selectPreviousColumnExtendSelection",
1736 "ctrl shift LEFT",
1737 "selectPreviousColumnExtendSelection",
1738 "ctrl shift KP_LEFT",
1739 "selectPreviousColumnExtendSelection",
1740 "ctrl LEFT", "selectPreviousColumnChangeLead",
1741 "ctrl KP_LEFT",
1742 "selectPreviousColumnChangeLead", "DOWN",
1743 "selectNextRow", "KP_DOWN", "selectNextRow",
1744 "shift DOWN", "selectNextRowExtendSelection",
1745 "shift KP_DOWN",
1746 "selectNextRowExtendSelection",
1747 "ctrl shift DOWN",
1748 "selectNextRowExtendSelection",
1749 "ctrl shift KP_DOWN",
1750 "selectNextRowExtendSelection", "ctrl DOWN",
1751 "selectNextRowChangeLead", "ctrl KP_DOWN",
1752 "selectNextRowChangeLead", "UP",
1753 "selectPreviousRow", "KP_UP",
1754 "selectPreviousRow", "shift UP",
1755 "selectPreviousRowExtendSelection",
1756 "shift KP_UP",
1757 "selectPreviousRowExtendSelection",
1758 "ctrl shift UP",
1759 "selectPreviousRowExtendSelection",
1760 "ctrl shift KP_UP",
1761 "selectPreviousRowExtendSelection", "ctrl UP",
1762 "selectPreviousRowChangeLead", "ctrl KP_UP",
1763 "selectPreviousRowChangeLead", "HOME",
1764 "selectFirstColumn", "shift HOME",
1765 "selectFirstColumnExtendSelection",
1766 "ctrl shift HOME",
1767 "selectFirstRowExtendSelection", "ctrl HOME",
1768 "selectFirstRow", "END", "selectLastColumn",
1769 "shift END", "selectLastColumnExtendSelection",
1770 "ctrl shift END",
1771 "selectLastRowExtendSelection", "ctrl END",
1772 "selectLastRow", "PAGE_UP",
1773 "scrollUpChangeSelection", "shift PAGE_UP",
1774 "scrollUpExtendSelection",
1775 "ctrl shift PAGE_UP",
1776 "scrollLeftExtendSelection", "ctrl PAGE_UP",
1777 "scrollLeftChangeSelection", "PAGE_DOWN",
1778 "scrollDownChangeSelection", "shift PAGE_DOWN",
1779 "scrollDownExtendSelection",
1780 "ctrl shift PAGE_DOWN",
1781 "scrollRightExtendSelection", "ctrl PAGE_DOWN",
1782 "scrollRightChangeSelection", "TAB",
1783 "selectNextColumnCell", "shift TAB",
1784 "selectPreviousColumnCell", "ENTER",
1785 "selectNextRowCell", "shift ENTER",
1786 "selectPreviousRowCell", "ctrl A", "selectAll",
1787 "ctrl SLASH", "selectAll", "ctrl BACK_SLASH",
1788 "clearSelection", "ESCAPE", "cancel", "F2",
1789 "startEditing", "SPACE", "addToSelection",
1790 "ctrl SPACE", "toggleAndAnchor", "shift SPACE",
1791 "extendTo", "ctrl shift SPACE",
1792 "moveSelectionTo", "F8", "focusHeader" }),
1793 "Table.ancestorInputMap.RightToLeft",
1794 new UIDefaults.LazyInputMap(new Object[] { "RIGHT",
1795 "selectPreviousColumn", "KP_RIGHT",
1796 "selectPreviousColumn", "shift RIGHT",
1797 "selectPreviousColumnExtendSelection",
1798 "shift KP_RIGHT",
1799 "selectPreviousColumnExtendSelection",
1800 "ctrl shift RIGHT",
1801 "selectPreviousColumnExtendSelection",
1802 "ctrl shift KP_RIGHT",
1803 "selectPreviousColumnExtendSelection",
1804 "ctrl RIGHT", "selectPreviousColumnChangeLead",
1805 "ctrl KP_RIGHT",
1806 "selectPreviousColumnChangeLead", "LEFT",
1807 "selectNextColumn", "KP_LEFT",
1808 "selectNextColumn", "shift LEFT",
1809 "selectNextColumnExtendSelection",
1810 "shift KP_LEFT",
1811 "selectNextColumnExtendSelection",
1812 "ctrl shift LEFT",
1813 "selectNextColumnExtendSelection",
1814 "ctrl shift KP_LEFT",
1815 "selectNextColumnExtendSelection", "ctrl LEFT",
1816 "selectNextColumnChangeLead", "ctrl KP_LEFT",
1817 "selectNextColumnChangeLead", "ctrl PAGE_UP",
1818 "scrollRightChangeSelection", "ctrl PAGE_DOWN",
1819 "scrollLeftChangeSelection",
1820 "ctrl shift PAGE_UP",
1821 "scrollRightExtendSelection",
1822 "ctrl shift PAGE_DOWN",
1823 "scrollLeftExtendSelection", }),
1824 "Table.ascendingSortIcon",
1825 new SwingLazyValue("sun.swing.icon.SortArrowIcon",
1826 null, new Object[] { Boolean.TRUE,
1827 "Table.sortIconColor" }),
1828 "Table.descendingSortIcon",
1829 new SwingLazyValue("sun.swing.icon.SortArrowIcon",
1830 null, new Object[] { Boolean.FALSE,
1831 "Table.sortIconColor" }),
1832 "Table.sortIconColor",
1833 controlShadow,
1834
1835 "TableHeader.font",
1836 dialogPlain12,
1837 "TableHeader.foreground",
1838 controlText, // header text color
1839 "TableHeader.background",
1840 control, // header background
1841 "TableHeader.cellBorder",
1842 tableHeaderBorder,
1843
1844 // Support for changing the background/border of the currently
1845 // selected header column when the header has the keyboard focus.
1846 "TableHeader.focusCellBackground",
1847 table.getColor("text"), // like text component bg
1848 "TableHeader.focusCellForeground",
1849 null,
1850 "TableHeader.focusCellBorder",
1851 null,
1852 "TableHeader.ancestorInputMap",
1853 new UIDefaults.LazyInputMap(new Object[] { "SPACE",
1854 "toggleSortOrder", "LEFT",
1855 "selectColumnToLeft", "KP_LEFT",
1856 "selectColumnToLeft", "RIGHT",
1857 "selectColumnToRight", "KP_RIGHT",
1858 "selectColumnToRight", "alt LEFT",
1859 "moveColumnLeft", "alt KP_LEFT",
1860 "moveColumnLeft", "alt RIGHT",
1861 "moveColumnRight", "alt KP_RIGHT",
1862 "moveColumnRight", "alt shift LEFT",
1863 "resizeLeft", "alt shift KP_LEFT",
1864 "resizeLeft", "alt shift RIGHT", "resizeRight",
1865 "alt shift KP_RIGHT", "resizeRight", "ESCAPE",
1866 "focusTable", }),
1867
1868 // *** Text
1869 "TextField.font",
1870 sansSerifPlain12,
1871 "TextField.background",
1872 window,
1873 "TextField.foreground",
1874 textText,
1875 "TextField.shadow",
1876 controlShadow,
1877 "TextField.darkShadow",
1878 controlDkShadow,
1879 "TextField.light",
1880 controlHighlight,
1881 "TextField.highlight",
1882 controlLtHighlight,
1883 "TextField.inactiveForeground",
1884 textInactiveText,
1885 "TextField.inactiveBackground",
1886 control,
1887 "TextField.selectionBackground",
1888 textHighlight,
1889 "TextField.selectionForeground",
1890 textHighlightText,
1891 "TextField.caretForeground",
1892 textText,
1893 "TextField.caretBlinkRate",
1894 caretBlinkRate,
1895 "TextField.border",
1896 textFieldBorder,
1897 "TextField.margin",
1898 zeroInsets,
1899
1900 "FormattedTextField.font",
1901 sansSerifPlain12,
1902 "FormattedTextField.background",
1903 window,
1904 "FormattedTextField.foreground",
1905 textText,
1906 "FormattedTextField.inactiveForeground",
1907 textInactiveText,
1908 "FormattedTextField.inactiveBackground",
1909 control,
1910 "FormattedTextField.selectionBackground",
1911 textHighlight,
1912 "FormattedTextField.selectionForeground",
1913 textHighlightText,
1914 "FormattedTextField.caretForeground",
1915 textText,
1916 "FormattedTextField.caretBlinkRate",
1917 caretBlinkRate,
1918 "FormattedTextField.border",
1919 textFieldBorder,
1920 "FormattedTextField.margin",
1921 zeroInsets,
1922 "FormattedTextField.focusInputMap",
1923 new UIDefaults.LazyInputMap(new Object[] { "ctrl C",
1924 DefaultEditorKit.copyAction, "ctrl V",
1925 DefaultEditorKit.pasteAction, "ctrl X",
1926 DefaultEditorKit.cutAction, "COPY",
1927 DefaultEditorKit.copyAction, "PASTE",
1928 DefaultEditorKit.pasteAction, "CUT",
1929 DefaultEditorKit.cutAction, "control INSERT",
1930 DefaultEditorKit.copyAction, "shift INSERT",
1931 DefaultEditorKit.pasteAction, "shift DELETE",
1932 DefaultEditorKit.cutAction, "shift LEFT",
1933 DefaultEditorKit.selectionBackwardAction,
1934 "shift KP_LEFT",
1935 DefaultEditorKit.selectionBackwardAction,
1936 "shift RIGHT",
1937 DefaultEditorKit.selectionForwardAction,
1938 "shift KP_RIGHT",
1939 DefaultEditorKit.selectionForwardAction,
1940 "ctrl LEFT",
1941 DefaultEditorKit.previousWordAction,
1942 "ctrl KP_LEFT",
1943 DefaultEditorKit.previousWordAction,
1944 "ctrl RIGHT", DefaultEditorKit.nextWordAction,
1945 "ctrl KP_RIGHT",
1946 DefaultEditorKit.nextWordAction,
1947 "ctrl shift LEFT",
1948 DefaultEditorKit.selectionPreviousWordAction,
1949 "ctrl shift KP_LEFT",
1950 DefaultEditorKit.selectionPreviousWordAction,
1951 "ctrl shift RIGHT",
1952 DefaultEditorKit.selectionNextWordAction,
1953 "ctrl shift KP_RIGHT",
1954 DefaultEditorKit.selectionNextWordAction,
1955 "ctrl A", DefaultEditorKit.selectAllAction,
1956 "HOME", DefaultEditorKit.beginLineAction,
1957 "END", DefaultEditorKit.endLineAction,
1958 "shift HOME",
1959 DefaultEditorKit.selectionBeginLineAction,
1960 "shift END",
1961 DefaultEditorKit.selectionEndLineAction,
1962 "BACK_SPACE",
1963 DefaultEditorKit.deletePrevCharAction,
1964 "shift BACK_SPACE",
1965 DefaultEditorKit.deletePrevCharAction,
1966 "ctrl H",
1967 DefaultEditorKit.deletePrevCharAction,
1968 "DELETE",
1969 DefaultEditorKit.deleteNextCharAction,
1970 "ctrl DELETE",
1971 DefaultEditorKit.deleteNextWordAction,
1972 "ctrl BACK_SPACE",
1973 DefaultEditorKit.deletePrevWordAction, "RIGHT",
1974 DefaultEditorKit.forwardAction, "LEFT",
1975 DefaultEditorKit.backwardAction, "KP_RIGHT",
1976 DefaultEditorKit.forwardAction, "KP_LEFT",
1977 DefaultEditorKit.backwardAction, "ENTER",
1978 JTextField.notifyAction, "ctrl BACK_SLASH",
1979 "unselect", "control shift O",
1980 "toggle-componentOrientation", "ESCAPE",
1981 "reset-field-edit", "UP", "increment", "KP_UP",
1982 "increment", "DOWN", "decrement", "KP_DOWN",
1983 "decrement", }),
1984
1985 "PasswordField.font",
1986 monospacedPlain12,
1987 "PasswordField.background",
1988 window,
1989 "PasswordField.foreground",
1990 textText,
1991 "PasswordField.inactiveForeground",
1992 textInactiveText,
1993 "PasswordField.inactiveBackground",
1994 control,
1995 "PasswordField.selectionBackground",
1996 textHighlight,
1997 "PasswordField.selectionForeground",
1998 textHighlightText,
1999 "PasswordField.caretForeground",
2000 textText,
2001 "PasswordField.caretBlinkRate",
2002 caretBlinkRate,
2003 "PasswordField.border",
2004 textFieldBorder,
2005 "PasswordField.margin",
2006 zeroInsets,
2007 "PasswordField.echoChar",
2008 '*',
2009
2010 "TextArea.font",
2011 monospacedPlain12,
2012 "TextArea.background",
2013 window,
2014 "TextArea.foreground",
2015 textText,
2016 "TextArea.inactiveForeground",
2017 textInactiveText,
2018 "TextArea.selectionBackground",
2019 textHighlight,
2020 "TextArea.selectionForeground",
2021 textHighlightText,
2022 "TextArea.caretForeground",
2023 textText,
2024 "TextArea.caretBlinkRate",
2025 caretBlinkRate,
2026 "TextArea.border",
2027 marginBorder,
2028 "TextArea.margin",
2029 zeroInsets,
2030
2031 "TextPane.font",
2032 serifPlain12,
2033 "TextPane.background",
2034 white,
2035 "TextPane.foreground",
2036 textText,
2037 "TextPane.selectionBackground",
2038 textHighlight,
2039 "TextPane.selectionForeground",
2040 textHighlightText,
2041 "TextPane.caretForeground",
2042 textText,
2043 "TextPane.caretBlinkRate",
2044 caretBlinkRate,
2045 "TextPane.inactiveForeground",
2046 textInactiveText,
2047 "TextPane.border",
2048 marginBorder,
2049 "TextPane.margin",
2050 editorMargin,
2051
2052 "EditorPane.font",
2053 serifPlain12,
2054 "EditorPane.background",
2055 white,
2056 "EditorPane.foreground",
2057 textText,
2058 "EditorPane.selectionBackground",
2059 textHighlight,
2060 "EditorPane.selectionForeground",
2061 textHighlightText,
2062 "EditorPane.caretForeground",
2063 textText,
2064 "EditorPane.caretBlinkRate",
2065 caretBlinkRate,
2066 "EditorPane.inactiveForeground",
2067 textInactiveText,
2068 "EditorPane.border",
2069 marginBorder,
2070 "EditorPane.margin",
2071 editorMargin,
2072
2073 "html.pendingImage",
2074 SwingUtilities2.makeIcon(getClass(),
2075 BasicLookAndFeel.class,
2076 "icons/image-delayed.png"),
2077 "html.missingImage",
2078 SwingUtilities2.makeIcon(getClass(),
2079 BasicLookAndFeel.class,
2080 "icons/image-failed.png"),
2081 // *** TitledBorder
2082 "TitledBorder.font",
2083 dialogPlain12,
2084 "TitledBorder.titleColor",
2085 controlText,
2086 "TitledBorder.border",
2087 etchedBorder,
2088
2089 // *** ToolBar
2090 "ToolBar.font",
2091 dialogPlain12,
2092 "ToolBar.background",
2093 control,
2094 "ToolBar.foreground",
2095 controlText,
2096 "ToolBar.shadow",
2097 controlShadow,
2098 "ToolBar.darkShadow",
2099 controlDkShadow,
2100 "ToolBar.light",
2101 controlHighlight,
2102 "ToolBar.highlight",
2103 controlLtHighlight,
2104 "ToolBar.dockingBackground",
2105 control,
2106 "ToolBar.dockingForeground",
2107 red,
2108 "ToolBar.floatingBackground",
2109 control,
2110 "ToolBar.floatingForeground",
2111 darkGray,
2112 "ToolBar.border",
2113 etchedBorder,
2114 "ToolBar.separatorSize",
2115 toolBarSeparatorSize,
2116 "ToolBar.ancestorInputMap",
2117 new UIDefaults.LazyInputMap(new Object[] { "UP",
2118 "navigateUp", "KP_UP", "navigateUp", "DOWN",
2119 "navigateDown", "KP_DOWN", "navigateDown",
2120 "LEFT", "navigateLeft", "KP_LEFT",
2121 "navigateLeft", "RIGHT", "navigateRight",
2122 "KP_RIGHT", "navigateRight" }),
2123
2124 // *** ToolTips
2125 "ToolTip.font",
2126 sansSerifPlain12,
2127 "ToolTip.background",
2128 table.get("info"),
2129 "ToolTip.foreground",
2130 table.get("infoText"),
2131 "ToolTip.border",
2132 blackLineBorder,
2133 // ToolTips also support backgroundInactive, borderInactive,
2134 // and foregroundInactive
2135
2136 // *** ToolTipManager
2137 // ToolTipManager.enableToolTipMode currently supports:
2138 // "allWindows" (default):
2139 // enables tool tips for all windows of all java applications,
2140 // whether the windows are active or inactive
2141 // "activeApplication"
2142 // enables tool tips for windows of an application only when
2143 // the application has an active window
2144 "ToolTipManager.enableToolTipMode",
2145 "allWindows",
2146
2147 // *** Tree
2148 "Tree.paintLines",
2149 Boolean.TRUE,
2150 "Tree.lineTypeDashed",
2151 Boolean.FALSE,
2152 "Tree.font",
2153 dialogPlain12,
2154 "Tree.background",
2155 window,
2156 "Tree.foreground",
2157 textText,
2158 "Tree.hash",
2159 gray,
2160 "Tree.textForeground",
2161 textText,
2162 "Tree.textBackground",
2163 table.get("text"),
2164 "Tree.selectionForeground",
2165 textHighlightText,
2166 "Tree.selectionBackground",
2167 textHighlight,
2168 "Tree.selectionBorderColor",
2169 black,
2170 "Tree.dropLineColor",
2171 controlShadow,
2172 "Tree.editorBorder",
2173 blackLineBorder,
2174 "Tree.leftChildIndent",
2175 new Integer(7),
2176 "Tree.rightChildIndent",
2177 new Integer(13),
2178 "Tree.rowHeight",
2179 new Integer(16),
2180 "Tree.scrollsOnExpand",
2181 Boolean.TRUE,
2182 "Tree.openIcon",
2183 SwingUtilities2.makeIcon(getClass(),
2184 BasicLookAndFeel.class, "icons/TreeOpen.gif"),
2185 "Tree.closedIcon",
2186 SwingUtilities2.makeIcon(getClass(),
2187 BasicLookAndFeel.class, "icons/TreeClosed.gif"),
2188 "Tree.leafIcon",
2189 SwingUtilities2.makeIcon(getClass(),
2190 BasicLookAndFeel.class, "icons/TreeLeaf.gif"),
2191 "Tree.expandedIcon",
2192 null,
2193 "Tree.collapsedIcon",
2194 null,
2195 "Tree.changeSelectionWithFocus",
2196 Boolean.TRUE,
2197 "Tree.drawsFocusBorderAroundIcon",
2198 Boolean.FALSE,
2199 "Tree.timeFactor",
2200 oneThousand,
2201 "Tree.focusInputMap",
2202 new UIDefaults.LazyInputMap(new Object[] { "ctrl C",
2203 "copy", "ctrl V", "paste", "ctrl X", "cut",
2204 "COPY", "copy", "PASTE", "paste", "CUT", "cut",
2205 "control INSERT", "copy", "shift INSERT",
2206 "paste", "shift DELETE", "cut", "UP",
2207 "selectPrevious", "KP_UP", "selectPrevious",
2208 "shift UP", "selectPreviousExtendSelection",
2209 "shift KP_UP", "selectPreviousExtendSelection",
2210 "ctrl shift UP",
2211 "selectPreviousExtendSelection",
2212 "ctrl shift KP_UP",
2213 "selectPreviousExtendSelection", "ctrl UP",
2214 "selectPreviousChangeLead", "ctrl KP_UP",
2215 "selectPreviousChangeLead", "DOWN",
2216 "selectNext", "KP_DOWN", "selectNext",
2217 "shift DOWN", "selectNextExtendSelection",
2218 "shift KP_DOWN", "selectNextExtendSelection",
2219 "ctrl shift DOWN", "selectNextExtendSelection",
2220 "ctrl shift KP_DOWN",
2221 "selectNextExtendSelection", "ctrl DOWN",
2222 "selectNextChangeLead", "ctrl KP_DOWN",
2223 "selectNextChangeLead", "RIGHT", "selectChild",
2224 "KP_RIGHT", "selectChild", "LEFT",
2225 "selectParent", "KP_LEFT", "selectParent",
2226 "PAGE_UP", "scrollUpChangeSelection",
2227 "shift PAGE_UP", "scrollUpExtendSelection",
2228 "ctrl shift PAGE_UP",
2229 "scrollUpExtendSelection", "ctrl PAGE_UP",
2230 "scrollUpChangeLead", "PAGE_DOWN",
2231 "scrollDownChangeSelection", "shift PAGE_DOWN",
2232 "scrollDownExtendSelection",
2233 "ctrl shift PAGE_DOWN",
2234 "scrollDownExtendSelection", "ctrl PAGE_DOWN",
2235 "scrollDownChangeLead", "HOME", "selectFirst",
2236 "shift HOME", "selectFirstExtendSelection",
2237 "ctrl shift HOME",
2238 "selectFirstExtendSelection", "ctrl HOME",
2239 "selectFirstChangeLead", "END", "selectLast",
2240 "shift END", "selectLastExtendSelection",
2241 "ctrl shift END", "selectLastExtendSelection",
2242 "ctrl END", "selectLastChangeLead", "F2",
2243 "startEditing", "ctrl A", "selectAll",
2244 "ctrl SLASH", "selectAll", "ctrl BACK_SLASH",
2245 "clearSelection", "ctrl LEFT", "scrollLeft",
2246 "ctrl KP_LEFT", "scrollLeft", "ctrl RIGHT",
2247 "scrollRight", "ctrl KP_RIGHT", "scrollRight",
2248 "SPACE", "addToSelection", "ctrl SPACE",
2249 "toggleAndAnchor", "shift SPACE", "extendTo",
2250 "ctrl shift SPACE", "moveSelectionTo" }),
2251 "Tree.focusInputMap.RightToLeft",
2252 new UIDefaults.LazyInputMap(new Object[] { "RIGHT",
2253 "selectParent", "KP_RIGHT", "selectParent",
2254 "LEFT", "selectChild", "KP_LEFT",
2255 "selectChild", }),
2256 "Tree.ancestorInputMap",
2257 new UIDefaults.LazyInputMap(new Object[] { "ESCAPE",
2258 "cancel" }),
2259 // Bind specific keys that can invoke popup on currently
2260 // focused JComponent
2261 "RootPane.ancestorInputMap",
2262 new UIDefaults.LazyInputMap(new Object[] { "shift F10",
2263 "postPopup", "CONTEXT_MENU", "postPopup" }),
2264
2265 // These bindings are only enabled when there is a default
2266 // button set on the rootpane.
2267 "RootPane.defaultButtonWindowKeyBindings",
2268 new Object[] { "ENTER", "press", "released ENTER",
2269 "release", "ctrl ENTER", "press",
2270 "ctrl released ENTER", "release" }, };
2271
2272 table.putDefaults(defaults);
2273 }
2274
2275 /**
2276 * Returns the ui that is of type <code>klass</code>, or null if
2277 * one can not be found.
2278 */
2279 static Object getUIOfType(ComponentUI ui, Class klass) {
2280 if (klass.isInstance(ui)) {
2281 return ui;
2282 }
2283 return null;
2284 }
2285
2286 // ********* Auditory Cue support methods and objects *********
2287 // also see the "AuditoryCues" section of the defaults table
2288
2289 /**
2290 * Returns an <code>ActionMap</code> containing the audio actions
2291 * for this look and feel.
2292 * <P>
2293 * The returned <code>ActionMap</code> contains <code>Actions</code> that
2294 * embody the ability to render an auditory cue. These auditory
2295 * cues map onto user and system activities that may be useful
2296 * for an end user to know about (such as a dialog box appearing).
2297 * <P>
2298 * At the appropriate time,
2299 * the {@code ComponentUI} is responsible for obtaining an
2300 * <code>Action</code> out of the <code>ActionMap</code> and passing
2301 * it to <code>playSound</code>.
2302 * <P>
2303 * This method first looks up the {@code ActionMap} from the
2304 * defaults using the key {@code "AuditoryCues.actionMap"}.
2305 * <p>
2306 * If the value is {@code non-null}, it is returned. If the value
2307 * of the default {@code "AuditoryCues.actionMap"} is {@code null}
2308 * and the value of the default {@code "AuditoryCues.cueList"} is
2309 * {@code non-null}, an {@code ActionMapUIResource} is created and
2310 * populated. Population is done by iterating over each of the
2311 * elements of the {@code "AuditoryCues.cueList"} array, and
2312 * invoking {@code createAudioAction()} to create an {@code
2313 * Action} for each element. The resulting {@code Action} is
2314 * placed in the {@code ActionMapUIResource}, using the array
2315 * element as the key. For example, if the {@code
2316 * "AuditoryCues.cueList"} array contains a single-element, {@code
2317 * "audioKey"}, the {@code ActionMapUIResource} is created, then
2318 * populated by way of {@code actionMap.put(cueList[0],
2319 * createAudioAction(cueList[0]))}.
2320 * <p>
2321 * If the value of the default {@code "AuditoryCues.actionMap"} is
2322 * {@code null} and the value of the default
2323 * {@code "AuditoryCues.cueList"} is {@code null}, an empty
2324 * {@code ActionMapUIResource} is created.
2325 *
2326 *
2327 * @return an ActionMap containing {@code Actions}
2328 * responsible for playing auditory cues
2329 * @throws ClassCastException if the value of the
2330 * default {@code "AuditoryCues.actionMap"} is not an
2331 * {@code ActionMap}, or the value of the default
2332 * {@code "AuditoryCues.cueList"} is not an {@code Object[]}
2333 * @see #createAudioAction
2334 * @see #playSound(Action)
2335 * @since 1.4
2336 */
2337 protected ActionMap getAudioActionMap() {
2338 ActionMap audioActionMap = (ActionMap) UIManager
2339 .get("AuditoryCues.actionMap");
2340 if (audioActionMap == null) {
2341 Object[] acList = (Object[]) UIManager
2342 .get("AuditoryCues.cueList");
2343 if (acList != null) {
2344 audioActionMap = new ActionMapUIResource();
2345 for (int counter = acList.length - 1; counter >= 0; counter--) {
2346 audioActionMap.put(acList[counter],
2347 createAudioAction(acList[counter]));
2348 }
2349 }
2350 UIManager.getLookAndFeelDefaults().put(
2351 "AuditoryCues.actionMap", audioActionMap);
2352 }
2353 return audioActionMap;
2354 }
2355
2356 /**
2357 * Creates and returns an {@code Action} used to play a sound.
2358 * <p>
2359 * If {@code key} is {@code non-null}, an {@code Action} is created
2360 * using the value from the defaults with key {@code key}. The value
2361 * identifies the sound resource to load when
2362 * {@code actionPerformed} is invoked on the {@code Action}. The
2363 * sound resource is loaded into a {@code byte[]} by way of
2364 * {@code getClass().getResourceAsStream()}.
2365 *
2366 * @param key the key identifying the audio action
2367 * @return an {@code Action} used to play the source, or {@code null}
2368 * if {@code key} is {@code null}
2369 * @see #playSound(Action)
2370 * @since 1.4
2371 */
2372 protected Action createAudioAction(Object key) {
2373 if (key != null) {
2374 String audioKey = (String) key;
2375 String audioValue = (String) UIManager.get(key);
2376 return new AudioAction(audioKey, audioValue);
2377 } else {
2378 return null;
2379 }
2380 }
2381
2382 /**
2383 * Pass the name String to the super constructor. This is used
2384 * later to identify the Action and decide whether to play it or
2385 * not. Store the resource String. I is used to get the audio
2386 * resource. In this case, the resource is an audio file.
2387 *
2388 * @since 1.4
2389 */
2390 private class AudioAction extends AbstractAction implements
2391 LineListener {
2392 // We strive to only play one sound at a time (other platforms
2393 // appear to do this). This is done by maintaining the field
2394 // clipPlaying. Every time a sound is to be played,
2395 // cancelCurrentSound is invoked to cancel any sound that may be
2396 // playing.
2397 private String audioResource;
2398 private byte[] audioBuffer;
2399
2400 /**
2401 * The String is the name of the Action and
2402 * points to the audio resource.
2403 * The byte[] is a buffer of the audio bits.
2404 */
2405 public AudioAction(String name, String resource) {
2406 super (name);
2407 audioResource = resource;
2408 }
2409
2410 public void actionPerformed(ActionEvent e) {
2411 if (audioBuffer == null) {
2412 audioBuffer = loadAudioData(audioResource);
2413 }
2414 if (audioBuffer != null) {
2415 cancelCurrentSound(null);
2416 try {
2417 AudioInputStream soundStream = AudioSystem
2418 .getAudioInputStream(new ByteArrayInputStream(
2419 audioBuffer));
2420 DataLine.Info info = new DataLine.Info(Clip.class,
2421 soundStream.getFormat());
2422 Clip clip = (Clip) AudioSystem.getLine(info);
2423 clip.open(soundStream);
2424 clip.addLineListener(this );
2425
2426 synchronized (audioLock) {
2427 clipPlaying = clip;
2428 }
2429
2430 clip.start();
2431 } catch (Exception ex) {
2432 }
2433 }
2434 }
2435
2436 public void update(LineEvent event) {
2437 if (event.getType() == LineEvent.Type.STOP) {
2438 cancelCurrentSound((Clip) event.getLine());
2439 }
2440 }
2441
2442 /**
2443 * If the parameter is null, or equal to the currently
2444 * playing sound, then cancel the currently playing sound.
2445 */
2446 private void cancelCurrentSound(Clip clip) {
2447 Clip lastClip = null;
2448
2449 synchronized (audioLock) {
2450 if (clip == null || clip == clipPlaying) {
2451 lastClip = clipPlaying;
2452 clipPlaying = null;
2453 }
2454 }
2455
2456 if (lastClip != null) {
2457 lastClip.removeLineListener(this );
2458 lastClip.close();
2459 }
2460 }
2461 }
2462
2463 /**
2464 * Utility method that loads audio bits for the specified
2465 * <code>soundFile</code> filename. If this method is unable to
2466 * build a viable path name from the <code>baseClass</code> and
2467 * <code>soundFile</code> passed into this method, it will
2468 * return <code>null</code>.
2469 *
2470 * @param baseClass used as the root class/location to get the
2471 * soundFile from
2472 * @param soundFile the name of the audio file to be retrieved
2473 * from disk
2474 * @return A byte[] with audio data or null
2475 * @since 1.4
2476 */
2477 private byte[] loadAudioData(final String soundFile) {
2478 if (soundFile == null) {
2479 return null;
2480 }
2481 /* Copy resource into a byte array. This is
2482 * necessary because several browsers consider
2483 * Class.getResource a security risk since it
2484 * can be used to load additional classes.
2485 * Class.getResourceAsStream just returns raw
2486 * bytes, which we can convert to a sound.
2487 */
2488 byte[] buffer = (byte[]) AccessController
2489 .doPrivileged(new PrivilegedAction() {
2490 public Object run() {
2491 try {
2492 InputStream resource = BasicLookAndFeel.this
2493 .getClass().getResourceAsStream(
2494 soundFile);
2495 if (resource == null) {
2496 return null;
2497 }
2498 BufferedInputStream in = new BufferedInputStream(
2499 resource);
2500 ByteArrayOutputStream out = new ByteArrayOutputStream(
2501 1024);
2502 byte[] buffer = new byte[1024];
2503 int n;
2504 while ((n = in.read(buffer)) > 0) {
2505 out.write(buffer, 0, n);
2506 }
2507 in.close();
2508 out.flush();
2509 buffer = out.toByteArray();
2510 return buffer;
2511 } catch (IOException ioe) {
2512 System.err.println(ioe.toString());
2513 return null;
2514 }
2515 }
2516 });
2517 if (buffer == null) {
2518 System.err.println(getClass().getName() + "/" + soundFile
2519 + " not found.");
2520 return null;
2521 }
2522 if (buffer.length == 0) {
2523 System.err.println("warning: " + soundFile
2524 + " is zero-length");
2525 return null;
2526 }
2527 return buffer;
2528 }
2529
2530 /**
2531 * If necessary, invokes {@code actionPerformed} on
2532 * {@code audioAction} to play a sound.
2533 * The {@code actionPerformed} method is invoked if the value of
2534 * the {@code "AuditoryCues.playList"} default is a {@code
2535 * non-null} {@code Object[]} containing a {@code String} entry
2536 * equal to the name of the {@code audioAction}.
2537 *
2538 * @param audioAction an Action that knows how to render the audio
2539 * associated with the system or user activity
2540 * that is occurring; a value of {@code null}, is
2541 * ignored
2542 * @throws ClassCastException if {@code audioAction} is {@code non-null}
2543 * and the value of the default {@code "AuditoryCues.playList"}
2544 * is not an {@code Object[]}
2545 * @since 1.4
2546 */
2547 protected void playSound(Action audioAction) {
2548 if (audioAction != null) {
2549 Object[] audioStrings = (Object[]) UIManager
2550 .get("AuditoryCues.playList");
2551 if (audioStrings != null) {
2552 // create a HashSet to help us decide to play or not
2553 HashSet audioCues = new HashSet();
2554 for (int i = 0; i < audioStrings.length; i++) {
2555 audioCues.add(audioStrings[i]);
2556 }
2557 // get the name of the Action
2558 String actionName = (String) audioAction
2559 .getValue(Action.NAME);
2560 // if the actionName is in the audioCues HashSet, play it.
2561 if (audioCues.contains(actionName)) {
2562 audioAction.actionPerformed(new ActionEvent(this ,
2563 ActionEvent.ACTION_PERFORMED, actionName));
2564 }
2565 }
2566 }
2567 }
2568
2569 /**
2570 * Sets the parent of the passed in ActionMap to be the audio action
2571 * map.
2572 */
2573 static void installAudioActionMap(ActionMap map) {
2574 LookAndFeel laf = UIManager.getLookAndFeel();
2575 if (laf instanceof BasicLookAndFeel) {
2576 map.setParent(((BasicLookAndFeel) laf).getAudioActionMap());
2577 }
2578 }
2579
2580 /**
2581 * Helper method to play a named sound.
2582 *
2583 * @param c JComponent to play the sound for.
2584 * @param actionKey Key for the sound.
2585 */
2586 static void playSound(JComponent c, Object actionKey) {
2587 LookAndFeel laf = UIManager.getLookAndFeel();
2588 if (laf instanceof BasicLookAndFeel) {
2589 ActionMap map = c.getActionMap();
2590 if (map != null) {
2591 Action audioAction = map.get(actionKey);
2592 if (audioAction != null) {
2593 // pass off firing the Action to a utility method
2594 ((BasicLookAndFeel) laf).playSound(audioAction);
2595 }
2596 }
2597 }
2598 }
2599
2600 /**
2601 * This class contains listener that watches for all the mouse
2602 * events that can possibly invoke popup on the component
2603 */
2604 class AWTEventHelper implements AWTEventListener, PrivilegedAction {
2605 AWTEventHelper() {
2606 super ();
2607 AccessController.doPrivileged(this );
2608 }
2609
2610 public Object run() {
2611 Toolkit tk = Toolkit.getDefaultToolkit();
2612 if (invocator == null) {
2613 tk.addAWTEventListener(this , AWTEvent.MOUSE_EVENT_MASK);
2614 } else {
2615 tk.removeAWTEventListener(invocator);
2616 }
2617 // Return value not used.
2618 return null;
2619 }
2620
2621 public void eventDispatched(AWTEvent ev) {
2622 int eventID = ev.getID();
2623 if ((eventID & AWTEvent.MOUSE_EVENT_MASK) != 0) {
2624 MouseEvent me = (MouseEvent) ev;
2625 if (me.isPopupTrigger()) {
2626 MenuElement[] elems = MenuSelectionManager
2627 .defaultManager().getSelectedPath();
2628 if (elems != null && elems.length != 0) {
2629 return;
2630 // We shall not interfere with already opened menu
2631 }
2632 Object c = me.getSource();
2633 JComponent src = null;
2634 if (c instanceof JComponent) {
2635 src = (JComponent) c;
2636 } else if (c instanceof BasicSplitPaneDivider) {
2637 // Special case - if user clicks on divider we must
2638 // invoke popup from the SplitPane
2639 src = (JComponent) ((BasicSplitPaneDivider) c)
2640 .getParent();
2641 }
2642 if (src != null) {
2643 if (src.getComponentPopupMenu() != null) {
2644 Point pt = src.getPopupLocation(me);
2645 if (pt == null) {
2646 pt = me.getPoint();
2647 pt = SwingUtilities.convertPoint(
2648 (Component) c, pt, src);
2649 }
2650 src.getComponentPopupMenu().show(src, pt.x,
2651 pt.y);
2652 me.consume();
2653 }
2654 }
2655 }
2656 }
2657 /* Activate a JInternalFrame if necessary. */
2658 if (eventID == MouseEvent.MOUSE_PRESSED) {
2659 Object object = ev.getSource();
2660 if (!(object instanceof Component)) {
2661 return;
2662 }
2663 Component component = (Component) object;
2664 if (component != null) {
2665 Component parent = component;
2666 while (parent != null
2667 && !(parent instanceof Window)) {
2668 if (parent instanceof JInternalFrame) {
2669 // Activate the frame.
2670 try {
2671 ((JInternalFrame) parent)
2672 .setSelected(true);
2673 } catch (PropertyVetoException e1) {
2674 }
2675 }
2676 parent = parent.getParent();
2677 }
2678 }
2679 }
2680 }
2681 }
2682 }
|