0001 /*
0002 * Copyright 1998-2006 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.metal;
0027
0028 import java.awt.*;
0029 import java.beans.PropertyChangeEvent;
0030 import java.beans.PropertyChangeListener;
0031 import javax.swing.plaf.*;
0032 import javax.swing.*;
0033 import javax.swing.plaf.basic.*;
0034 import javax.swing.text.DefaultEditorKit;
0035
0036 import java.awt.Color;
0037 import java.awt.event.KeyEvent;
0038 import java.lang.reflect.*;
0039 import java.lang.ref.ReferenceQueue;
0040 import java.lang.ref.WeakReference;
0041
0042 import java.security.AccessController;
0043 import java.security.PrivilegedAction;
0044
0045 import sun.awt.*;
0046 import sun.security.action.GetPropertyAction;
0047 import sun.swing.DefaultLayoutStyle;
0048 import sun.swing.SwingLazyValue;
0049 import sun.swing.SwingUtilities2;
0050
0051 /**
0052 * The Java Look and Feel, otherwise known as Metal.
0053 * <p>
0054 * Each of the {@code ComponentUI}s provided by {@code
0055 * MetalLookAndFeel} derives its behavior from the defaults
0056 * table. Unless otherwise noted each of the {@code ComponentUI}
0057 * implementations in this package document the set of defaults they
0058 * use. Unless otherwise noted the defaults are installed at the time
0059 * {@code installUI} is invoked, and follow the recommendations
0060 * outlined in {@code LookAndFeel} for installing defaults.
0061 * <p>
0062 * {@code MetalLookAndFeel} derives it's color palette and fonts from
0063 * {@code MetalTheme}. The default theme is {@code OceanTheme}. The theme
0064 * can be changed using the {@code setCurrentTheme} method, refer to it
0065 * for details on changing the theme. Prior to 1.5 the default
0066 * theme was {@code DefaultMetalTheme}. The system property
0067 * {@code "swing.metalTheme"} can be set to {@code "steel"} to indicate
0068 * the default should be {@code DefaultMetalTheme}.
0069 * <p>
0070 * <strong>Warning:</strong>
0071 * Serialized objects of this class will not be compatible with
0072 * future Swing releases. The current serialization support is
0073 * appropriate for short term storage or RMI between applications running
0074 * the same version of Swing. As of 1.4, support for long term storage
0075 * of all JavaBeans<sup><font size="-2">TM</font></sup>
0076 * has been added to the <code>java.beans</code> package.
0077 * Please see {@link java.beans.XMLEncoder}.
0078 *
0079 * @see MetalTheme
0080 * @see DefaultMetalTheme
0081 * @see OceanTheme
0082 *
0083 * @version @(#)MetalLookAndFeel.java 1.213 07/06/07
0084 * @author Steve Wilson
0085 */
0086 public class MetalLookAndFeel extends BasicLookAndFeel {
0087
0088 private static boolean METAL_LOOK_AND_FEEL_INITED = false;
0089
0090 private static MetalTheme currentTheme;
0091 private static boolean isOnlyOneContext = true;
0092 private static AppContext cachedAppContext;
0093
0094 /**
0095 * True if checked for windows yet.
0096 */
0097 private static boolean checkedWindows;
0098 /**
0099 * True if running on Windows.
0100 */
0101 private static boolean isWindows;
0102
0103 /**
0104 * Set to true first time we've checked swing.useSystemFontSettings.
0105 */
0106 private static boolean checkedSystemFontSettings;
0107
0108 /**
0109 * True indicates we should use system fonts, unless the developer has
0110 * specified otherwise with Application.useSystemFontSettings.
0111 */
0112 private static boolean useSystemFonts;
0113
0114 /**
0115 * Returns true if running on Windows.
0116 */
0117 static boolean isWindows() {
0118 if (!checkedWindows) {
0119 OSInfo.OSType osType = AccessController.doPrivileged(OSInfo
0120 .getOSTypeAction());
0121 if (osType == OSInfo.OSType.WINDOWS) {
0122 isWindows = true;
0123 String systemFonts = AccessController
0124 .doPrivileged(new GetPropertyAction(
0125 "swing.useSystemFontSettings"));
0126 useSystemFonts = (systemFonts != null && (Boolean
0127 .valueOf(systemFonts).booleanValue()));
0128 }
0129 checkedWindows = true;
0130 }
0131 return isWindows;
0132 }
0133
0134 /**
0135 * Returns true if system fonts should be used, this is only useful
0136 * for windows.
0137 */
0138 static boolean useSystemFonts() {
0139 if (isWindows() && useSystemFonts) {
0140 if (METAL_LOOK_AND_FEEL_INITED) {
0141 Object value = UIManager
0142 .get("Application.useSystemFontSettings");
0143
0144 return (value == null || Boolean.TRUE.equals(value));
0145 }
0146 // If an instanceof MetalLookAndFeel hasn't been inited yet, we
0147 // don't want to trigger loading of a UI by asking the UIManager
0148 // for a property, assume the user wants system fonts. This will
0149 // be properly adjusted when install is invoked on the
0150 // MetalTheme
0151 return true;
0152 }
0153 return false;
0154 }
0155
0156 /**
0157 * Returns true if the high contrast theme should be used as the default
0158 * theme.
0159 */
0160 private static boolean useHighContrastTheme() {
0161 if (isWindows() && useSystemFonts()) {
0162 Boolean highContrast = (Boolean) Toolkit
0163 .getDefaultToolkit().getDesktopProperty(
0164 "win.highContrast.on");
0165
0166 return (highContrast == null) ? false : highContrast
0167 .booleanValue();
0168 }
0169 return false;
0170 }
0171
0172 /**
0173 * Returns true if we're using the Ocean Theme.
0174 */
0175 static boolean usingOcean() {
0176 return (getCurrentTheme() instanceof OceanTheme);
0177 }
0178
0179 /**
0180 * Returns the name of this look and feel. This returns
0181 * {@code "Metal"}.
0182 *
0183 * @return the name of this look and feel
0184 */
0185 public String getName() {
0186 return "Metal";
0187 }
0188
0189 /**
0190 * Returns an identifier for this look and feel. This returns
0191 * {@code "Metal"}.
0192 *
0193 * @return the identifier of this look and feel
0194 */
0195 public String getID() {
0196 return "Metal";
0197 }
0198
0199 /**
0200 * Returns a short description of this look and feel. This returns
0201 * {@code "The Java(tm) Look and Feel"}.
0202
0203 * @return a short description for the look and feel
0204 */
0205 public String getDescription() {
0206 return "The Java(tm) Look and Feel";
0207 }
0208
0209 /**
0210 * Returns {@code false}; {@code MetalLookAndFeel} is not a native
0211 * look and feel.
0212 *
0213 * @return {@code false}
0214 */
0215 public boolean isNativeLookAndFeel() {
0216 return false;
0217 }
0218
0219 /**
0220 * Returns {@code true}; {@code MetalLookAndFeel} can be run on
0221 * any platform.
0222 *
0223 * @return {@code true}
0224 */
0225 public boolean isSupportedLookAndFeel() {
0226 return true;
0227 }
0228
0229 /**
0230 * Returns {@code true}; metal can provide {@code Window}
0231 * decorations.
0232 *
0233 * @return {@code true}
0234 *
0235 * @see JDialog#setDefaultLookAndFeelDecorated
0236 * @see JFrame#setDefaultLookAndFeelDecorated
0237 * @see JRootPane#setWindowDecorationStyle
0238 * @since 1.4
0239 */
0240 public boolean getSupportsWindowDecorations() {
0241 return true;
0242 }
0243
0244 /**
0245 * Populates {@code table} with mappings from {@code uiClassID} to
0246 * the fully qualified name of the ui class. {@code
0247 * MetalLookAndFeel} registers an entry for each of the classes in
0248 * the package {@code javax.swing.plaf.metal} that are named
0249 * MetalXXXUI. The string {@code XXX} is one of Swing's uiClassIDs. For
0250 * the {@code uiClassIDs} that do not have a class in metal, the
0251 * corresponding class in {@code javax.swing.plaf.basic} is
0252 * used. For example, metal does not have a class named {@code
0253 * "MetalColorChooserUI"}, as such, {@code
0254 * javax.swing.plaf.basic.BasicColorChooserUI} is used.
0255 *
0256 * @param table the {@code UIDefaults} instance the entries are
0257 * added to
0258 * @throws NullPointerException if {@code table} is {@code null}
0259 *
0260 * @see javax.swing.plaf.basic.BasicLookAndFeel#initClassDefaults
0261 */
0262 protected void initClassDefaults(UIDefaults table) {
0263 super .initClassDefaults(table);
0264 final String metalPackageName = "javax.swing.plaf.metal.";
0265
0266 Object[] uiDefaults = { "ButtonUI",
0267 metalPackageName + "MetalButtonUI", "CheckBoxUI",
0268 metalPackageName + "MetalCheckBoxUI", "ComboBoxUI",
0269 metalPackageName + "MetalComboBoxUI", "DesktopIconUI",
0270 metalPackageName + "MetalDesktopIconUI",
0271 "FileChooserUI",
0272 metalPackageName + "MetalFileChooserUI",
0273 "InternalFrameUI",
0274 metalPackageName + "MetalInternalFrameUI", "LabelUI",
0275 metalPackageName + "MetalLabelUI",
0276 "PopupMenuSeparatorUI",
0277 metalPackageName + "MetalPopupMenuSeparatorUI",
0278 "ProgressBarUI",
0279 metalPackageName + "MetalProgressBarUI",
0280 "RadioButtonUI",
0281 metalPackageName + "MetalRadioButtonUI", "ScrollBarUI",
0282 metalPackageName + "MetalScrollBarUI", "ScrollPaneUI",
0283 metalPackageName + "MetalScrollPaneUI", "SeparatorUI",
0284 metalPackageName + "MetalSeparatorUI", "SliderUI",
0285 metalPackageName + "MetalSliderUI", "SplitPaneUI",
0286 metalPackageName + "MetalSplitPaneUI", "TabbedPaneUI",
0287 metalPackageName + "MetalTabbedPaneUI", "TextFieldUI",
0288 metalPackageName + "MetalTextFieldUI",
0289 "ToggleButtonUI",
0290 metalPackageName + "MetalToggleButtonUI", "ToolBarUI",
0291 metalPackageName + "MetalToolBarUI", "ToolTipUI",
0292 metalPackageName + "MetalToolTipUI", "TreeUI",
0293 metalPackageName + "MetalTreeUI", "RootPaneUI",
0294 metalPackageName + "MetalRootPaneUI", };
0295
0296 table.putDefaults(uiDefaults);
0297 }
0298
0299 /**
0300 * Populates {@code table} with system colors. The following values are
0301 * added to {@code table}:
0302 * <table border="1" cellpadding="1" cellspacing="0"
0303 * summary="Metal's system color mapping"
0304 * valign="top" >
0305 * <tr valign="top" align="left">
0306 * <th bgcolor="#CCCCFF" align="left">Key
0307 * <th bgcolor="#CCCCFF" align="left">Value
0308 * <tr valign="top" align="left">
0309 * <td>"desktop"
0310 * <td>{@code theme.getDesktopColor()}
0311 * <tr valign="top" align="left">
0312 * <td>"activeCaption"
0313 * <td>{@code theme.getWindowTitleBackground()}
0314 * <tr valign="top" align="left">
0315 * <td>"activeCaptionText"
0316 * <td>{@code theme.getWindowTitleForeground()}
0317 * <tr valign="top" align="left">
0318 * <td>"activeCaptionBorder"
0319 * <td>{@code theme.getPrimaryControlShadow()}
0320 * <tr valign="top" align="left">
0321 * <td>"inactiveCaption"
0322 * <td>{@code theme.getWindowTitleInactiveBackground()}
0323 * <tr valign="top" align="left">
0324 * <td>"inactiveCaptionText"
0325 * <td>{@code theme.getWindowTitleInactiveForeground()}
0326 * <tr valign="top" align="left">
0327 * <td>"inactiveCaptionBorder"
0328 * <td>{@code theme.getControlShadow()}
0329 * <tr valign="top" align="left">
0330 * <td>"window"
0331 * <td>{@code theme.getWindowBackground()}
0332 * <tr valign="top" align="left">
0333 * <td>"windowBorder"
0334 * <td>{@code theme.getControl()}
0335 * <tr valign="top" align="left">
0336 * <td>"windowText"
0337 * <td>{@code theme.getUserTextColor()}
0338 * <tr valign="top" align="left">
0339 * <td>"menu"
0340 * <td>{@code theme.getMenuBackground()}
0341 * <tr valign="top" align="left">
0342 * <td>"menuText"
0343 * <td>{@code theme.getMenuForeground()}
0344 * <tr valign="top" align="left">
0345 * <td>"text"
0346 * <td>{@code theme.getWindowBackground()}
0347 * <tr valign="top" align="left">
0348 * <td>"textText"
0349 * <td>{@code theme.getUserTextColor()}
0350 * <tr valign="top" align="left">
0351 * <td>"textHighlight"
0352 * <td>{@code theme.getTextHighlightColor()}
0353 * <tr valign="top" align="left">
0354 * <td>"textHighlightText"
0355 * <td>{@code theme.getHighlightedTextColor()}
0356 * <tr valign="top" align="left">
0357 * <td>"textInactiveText"
0358 * <td>{@code theme.getInactiveSystemTextColor()}
0359 * <tr valign="top" align="left">
0360 * <td>"control"
0361 * <td>{@code theme.getControl()}
0362 * <tr valign="top" align="left">
0363 * <td>"controlText"
0364 * <td>{@code theme.getControlTextColor()}
0365 * <tr valign="top" align="left">
0366 * <td>"controlHighlight"
0367 * <td>{@code theme.getControlHighlight()}
0368 * <tr valign="top" align="left">
0369 * <td>"controlLtHighlight"
0370 * <td>{@code theme.getControlHighlight()}
0371 * <tr valign="top" align="left">
0372 * <td>"controlShadow"
0373 * <td>{@code theme.getControlShadow()}
0374 * <tr valign="top" align="left">
0375 * <td>"controlDkShadow"
0376 * <td>{@code theme.getControlDarkShadow()}
0377 * <tr valign="top" align="left">
0378 * <td>"scrollbar"
0379 * <td>{@code theme.getControl()}
0380 * <tr valign="top" align="left">
0381 * <td>"info"
0382 * <td>{@code theme.getPrimaryControl()}
0383 * <tr valign="top" align="left">
0384 * <td>"infoText"
0385 * <td>{@code theme.getPrimaryControlInfo()}
0386 * </table>
0387 * The value {@code theme} corresponds to the current {@code MetalTheme}.
0388 *
0389 * @param table the {@code UIDefaults} object the values are added to
0390 * @throws NullPointerException if {@code table} is {@code null}
0391 */
0392 protected void initSystemColorDefaults(UIDefaults table) {
0393 MetalTheme theme = getCurrentTheme();
0394 Color control = theme.getControl();
0395 Object[] systemColors = { "desktop", theme.getDesktopColor(), /* Color of the desktop background */
0396 "activeCaption", theme.getWindowTitleBackground(), /* Color for captions (title bars) when they are active. */
0397 "activeCaptionText", theme.getWindowTitleForeground(), /* Text color for text in captions (title bars). */
0398 "activeCaptionBorder", theme.getPrimaryControlShadow(), /* Border color for caption (title bar) window borders. */
0399 "inactiveCaption", theme.getWindowTitleInactiveBackground(), /* Color for captions (title bars) when not active. */
0400 "inactiveCaptionText",
0401 theme.getWindowTitleInactiveForeground(), /* Text color for text in inactive captions (title bars). */
0402 "inactiveCaptionBorder", theme.getControlShadow(), /* Border color for inactive caption (title bar) window borders. */
0403 "window", theme.getWindowBackground(), /* Default color for the interior of windows */
0404 "windowBorder", control, /* ??? */
0405 "windowText", theme.getUserTextColor(), /* ??? */
0406 "menu", theme.getMenuBackground(), /* Background color for menus */
0407 "menuText", theme.getMenuForeground(), /* Text color for menus */
0408 "text", theme.getWindowBackground(), /* Text background color */
0409 "textText", theme.getUserTextColor(), /* Text foreground color */
0410 "textHighlight", theme.getTextHighlightColor(), /* Text background color when selected */
0411 "textHighlightText", theme.getHighlightedTextColor(), /* Text color when selected */
0412 "textInactiveText", theme.getInactiveSystemTextColor(), /* Text color when disabled */
0413 "control", control, /* Default color for controls (buttons, sliders, etc) */
0414 "controlText", theme.getControlTextColor(), /* Default color for text in controls */
0415 "controlHighlight", theme.getControlHighlight(), /* Specular highlight (opposite of the shadow) */
0416 "controlLtHighlight", theme.getControlHighlight(), /* Highlight color for controls */
0417 "controlShadow", theme.getControlShadow(), /* Shadow color for controls */
0418 "controlDkShadow", theme.getControlDarkShadow(), /* Dark shadow color for controls */
0419 "scrollbar", control, /* Scrollbar background (usually the "track") */
0420 "info", theme.getPrimaryControl(), /* ToolTip Background */
0421 "infoText", theme.getPrimaryControlInfo() /* ToolTip Text */
0422 };
0423
0424 table.putDefaults(systemColors);
0425 }
0426
0427 /**
0428 * Initialize the defaults table with the name of the ResourceBundle
0429 * used for getting localized defaults.
0430 */
0431 private void initResourceBundle(UIDefaults table) {
0432 table
0433 .addResourceBundle("com.sun.swing.internal.plaf.metal.resources.metal");
0434 }
0435
0436 /**
0437 * Populates {@code table} with the defaults for metal.
0438 *
0439 * @param table the {@code UIDefaults} to add the values to
0440 * @throws NullPointerException if {@code table} is {@code null}
0441 */
0442 protected void initComponentDefaults(UIDefaults table) {
0443 super .initComponentDefaults(table);
0444
0445 initResourceBundle(table);
0446
0447 Color acceleratorForeground = getAcceleratorForeground();
0448 Color acceleratorSelectedForeground = getAcceleratorSelectedForeground();
0449 Color control = getControl();
0450 Color controlHighlight = getControlHighlight();
0451 Color controlShadow = getControlShadow();
0452 Color controlDarkShadow = getControlDarkShadow();
0453 Color controlTextColor = getControlTextColor();
0454 Color focusColor = getFocusColor();
0455 Color inactiveControlTextColor = getInactiveControlTextColor();
0456 Color menuBackground = getMenuBackground();
0457 Color menuSelectedBackground = getMenuSelectedBackground();
0458 Color menuDisabledForeground = getMenuDisabledForeground();
0459 Color menuSelectedForeground = getMenuSelectedForeground();
0460 Color primaryControl = getPrimaryControl();
0461 Color primaryControlDarkShadow = getPrimaryControlDarkShadow();
0462 Color primaryControlShadow = getPrimaryControlShadow();
0463 Color systemTextColor = getSystemTextColor();
0464
0465 Insets zeroInsets = new InsetsUIResource(0, 0, 0, 0);
0466
0467 Integer zero = new Integer(0);
0468
0469 Object textFieldBorder = new SwingLazyValue(
0470 "javax.swing.plaf.metal.MetalBorders",
0471 "getTextFieldBorder");
0472
0473 Object dialogBorder = new MetalLazyValue(
0474 "javax.swing.plaf.metal.MetalBorders$DialogBorder");
0475
0476 Object questionDialogBorder = new MetalLazyValue(
0477 "javax.swing.plaf.metal.MetalBorders$QuestionDialogBorder");
0478
0479 Object fieldInputMap = new UIDefaults.LazyInputMap(
0480 new Object[] { "ctrl C", DefaultEditorKit.copyAction,
0481 "ctrl V", DefaultEditorKit.pasteAction,
0482 "ctrl X", DefaultEditorKit.cutAction, "COPY",
0483 DefaultEditorKit.copyAction, "PASTE",
0484 DefaultEditorKit.pasteAction, "CUT",
0485 DefaultEditorKit.cutAction, "control INSERT",
0486 DefaultEditorKit.copyAction, "shift INSERT",
0487 DefaultEditorKit.pasteAction, "shift DELETE",
0488 DefaultEditorKit.cutAction, "shift LEFT",
0489 DefaultEditorKit.selectionBackwardAction,
0490 "shift KP_LEFT",
0491 DefaultEditorKit.selectionBackwardAction,
0492 "shift RIGHT",
0493 DefaultEditorKit.selectionForwardAction,
0494 "shift KP_RIGHT",
0495 DefaultEditorKit.selectionForwardAction,
0496 "ctrl LEFT",
0497 DefaultEditorKit.previousWordAction,
0498 "ctrl KP_LEFT",
0499 DefaultEditorKit.previousWordAction,
0500 "ctrl RIGHT", DefaultEditorKit.nextWordAction,
0501 "ctrl KP_RIGHT",
0502 DefaultEditorKit.nextWordAction,
0503 "ctrl shift LEFT",
0504 DefaultEditorKit.selectionPreviousWordAction,
0505 "ctrl shift KP_LEFT",
0506 DefaultEditorKit.selectionPreviousWordAction,
0507 "ctrl shift RIGHT",
0508 DefaultEditorKit.selectionNextWordAction,
0509 "ctrl shift KP_RIGHT",
0510 DefaultEditorKit.selectionNextWordAction,
0511 "ctrl A", DefaultEditorKit.selectAllAction,
0512 "HOME", DefaultEditorKit.beginLineAction,
0513 "END", DefaultEditorKit.endLineAction,
0514 "shift HOME",
0515 DefaultEditorKit.selectionBeginLineAction,
0516 "shift END",
0517 DefaultEditorKit.selectionEndLineAction,
0518 "BACK_SPACE",
0519 DefaultEditorKit.deletePrevCharAction,
0520 "shift BACK_SPACE",
0521 DefaultEditorKit.deletePrevCharAction,
0522 "ctrl H",
0523 DefaultEditorKit.deletePrevCharAction,
0524 "DELETE",
0525 DefaultEditorKit.deleteNextCharAction,
0526 "ctrl DELETE",
0527 DefaultEditorKit.deleteNextWordAction,
0528 "ctrl BACK_SPACE",
0529 DefaultEditorKit.deletePrevWordAction, "RIGHT",
0530 DefaultEditorKit.forwardAction, "LEFT",
0531 DefaultEditorKit.backwardAction, "KP_RIGHT",
0532 DefaultEditorKit.forwardAction, "KP_LEFT",
0533 DefaultEditorKit.backwardAction, "ENTER",
0534 JTextField.notifyAction, "ctrl BACK_SLASH",
0535 "unselect"/*DefaultEditorKit.unselectAction*/,
0536 "control shift O",
0537 "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
0538 });
0539
0540 Object passwordInputMap = new UIDefaults.LazyInputMap(
0541 new Object[] { "ctrl C", DefaultEditorKit.copyAction,
0542 "ctrl V", DefaultEditorKit.pasteAction,
0543 "ctrl X", DefaultEditorKit.cutAction, "COPY",
0544 DefaultEditorKit.copyAction, "PASTE",
0545 DefaultEditorKit.pasteAction, "CUT",
0546 DefaultEditorKit.cutAction, "control INSERT",
0547 DefaultEditorKit.copyAction, "shift INSERT",
0548 DefaultEditorKit.pasteAction, "shift DELETE",
0549 DefaultEditorKit.cutAction, "shift LEFT",
0550 DefaultEditorKit.selectionBackwardAction,
0551 "shift KP_LEFT",
0552 DefaultEditorKit.selectionBackwardAction,
0553 "shift RIGHT",
0554 DefaultEditorKit.selectionForwardAction,
0555 "shift KP_RIGHT",
0556 DefaultEditorKit.selectionForwardAction,
0557 "ctrl LEFT", DefaultEditorKit.beginLineAction,
0558 "ctrl KP_LEFT",
0559 DefaultEditorKit.beginLineAction, "ctrl RIGHT",
0560 DefaultEditorKit.endLineAction,
0561 "ctrl KP_RIGHT",
0562 DefaultEditorKit.endLineAction,
0563 "ctrl shift LEFT",
0564 DefaultEditorKit.selectionBeginLineAction,
0565 "ctrl shift KP_LEFT",
0566 DefaultEditorKit.selectionBeginLineAction,
0567 "ctrl shift RIGHT",
0568 DefaultEditorKit.selectionEndLineAction,
0569 "ctrl shift KP_RIGHT",
0570 DefaultEditorKit.selectionEndLineAction,
0571 "ctrl A", DefaultEditorKit.selectAllAction,
0572 "HOME", DefaultEditorKit.beginLineAction,
0573 "END", DefaultEditorKit.endLineAction,
0574 "shift HOME",
0575 DefaultEditorKit.selectionBeginLineAction,
0576 "shift END",
0577 DefaultEditorKit.selectionEndLineAction,
0578 "BACK_SPACE",
0579 DefaultEditorKit.deletePrevCharAction,
0580 "shift BACK_SPACE",
0581 DefaultEditorKit.deletePrevCharAction,
0582 "ctrl H",
0583 DefaultEditorKit.deletePrevCharAction,
0584 "DELETE",
0585 DefaultEditorKit.deleteNextCharAction, "RIGHT",
0586 DefaultEditorKit.forwardAction, "LEFT",
0587 DefaultEditorKit.backwardAction, "KP_RIGHT",
0588 DefaultEditorKit.forwardAction, "KP_LEFT",
0589 DefaultEditorKit.backwardAction, "ENTER",
0590 JTextField.notifyAction, "ctrl BACK_SLASH",
0591 "unselect"/*DefaultEditorKit.unselectAction*/,
0592 "control shift O",
0593 "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
0594 });
0595
0596 Object multilineInputMap = new UIDefaults.LazyInputMap(
0597 new Object[] { "ctrl C", DefaultEditorKit.copyAction,
0598 "ctrl V", DefaultEditorKit.pasteAction,
0599 "ctrl X", DefaultEditorKit.cutAction, "COPY",
0600 DefaultEditorKit.copyAction, "PASTE",
0601 DefaultEditorKit.pasteAction, "CUT",
0602 DefaultEditorKit.cutAction, "control INSERT",
0603 DefaultEditorKit.copyAction, "shift INSERT",
0604 DefaultEditorKit.pasteAction, "shift DELETE",
0605 DefaultEditorKit.cutAction, "shift LEFT",
0606 DefaultEditorKit.selectionBackwardAction,
0607 "shift KP_LEFT",
0608 DefaultEditorKit.selectionBackwardAction,
0609 "shift RIGHT",
0610 DefaultEditorKit.selectionForwardAction,
0611 "shift KP_RIGHT",
0612 DefaultEditorKit.selectionForwardAction,
0613 "ctrl LEFT",
0614 DefaultEditorKit.previousWordAction,
0615 "ctrl KP_LEFT",
0616 DefaultEditorKit.previousWordAction,
0617 "ctrl RIGHT", DefaultEditorKit.nextWordAction,
0618 "ctrl KP_RIGHT",
0619 DefaultEditorKit.nextWordAction,
0620 "ctrl shift LEFT",
0621 DefaultEditorKit.selectionPreviousWordAction,
0622 "ctrl shift KP_LEFT",
0623 DefaultEditorKit.selectionPreviousWordAction,
0624 "ctrl shift RIGHT",
0625 DefaultEditorKit.selectionNextWordAction,
0626 "ctrl shift KP_RIGHT",
0627 DefaultEditorKit.selectionNextWordAction,
0628 "ctrl A", DefaultEditorKit.selectAllAction,
0629 "HOME", DefaultEditorKit.beginLineAction,
0630 "END", DefaultEditorKit.endLineAction,
0631 "shift HOME",
0632 DefaultEditorKit.selectionBeginLineAction,
0633 "shift END",
0634 DefaultEditorKit.selectionEndLineAction,
0635
0636 "UP", DefaultEditorKit.upAction, "KP_UP",
0637 DefaultEditorKit.upAction, "DOWN",
0638 DefaultEditorKit.downAction, "KP_DOWN",
0639 DefaultEditorKit.downAction, "PAGE_UP",
0640 DefaultEditorKit.pageUpAction, "PAGE_DOWN",
0641 DefaultEditorKit.pageDownAction,
0642 "shift PAGE_UP", "selection-page-up",
0643 "shift PAGE_DOWN", "selection-page-down",
0644 "ctrl shift PAGE_UP", "selection-page-left",
0645 "ctrl shift PAGE_DOWN", "selection-page-right",
0646 "shift UP", DefaultEditorKit.selectionUpAction,
0647 "shift KP_UP",
0648 DefaultEditorKit.selectionUpAction,
0649 "shift DOWN",
0650 DefaultEditorKit.selectionDownAction,
0651 "shift KP_DOWN",
0652 DefaultEditorKit.selectionDownAction, "ENTER",
0653 DefaultEditorKit.insertBreakAction,
0654 "BACK_SPACE",
0655 DefaultEditorKit.deletePrevCharAction,
0656 "shift BACK_SPACE",
0657 DefaultEditorKit.deletePrevCharAction,
0658 "ctrl H",
0659 DefaultEditorKit.deletePrevCharAction,
0660 "DELETE",
0661 DefaultEditorKit.deleteNextCharAction,
0662 "ctrl DELETE",
0663 DefaultEditorKit.deleteNextWordAction,
0664 "ctrl BACK_SPACE",
0665 DefaultEditorKit.deletePrevWordAction, "RIGHT",
0666 DefaultEditorKit.forwardAction, "LEFT",
0667 DefaultEditorKit.backwardAction, "KP_RIGHT",
0668 DefaultEditorKit.forwardAction, "KP_LEFT",
0669 DefaultEditorKit.backwardAction, "TAB",
0670 DefaultEditorKit.insertTabAction,
0671 "ctrl BACK_SLASH",
0672 "unselect"/*DefaultEditorKit.unselectAction*/,
0673 "ctrl HOME", DefaultEditorKit.beginAction,
0674 "ctrl END", DefaultEditorKit.endAction,
0675 "ctrl shift HOME",
0676 DefaultEditorKit.selectionBeginAction,
0677 "ctrl shift END",
0678 DefaultEditorKit.selectionEndAction, "ctrl T",
0679 "next-link-action", "ctrl shift T",
0680 "previous-link-action", "ctrl SPACE",
0681 "activate-link-action", "control shift O",
0682 "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
0683 });
0684
0685 Object scrollPaneBorder = new SwingLazyValue(
0686 "javax.swing.plaf.metal.MetalBorders$ScrollPaneBorder");
0687 Object buttonBorder = new SwingLazyValue(
0688 "javax.swing.plaf.metal.MetalBorders",
0689 "getButtonBorder");
0690
0691 Object toggleButtonBorder = new SwingLazyValue(
0692 "javax.swing.plaf.metal.MetalBorders",
0693 "getToggleButtonBorder");
0694
0695 Object titledBorderBorder = new SwingLazyValue(
0696 "javax.swing.plaf.BorderUIResource$LineBorderUIResource",
0697 new Object[] { controlShadow });
0698
0699 Object desktopIconBorder = new SwingLazyValue(
0700 "javax.swing.plaf.metal.MetalBorders",
0701 "getDesktopIconBorder");
0702
0703 Object menuBarBorder = new SwingLazyValue(
0704 "javax.swing.plaf.metal.MetalBorders$MenuBarBorder");
0705
0706 Object popupMenuBorder = new SwingLazyValue(
0707 "javax.swing.plaf.metal.MetalBorders$PopupMenuBorder");
0708 Object menuItemBorder = new SwingLazyValue(
0709 "javax.swing.plaf.metal.MetalBorders$MenuItemBorder");
0710
0711 Object menuItemAcceleratorDelimiter = "-";
0712 Object toolBarBorder = new SwingLazyValue(
0713 "javax.swing.plaf.metal.MetalBorders$ToolBarBorder");
0714
0715 Object progressBarBorder = new SwingLazyValue(
0716 "javax.swing.plaf.BorderUIResource$LineBorderUIResource",
0717 new Object[] { controlDarkShadow, new Integer(1) });
0718
0719 Object toolTipBorder = new SwingLazyValue(
0720 "javax.swing.plaf.BorderUIResource$LineBorderUIResource",
0721 new Object[] { primaryControlDarkShadow });
0722
0723 Object toolTipBorderInactive = new SwingLazyValue(
0724 "javax.swing.plaf.BorderUIResource$LineBorderUIResource",
0725 new Object[] { controlDarkShadow });
0726
0727 Object focusCellHighlightBorder = new SwingLazyValue(
0728 "javax.swing.plaf.BorderUIResource$LineBorderUIResource",
0729 new Object[] { focusColor });
0730
0731 Object tabbedPaneTabAreaInsets = new InsetsUIResource(4, 2, 0,
0732 6);
0733
0734 Object tabbedPaneTabInsets = new InsetsUIResource(0, 9, 1, 9);
0735
0736 final Object[] internalFrameIconArgs = new Object[1];
0737 internalFrameIconArgs[0] = new Integer(16);
0738
0739 Object[] defaultCueList = new Object[] {
0740 "OptionPane.errorSound", "OptionPane.informationSound",
0741 "OptionPane.questionSound", "OptionPane.warningSound" };
0742
0743 MetalTheme theme = getCurrentTheme();
0744 Object menuTextValue = new FontActiveValue(theme,
0745 MetalTheme.MENU_TEXT_FONT);
0746 Object controlTextValue = new FontActiveValue(theme,
0747 MetalTheme.CONTROL_TEXT_FONT);
0748 Object userTextValue = new FontActiveValue(theme,
0749 MetalTheme.USER_TEXT_FONT);
0750 Object windowTitleValue = new FontActiveValue(theme,
0751 MetalTheme.WINDOW_TITLE_FONT);
0752 Object subTextValue = new FontActiveValue(theme,
0753 MetalTheme.SUB_TEXT_FONT);
0754 Object systemTextValue = new FontActiveValue(theme,
0755 MetalTheme.SYSTEM_TEXT_FONT);
0756 //
0757 // DEFAULTS TABLE
0758 //
0759
0760 Object[] defaults = {
0761 // *** Auditory Feedback
0762 "AuditoryCues.defaultCueList",
0763 defaultCueList,
0764 // this key defines which of the various cues to render
0765 // This is disabled until sound bugs can be resolved.
0766 "AuditoryCues.playList",
0767 null, // defaultCueList,
0768
0769 // Text (Note: many are inherited)
0770 "TextField.border",
0771 textFieldBorder,
0772 "TextField.font",
0773 userTextValue,
0774
0775 "PasswordField.border",
0776 textFieldBorder,
0777 // passwordField.font should actually map to
0778 // win.ansiFixed.font.height on windows.
0779 "PasswordField.font",
0780 userTextValue,
0781 "PasswordField.echoChar",
0782 (char) 0x2022,
0783
0784 // TextArea.font should actually map to win.ansiFixed.font.height
0785 // on windows.
0786 "TextArea.font",
0787 userTextValue,
0788
0789 "TextPane.background",
0790 table.get("window"),
0791 "TextPane.font",
0792 userTextValue,
0793
0794 "EditorPane.background",
0795 table.get("window"),
0796 "EditorPane.font",
0797 userTextValue,
0798
0799 "TextField.focusInputMap",
0800 fieldInputMap,
0801 "PasswordField.focusInputMap",
0802 passwordInputMap,
0803 "TextArea.focusInputMap",
0804 multilineInputMap,
0805 "TextPane.focusInputMap",
0806 multilineInputMap,
0807 "EditorPane.focusInputMap",
0808 multilineInputMap,
0809
0810 // FormattedTextFields
0811 "FormattedTextField.border",
0812 textFieldBorder,
0813 "FormattedTextField.font",
0814 userTextValue,
0815 "FormattedTextField.focusInputMap",
0816 new UIDefaults.LazyInputMap(new Object[] { "ctrl C",
0817 DefaultEditorKit.copyAction, "ctrl V",
0818 DefaultEditorKit.pasteAction, "ctrl X",
0819 DefaultEditorKit.cutAction, "COPY",
0820 DefaultEditorKit.copyAction, "PASTE",
0821 DefaultEditorKit.pasteAction, "CUT",
0822 DefaultEditorKit.cutAction, "control INSERT",
0823 DefaultEditorKit.copyAction, "shift INSERT",
0824 DefaultEditorKit.pasteAction, "shift DELETE",
0825 DefaultEditorKit.cutAction, "shift LEFT",
0826 DefaultEditorKit.selectionBackwardAction,
0827 "shift KP_LEFT",
0828 DefaultEditorKit.selectionBackwardAction,
0829 "shift RIGHT",
0830 DefaultEditorKit.selectionForwardAction,
0831 "shift KP_RIGHT",
0832 DefaultEditorKit.selectionForwardAction,
0833 "ctrl LEFT",
0834 DefaultEditorKit.previousWordAction,
0835 "ctrl KP_LEFT",
0836 DefaultEditorKit.previousWordAction,
0837 "ctrl RIGHT", DefaultEditorKit.nextWordAction,
0838 "ctrl KP_RIGHT",
0839 DefaultEditorKit.nextWordAction,
0840 "ctrl shift LEFT",
0841 DefaultEditorKit.selectionPreviousWordAction,
0842 "ctrl shift KP_LEFT",
0843 DefaultEditorKit.selectionPreviousWordAction,
0844 "ctrl shift RIGHT",
0845 DefaultEditorKit.selectionNextWordAction,
0846 "ctrl shift KP_RIGHT",
0847 DefaultEditorKit.selectionNextWordAction,
0848 "ctrl A", DefaultEditorKit.selectAllAction,
0849 "HOME", DefaultEditorKit.beginLineAction,
0850 "END", DefaultEditorKit.endLineAction,
0851 "shift HOME",
0852 DefaultEditorKit.selectionBeginLineAction,
0853 "shift END",
0854 DefaultEditorKit.selectionEndLineAction,
0855 "BACK_SPACE",
0856 DefaultEditorKit.deletePrevCharAction,
0857 "shift BACK_SPACE",
0858 DefaultEditorKit.deletePrevCharAction,
0859 "ctrl H",
0860 DefaultEditorKit.deletePrevCharAction,
0861 "DELETE",
0862 DefaultEditorKit.deleteNextCharAction,
0863 "ctrl DELETE",
0864 DefaultEditorKit.deleteNextWordAction,
0865 "ctrl BACK_SPACE",
0866 DefaultEditorKit.deletePrevWordAction, "RIGHT",
0867 DefaultEditorKit.forwardAction, "LEFT",
0868 DefaultEditorKit.backwardAction, "KP_RIGHT",
0869 DefaultEditorKit.forwardAction, "KP_LEFT",
0870 DefaultEditorKit.backwardAction, "ENTER",
0871 JTextField.notifyAction, "ctrl BACK_SLASH",
0872 "unselect", "control shift O",
0873 "toggle-componentOrientation", "ESCAPE",
0874 "reset-field-edit", "UP", "increment", "KP_UP",
0875 "increment", "DOWN", "decrement", "KP_DOWN",
0876 "decrement", }),
0877
0878 // Buttons
0879 "Button.defaultButtonFollowsFocus",
0880 Boolean.FALSE,
0881 "Button.disabledText",
0882 inactiveControlTextColor,
0883 "Button.select",
0884 controlShadow,
0885 "Button.border",
0886 buttonBorder,
0887 "Button.font",
0888 controlTextValue,
0889 "Button.focus",
0890 focusColor,
0891 "Button.focusInputMap",
0892 new UIDefaults.LazyInputMap(new Object[] { "SPACE",
0893 "pressed", "released SPACE", "released" }),
0894
0895 "CheckBox.disabledText",
0896 inactiveControlTextColor,
0897 "Checkbox.select",
0898 controlShadow,
0899 "CheckBox.font",
0900 controlTextValue,
0901 "CheckBox.focus",
0902 focusColor,
0903 "CheckBox.icon",
0904 new SwingLazyValue(
0905 "javax.swing.plaf.metal.MetalIconFactory",
0906 "getCheckBoxIcon"),
0907 "CheckBox.focusInputMap",
0908 new UIDefaults.LazyInputMap(new Object[] { "SPACE",
0909 "pressed", "released SPACE", "released" }),
0910 // margin is 2 all the way around, BasicBorders.RadioButtonBorder
0911 // (checkbox uses RadioButtonBorder) is 2 all the way around too.
0912 "CheckBox.totalInsets",
0913 new Insets(4, 4, 4, 4),
0914
0915 "RadioButton.disabledText",
0916 inactiveControlTextColor,
0917 "RadioButton.select",
0918 controlShadow,
0919 "RadioButton.icon",
0920 new SwingLazyValue(
0921 "javax.swing.plaf.metal.MetalIconFactory",
0922 "getRadioButtonIcon"),
0923 "RadioButton.font",
0924 controlTextValue,
0925 "RadioButton.focus",
0926 focusColor,
0927 "RadioButton.focusInputMap",
0928 new UIDefaults.LazyInputMap(new Object[] { "SPACE",
0929 "pressed", "released SPACE", "released" }),
0930 // margin is 2 all the way around, BasicBorders.RadioButtonBorder
0931 // is 2 all the way around too.
0932 "RadioButton.totalInsets",
0933 new Insets(4, 4, 4, 4),
0934
0935 "ToggleButton.select",
0936 controlShadow,
0937 "ToggleButton.disabledText",
0938 inactiveControlTextColor,
0939 "ToggleButton.focus",
0940 focusColor,
0941 "ToggleButton.border",
0942 toggleButtonBorder,
0943 "ToggleButton.font",
0944 controlTextValue,
0945 "ToggleButton.focusInputMap",
0946 new UIDefaults.LazyInputMap(new Object[] { "SPACE",
0947 "pressed", "released SPACE", "released" }),
0948
0949 // File View
0950 "FileView.directoryIcon",
0951 new SwingLazyValue(
0952 "javax.swing.plaf.metal.MetalIconFactory",
0953 "getTreeFolderIcon"),
0954 "FileView.fileIcon",
0955 new SwingLazyValue(
0956 "javax.swing.plaf.metal.MetalIconFactory",
0957 "getTreeLeafIcon"),
0958 "FileView.computerIcon",
0959 new SwingLazyValue(
0960 "javax.swing.plaf.metal.MetalIconFactory",
0961 "getTreeComputerIcon"),
0962 "FileView.hardDriveIcon",
0963 new SwingLazyValue(
0964 "javax.swing.plaf.metal.MetalIconFactory",
0965 "getTreeHardDriveIcon"),
0966 "FileView.floppyDriveIcon",
0967 new SwingLazyValue(
0968 "javax.swing.plaf.metal.MetalIconFactory",
0969 "getTreeFloppyDriveIcon"),
0970
0971 // File Chooser
0972 "FileChooser.detailsViewIcon",
0973 new SwingLazyValue(
0974 "javax.swing.plaf.metal.MetalIconFactory",
0975 "getFileChooserDetailViewIcon"),
0976 "FileChooser.homeFolderIcon",
0977 new SwingLazyValue(
0978 "javax.swing.plaf.metal.MetalIconFactory",
0979 "getFileChooserHomeFolderIcon"),
0980 "FileChooser.listViewIcon",
0981 new SwingLazyValue(
0982 "javax.swing.plaf.metal.MetalIconFactory",
0983 "getFileChooserListViewIcon"),
0984 "FileChooser.newFolderIcon",
0985 new SwingLazyValue(
0986 "javax.swing.plaf.metal.MetalIconFactory",
0987 "getFileChooserNewFolderIcon"),
0988 "FileChooser.upFolderIcon",
0989 new SwingLazyValue(
0990 "javax.swing.plaf.metal.MetalIconFactory",
0991 "getFileChooserUpFolderIcon"),
0992
0993 "FileChooser.lookInLabelMnemonic",
0994 new Integer(KeyEvent.VK_I),
0995 "FileChooser.fileNameLabelMnemonic",
0996 new Integer(KeyEvent.VK_N),
0997 "FileChooser.filesOfTypeLabelMnemonic",
0998 new Integer(KeyEvent.VK_T),
0999 "FileChooser.usesSingleFilePane",
1000 Boolean.TRUE,
1001 "FileChooser.ancestorInputMap",
1002 new UIDefaults.LazyInputMap(new Object[] { "ESCAPE",
1003 "cancelSelection", "F2", "editFileName", "F5",
1004 "refresh", "BACK_SPACE", "Go Up", "ENTER",
1005 "approveSelection", "ctrl ENTER",
1006 "approveSelection" }),
1007
1008 // ToolTip
1009 "ToolTip.font",
1010 systemTextValue,
1011 "ToolTip.border",
1012 toolTipBorder,
1013 "ToolTip.borderInactive",
1014 toolTipBorderInactive,
1015 "ToolTip.backgroundInactive",
1016 control,
1017 "ToolTip.foregroundInactive",
1018 controlDarkShadow,
1019 "ToolTip.hideAccelerator",
1020 Boolean.FALSE,
1021
1022 // ToolTipManager
1023 "ToolTipManager.enableToolTipMode",
1024 "activeApplication",
1025
1026 // Slider Defaults
1027 "Slider.font",
1028 controlTextValue,
1029 "Slider.border",
1030 null,
1031 "Slider.foreground",
1032 primaryControlShadow,
1033 "Slider.focus",
1034 focusColor,
1035 "Slider.focusInsets",
1036 zeroInsets,
1037 "Slider.trackWidth",
1038 new Integer(7),
1039 "Slider.majorTickLength",
1040 new Integer(6),
1041 "Slider.horizontalThumbIcon",
1042 new SwingLazyValue(
1043 "javax.swing.plaf.metal.MetalIconFactory",
1044 "getHorizontalSliderThumbIcon"),
1045 "Slider.verticalThumbIcon",
1046 new SwingLazyValue(
1047 "javax.swing.plaf.metal.MetalIconFactory",
1048 "getVerticalSliderThumbIcon"),
1049 "Slider.focusInputMap",
1050 new UIDefaults.LazyInputMap(new Object[] { "RIGHT",
1051 "positiveUnitIncrement", "KP_RIGHT",
1052 "positiveUnitIncrement", "DOWN",
1053 "negativeUnitIncrement", "KP_DOWN",
1054 "negativeUnitIncrement", "PAGE_DOWN",
1055 "negativeBlockIncrement", "ctrl PAGE_DOWN",
1056 "negativeBlockIncrement", "LEFT",
1057 "negativeUnitIncrement", "KP_LEFT",
1058 "negativeUnitIncrement", "UP",
1059 "positiveUnitIncrement", "KP_UP",
1060 "positiveUnitIncrement", "PAGE_UP",
1061 "positiveBlockIncrement", "ctrl PAGE_UP",
1062 "positiveBlockIncrement", "HOME", "minScroll",
1063 "END", "maxScroll" }),
1064
1065 // Progress Bar
1066 "ProgressBar.font",
1067 controlTextValue,
1068 "ProgressBar.foreground",
1069 primaryControlShadow,
1070 "ProgressBar.selectionBackground",
1071 primaryControlDarkShadow,
1072 "ProgressBar.border",
1073 progressBarBorder,
1074 "ProgressBar.cellSpacing",
1075 zero,
1076 "ProgressBar.cellLength",
1077 new Integer(1),
1078
1079 // Combo Box
1080 "ComboBox.background",
1081 control,
1082 "ComboBox.foreground",
1083 controlTextColor,
1084 "ComboBox.selectionBackground",
1085 primaryControlShadow,
1086 "ComboBox.selectionForeground",
1087 controlTextColor,
1088 "ComboBox.font",
1089 controlTextValue,
1090 "ComboBox.ancestorInputMap",
1091 new UIDefaults.LazyInputMap(new Object[] { "ESCAPE",
1092 "hidePopup", "PAGE_UP", "pageUpPassThrough",
1093 "PAGE_DOWN", "pageDownPassThrough", "HOME",
1094 "homePassThrough", "END", "endPassThrough",
1095 "DOWN", "selectNext", "KP_DOWN", "selectNext",
1096 "alt DOWN", "togglePopup", "alt KP_DOWN",
1097 "togglePopup", "alt UP", "togglePopup",
1098 "alt KP_UP", "togglePopup", "SPACE",
1099 "spacePopup", "ENTER", "enterPressed", "UP",
1100 "selectPrevious", "KP_UP", "selectPrevious" }),
1101
1102 // Internal Frame Defaults
1103 "InternalFrame.icon",
1104 new SwingLazyValue(
1105 "javax.swing.plaf.metal.MetalIconFactory",
1106 "getInternalFrameDefaultMenuIcon"),
1107 "InternalFrame.border",
1108 new SwingLazyValue(
1109 "javax.swing.plaf.metal.MetalBorders$InternalFrameBorder"),
1110 "InternalFrame.optionDialogBorder",
1111 new SwingLazyValue(
1112 "javax.swing.plaf.metal.MetalBorders$OptionDialogBorder"),
1113 "InternalFrame.paletteBorder",
1114 new SwingLazyValue(
1115 "javax.swing.plaf.metal.MetalBorders$PaletteBorder"),
1116 "InternalFrame.paletteTitleHeight",
1117 new Integer(11),
1118 "InternalFrame.paletteCloseIcon",
1119 new SwingLazyValue(
1120 "javax.swing.plaf.metal.MetalIconFactory$PaletteCloseIcon"),
1121 "InternalFrame.closeIcon",
1122 new SwingLazyValue(
1123 "javax.swing.plaf.metal.MetalIconFactory",
1124 "getInternalFrameCloseIcon",
1125 internalFrameIconArgs),
1126 "InternalFrame.maximizeIcon",
1127 new SwingLazyValue(
1128 "javax.swing.plaf.metal.MetalIconFactory",
1129 "getInternalFrameMaximizeIcon",
1130 internalFrameIconArgs),
1131 "InternalFrame.iconifyIcon",
1132 new SwingLazyValue(
1133 "javax.swing.plaf.metal.MetalIconFactory",
1134 "getInternalFrameMinimizeIcon",
1135 internalFrameIconArgs),
1136 "InternalFrame.minimizeIcon",
1137 new SwingLazyValue(
1138 "javax.swing.plaf.metal.MetalIconFactory",
1139 "getInternalFrameAltMaximizeIcon",
1140 internalFrameIconArgs),
1141 "InternalFrame.titleFont",
1142 windowTitleValue,
1143 "InternalFrame.windowBindings",
1144 null,
1145 // Internal Frame Auditory Cue Mappings
1146 "InternalFrame.closeSound",
1147 "sounds/FrameClose.wav",
1148 "InternalFrame.maximizeSound",
1149 "sounds/FrameMaximize.wav",
1150 "InternalFrame.minimizeSound",
1151 "sounds/FrameMinimize.wav",
1152 "InternalFrame.restoreDownSound",
1153 "sounds/FrameRestoreDown.wav",
1154 "InternalFrame.restoreUpSound",
1155 "sounds/FrameRestoreUp.wav",
1156
1157 // Desktop Icon
1158 "DesktopIcon.border",
1159 desktopIconBorder,
1160 "DesktopIcon.font",
1161 controlTextValue,
1162 "DesktopIcon.foreground",
1163 controlTextColor,
1164 "DesktopIcon.background",
1165 control,
1166 "DesktopIcon.width",
1167 new Integer(160),
1168
1169 "Desktop.ancestorInputMap",
1170 new UIDefaults.LazyInputMap(new Object[] { "ctrl F5",
1171 "restore", "ctrl F4", "close", "ctrl F7",
1172 "move", "ctrl F8", "resize", "RIGHT", "right",
1173 "KP_RIGHT", "right", "shift RIGHT",
1174 "shrinkRight", "shift KP_RIGHT", "shrinkRight",
1175 "LEFT", "left", "KP_LEFT", "left",
1176 "shift LEFT", "shrinkLeft", "shift KP_LEFT",
1177 "shrinkLeft", "UP", "up", "KP_UP", "up",
1178 "shift UP", "shrinkUp", "shift KP_UP",
1179 "shrinkUp", "DOWN", "down", "KP_DOWN", "down",
1180 "shift DOWN", "shrinkDown", "shift KP_DOWN",
1181 "shrinkDown", "ESCAPE", "escape", "ctrl F9",
1182 "minimize", "ctrl F10", "maximize", "ctrl F6",
1183 "selectNextFrame", "ctrl TAB",
1184 "selectNextFrame", "ctrl alt F6",
1185 "selectNextFrame", "shift ctrl alt F6",
1186 "selectPreviousFrame", "ctrl F12",
1187 "navigateNext", "shift ctrl F12",
1188 "navigatePrevious" }),
1189
1190 // Titled Border
1191 "TitledBorder.font",
1192 controlTextValue,
1193 "TitledBorder.titleColor",
1194 systemTextColor,
1195 "TitledBorder.border",
1196 titledBorderBorder,
1197
1198 // Label
1199 "Label.font",
1200 controlTextValue,
1201 "Label.foreground",
1202 systemTextColor,
1203 "Label.disabledForeground",
1204 getInactiveSystemTextColor(),
1205
1206 // List
1207 "List.font",
1208 controlTextValue,
1209 "List.focusCellHighlightBorder",
1210 focusCellHighlightBorder,
1211 "List.focusInputMap",
1212 new UIDefaults.LazyInputMap(new Object[] { "ctrl C",
1213 "copy", "ctrl V", "paste", "ctrl X", "cut",
1214 "COPY", "copy", "PASTE", "paste", "CUT", "cut",
1215 "control INSERT", "copy", "shift INSERT",
1216 "paste", "shift DELETE", "cut", "UP",
1217 "selectPreviousRow", "KP_UP",
1218 "selectPreviousRow", "shift UP",
1219 "selectPreviousRowExtendSelection",
1220 "shift KP_UP",
1221 "selectPreviousRowExtendSelection",
1222 "ctrl shift UP",
1223 "selectPreviousRowExtendSelection",
1224 "ctrl shift KP_UP",
1225 "selectPreviousRowExtendSelection", "ctrl UP",
1226 "selectPreviousRowChangeLead", "ctrl KP_UP",
1227 "selectPreviousRowChangeLead", "DOWN",
1228 "selectNextRow", "KP_DOWN", "selectNextRow",
1229 "shift DOWN", "selectNextRowExtendSelection",
1230 "shift KP_DOWN",
1231 "selectNextRowExtendSelection",
1232 "ctrl shift DOWN",
1233 "selectNextRowExtendSelection",
1234 "ctrl shift KP_DOWN",
1235 "selectNextRowExtendSelection", "ctrl DOWN",
1236 "selectNextRowChangeLead", "ctrl KP_DOWN",
1237 "selectNextRowChangeLead", "LEFT",
1238 "selectPreviousColumn", "KP_LEFT",
1239 "selectPreviousColumn", "shift LEFT",
1240 "selectPreviousColumnExtendSelection",
1241 "shift KP_LEFT",
1242 "selectPreviousColumnExtendSelection",
1243 "ctrl shift LEFT",
1244 "selectPreviousColumnExtendSelection",
1245 "ctrl shift KP_LEFT",
1246 "selectPreviousColumnExtendSelection",
1247 "ctrl LEFT", "selectPreviousColumnChangeLead",
1248 "ctrl KP_LEFT",
1249 "selectPreviousColumnChangeLead", "RIGHT",
1250 "selectNextColumn", "KP_RIGHT",
1251 "selectNextColumn", "shift RIGHT",
1252 "selectNextColumnExtendSelection",
1253 "shift KP_RIGHT",
1254 "selectNextColumnExtendSelection",
1255 "ctrl shift RIGHT",
1256 "selectNextColumnExtendSelection",
1257 "ctrl shift KP_RIGHT",
1258 "selectNextColumnExtendSelection",
1259 "ctrl RIGHT", "selectNextColumnChangeLead",
1260 "ctrl KP_RIGHT", "selectNextColumnChangeLead",
1261 "HOME", "selectFirstRow", "shift HOME",
1262 "selectFirstRowExtendSelection",
1263 "ctrl shift HOME",
1264 "selectFirstRowExtendSelection", "ctrl HOME",
1265 "selectFirstRowChangeLead", "END",
1266 "selectLastRow", "shift END",
1267 "selectLastRowExtendSelection",
1268 "ctrl shift END",
1269 "selectLastRowExtendSelection", "ctrl END",
1270 "selectLastRowChangeLead", "PAGE_UP",
1271 "scrollUp", "shift PAGE_UP",
1272 "scrollUpExtendSelection",
1273 "ctrl shift PAGE_UP",
1274 "scrollUpExtendSelection", "ctrl PAGE_UP",
1275 "scrollUpChangeLead", "PAGE_DOWN",
1276 "scrollDown", "shift PAGE_DOWN",
1277 "scrollDownExtendSelection",
1278 "ctrl shift PAGE_DOWN",
1279 "scrollDownExtendSelection", "ctrl PAGE_DOWN",
1280 "scrollDownChangeLead", "ctrl A", "selectAll",
1281 "ctrl SLASH", "selectAll", "ctrl BACK_SLASH",
1282 "clearSelection", "SPACE", "addToSelection",
1283 "ctrl SPACE", "toggleAndAnchor", "shift SPACE",
1284 "extendTo", "ctrl shift SPACE",
1285 "moveSelectionTo" }),
1286
1287 // ScrollBar
1288 "ScrollBar.background",
1289 control,
1290 "ScrollBar.highlight",
1291 controlHighlight,
1292 "ScrollBar.shadow",
1293 controlShadow,
1294 "ScrollBar.darkShadow",
1295 controlDarkShadow,
1296 "ScrollBar.thumb",
1297 primaryControlShadow,
1298 "ScrollBar.thumbShadow",
1299 primaryControlDarkShadow,
1300 "ScrollBar.thumbHighlight",
1301 primaryControl,
1302 "ScrollBar.width",
1303 new Integer(17),
1304 "ScrollBar.allowsAbsolutePositioning",
1305 Boolean.TRUE,
1306 "ScrollBar.ancestorInputMap",
1307 new UIDefaults.LazyInputMap(new Object[] { "RIGHT",
1308 "positiveUnitIncrement", "KP_RIGHT",
1309 "positiveUnitIncrement", "DOWN",
1310 "positiveUnitIncrement", "KP_DOWN",
1311 "positiveUnitIncrement", "PAGE_DOWN",
1312 "positiveBlockIncrement", "LEFT",
1313 "negativeUnitIncrement", "KP_LEFT",
1314 "negativeUnitIncrement", "UP",
1315 "negativeUnitIncrement", "KP_UP",
1316 "negativeUnitIncrement", "PAGE_UP",
1317 "negativeBlockIncrement", "HOME", "minScroll",
1318 "END", "maxScroll" }),
1319
1320 // ScrollPane
1321 "ScrollPane.border",
1322 scrollPaneBorder,
1323 "ScrollPane.ancestorInputMap",
1324 new UIDefaults.LazyInputMap(new Object[] { "RIGHT",
1325 "unitScrollRight", "KP_RIGHT",
1326 "unitScrollRight", "DOWN", "unitScrollDown",
1327 "KP_DOWN", "unitScrollDown", "LEFT",
1328 "unitScrollLeft", "KP_LEFT", "unitScrollLeft",
1329 "UP", "unitScrollUp", "KP_UP", "unitScrollUp",
1330 "PAGE_UP", "scrollUp", "PAGE_DOWN",
1331 "scrollDown", "ctrl PAGE_UP", "scrollLeft",
1332 "ctrl PAGE_DOWN", "scrollRight", "ctrl HOME",
1333 "scrollHome", "ctrl END", "scrollEnd" }),
1334
1335 // Tabbed Pane
1336 "TabbedPane.font",
1337 controlTextValue,
1338 "TabbedPane.tabAreaBackground",
1339 control,
1340 "TabbedPane.background",
1341 controlShadow,
1342 "TabbedPane.light",
1343 control,
1344 "TabbedPane.focus",
1345 primaryControlDarkShadow,
1346 "TabbedPane.selected",
1347 control,
1348 "TabbedPane.selectHighlight",
1349 controlHighlight,
1350 "TabbedPane.tabAreaInsets",
1351 tabbedPaneTabAreaInsets,
1352 "TabbedPane.tabInsets",
1353 tabbedPaneTabInsets,
1354 "TabbedPane.focusInputMap",
1355 new UIDefaults.LazyInputMap(new Object[] { "RIGHT",
1356 "navigateRight", "KP_RIGHT", "navigateRight",
1357 "LEFT", "navigateLeft", "KP_LEFT",
1358 "navigateLeft", "UP", "navigateUp", "KP_UP",
1359 "navigateUp", "DOWN", "navigateDown",
1360 "KP_DOWN", "navigateDown", "ctrl DOWN",
1361 "requestFocusForVisibleComponent",
1362 "ctrl KP_DOWN",
1363 "requestFocusForVisibleComponent", }),
1364 "TabbedPane.ancestorInputMap",
1365 new UIDefaults.LazyInputMap(new Object[] {
1366 "ctrl PAGE_DOWN", "navigatePageDown",
1367 "ctrl PAGE_UP", "navigatePageUp", "ctrl UP",
1368 "requestFocus", "ctrl KP_UP", "requestFocus", }),
1369
1370 // Table
1371 "Table.font",
1372 userTextValue,
1373 "Table.focusCellHighlightBorder",
1374 focusCellHighlightBorder,
1375 "Table.scrollPaneBorder",
1376 scrollPaneBorder,
1377 "Table.dropLineColor",
1378 focusColor,
1379 "Table.dropLineShortColor",
1380 primaryControlDarkShadow,
1381 "Table.gridColor",
1382 controlShadow, // grid line color
1383 "Table.ancestorInputMap",
1384 new UIDefaults.LazyInputMap(new Object[] { "ctrl C",
1385 "copy", "ctrl V", "paste", "ctrl X", "cut",
1386 "COPY", "copy", "PASTE", "paste", "CUT", "cut",
1387 "control INSERT", "copy", "shift INSERT",
1388 "paste", "shift DELETE", "cut", "RIGHT",
1389 "selectNextColumn", "KP_RIGHT",
1390 "selectNextColumn", "shift RIGHT",
1391 "selectNextColumnExtendSelection",
1392 "shift KP_RIGHT",
1393 "selectNextColumnExtendSelection",
1394 "ctrl shift RIGHT",
1395 "selectNextColumnExtendSelection",
1396 "ctrl shift KP_RIGHT",
1397 "selectNextColumnExtendSelection",
1398 "ctrl RIGHT", "selectNextColumnChangeLead",
1399 "ctrl KP_RIGHT", "selectNextColumnChangeLead",
1400 "LEFT", "selectPreviousColumn", "KP_LEFT",
1401 "selectPreviousColumn", "shift LEFT",
1402 "selectPreviousColumnExtendSelection",
1403 "shift KP_LEFT",
1404 "selectPreviousColumnExtendSelection",
1405 "ctrl shift LEFT",
1406 "selectPreviousColumnExtendSelection",
1407 "ctrl shift KP_LEFT",
1408 "selectPreviousColumnExtendSelection",
1409 "ctrl LEFT", "selectPreviousColumnChangeLead",
1410 "ctrl KP_LEFT",
1411 "selectPreviousColumnChangeLead", "DOWN",
1412 "selectNextRow", "KP_DOWN", "selectNextRow",
1413 "shift DOWN", "selectNextRowExtendSelection",
1414 "shift KP_DOWN",
1415 "selectNextRowExtendSelection",
1416 "ctrl shift DOWN",
1417 "selectNextRowExtendSelection",
1418 "ctrl shift KP_DOWN",
1419 "selectNextRowExtendSelection", "ctrl DOWN",
1420 "selectNextRowChangeLead", "ctrl KP_DOWN",
1421 "selectNextRowChangeLead", "UP",
1422 "selectPreviousRow", "KP_UP",
1423 "selectPreviousRow", "shift UP",
1424 "selectPreviousRowExtendSelection",
1425 "shift KP_UP",
1426 "selectPreviousRowExtendSelection",
1427 "ctrl shift UP",
1428 "selectPreviousRowExtendSelection",
1429 "ctrl shift KP_UP",
1430 "selectPreviousRowExtendSelection", "ctrl UP",
1431 "selectPreviousRowChangeLead", "ctrl KP_UP",
1432 "selectPreviousRowChangeLead", "HOME",
1433 "selectFirstColumn", "shift HOME",
1434 "selectFirstColumnExtendSelection",
1435 "ctrl shift HOME",
1436 "selectFirstRowExtendSelection", "ctrl HOME",
1437 "selectFirstRow", "END", "selectLastColumn",
1438 "shift END", "selectLastColumnExtendSelection",
1439 "ctrl shift END",
1440 "selectLastRowExtendSelection", "ctrl END",
1441 "selectLastRow", "PAGE_UP",
1442 "scrollUpChangeSelection", "shift PAGE_UP",
1443 "scrollUpExtendSelection",
1444 "ctrl shift PAGE_UP",
1445 "scrollLeftExtendSelection", "ctrl PAGE_UP",
1446 "scrollLeftChangeSelection", "PAGE_DOWN",
1447 "scrollDownChangeSelection", "shift PAGE_DOWN",
1448 "scrollDownExtendSelection",
1449 "ctrl shift PAGE_DOWN",
1450 "scrollRightExtendSelection", "ctrl PAGE_DOWN",
1451 "scrollRightChangeSelection", "TAB",
1452 "selectNextColumnCell", "shift TAB",
1453 "selectPreviousColumnCell", "ENTER",
1454 "selectNextRowCell", "shift ENTER",
1455 "selectPreviousRowCell", "ctrl A", "selectAll",
1456 "ctrl SLASH", "selectAll", "ctrl BACK_SLASH",
1457 "clearSelection", "ESCAPE", "cancel", "F2",
1458 "startEditing", "SPACE", "addToSelection",
1459 "ctrl SPACE", "toggleAndAnchor", "shift SPACE",
1460 "extendTo", "ctrl shift SPACE",
1461 "moveSelectionTo", "F8", "focusHeader" }),
1462 "Table.ascendingSortIcon",
1463 SwingUtilities2.makeIcon(getClass(),
1464 MetalLookAndFeel.class, "icons/sortUp.png"),
1465 "Table.descendingSortIcon",
1466 SwingUtilities2.makeIcon(getClass(),
1467 MetalLookAndFeel.class, "icons/sortDown.png"),
1468
1469 "TableHeader.font",
1470 userTextValue,
1471 "TableHeader.cellBorder",
1472 new SwingLazyValue(
1473 "javax.swing.plaf.metal.MetalBorders$TableHeaderBorder"),
1474
1475 // MenuBar
1476 "MenuBar.border",
1477 menuBarBorder,
1478 "MenuBar.font",
1479 menuTextValue,
1480 "MenuBar.windowBindings",
1481 new Object[] { "F10", "takeFocus" },
1482
1483 // Menu
1484 "Menu.border",
1485 menuItemBorder,
1486 "Menu.borderPainted",
1487 Boolean.TRUE,
1488 "Menu.menuPopupOffsetX",
1489 zero,
1490 "Menu.menuPopupOffsetY",
1491 zero,
1492 "Menu.submenuPopupOffsetX",
1493 new Integer(-4),
1494 "Menu.submenuPopupOffsetY",
1495 new Integer(-3),
1496 "Menu.font",
1497 menuTextValue,
1498 "Menu.selectionForeground",
1499 menuSelectedForeground,
1500 "Menu.selectionBackground",
1501 menuSelectedBackground,
1502 "Menu.disabledForeground",
1503 menuDisabledForeground,
1504 "Menu.acceleratorFont",
1505 subTextValue,
1506 "Menu.acceleratorForeground",
1507 acceleratorForeground,
1508 "Menu.acceleratorSelectionForeground",
1509 acceleratorSelectedForeground,
1510 "Menu.checkIcon",
1511 new SwingLazyValue(
1512 "javax.swing.plaf.metal.MetalIconFactory",
1513 "getMenuItemCheckIcon"),
1514 "Menu.arrowIcon",
1515 new SwingLazyValue(
1516 "javax.swing.plaf.metal.MetalIconFactory",
1517 "getMenuArrowIcon"),
1518
1519 // Menu Item
1520 "MenuItem.border",
1521 menuItemBorder,
1522 "MenuItem.borderPainted",
1523 Boolean.TRUE,
1524 "MenuItem.font",
1525 menuTextValue,
1526 "MenuItem.selectionForeground",
1527 menuSelectedForeground,
1528 "MenuItem.selectionBackground",
1529 menuSelectedBackground,
1530 "MenuItem.disabledForeground",
1531 menuDisabledForeground,
1532 "MenuItem.acceleratorFont",
1533 subTextValue,
1534 "MenuItem.acceleratorForeground",
1535 acceleratorForeground,
1536 "MenuItem.acceleratorSelectionForeground",
1537 acceleratorSelectedForeground,
1538 "MenuItem.acceleratorDelimiter",
1539 menuItemAcceleratorDelimiter,
1540 "MenuItem.checkIcon",
1541 new SwingLazyValue(
1542 "javax.swing.plaf.metal.MetalIconFactory",
1543 "getMenuItemCheckIcon"),
1544 "MenuItem.arrowIcon",
1545 new SwingLazyValue(
1546 "javax.swing.plaf.metal.MetalIconFactory",
1547 "getMenuItemArrowIcon"),
1548 // Menu Item Auditory Cue Mapping
1549 "MenuItem.commandSound",
1550 "sounds/MenuItemCommand.wav",
1551
1552 // OptionPane.
1553 "OptionPane.windowBindings",
1554 new Object[] { "ESCAPE", "close" },
1555 // Option Pane Auditory Cue Mappings
1556 "OptionPane.informationSound",
1557 "sounds/OptionPaneInformation.wav",
1558 "OptionPane.warningSound",
1559 "sounds/OptionPaneWarning.wav",
1560 "OptionPane.errorSound",
1561 "sounds/OptionPaneError.wav",
1562 "OptionPane.questionSound",
1563 "sounds/OptionPaneQuestion.wav",
1564
1565 // Option Pane Special Dialog Colors, used when MetalRootPaneUI
1566 // is providing window manipulation widgets.
1567 "OptionPane.errorDialog.border.background",
1568 new ColorUIResource(153, 51, 51),
1569 "OptionPane.errorDialog.titlePane.foreground",
1570 new ColorUIResource(51, 0, 0),
1571 "OptionPane.errorDialog.titlePane.background",
1572 new ColorUIResource(255, 153, 153),
1573 "OptionPane.errorDialog.titlePane.shadow",
1574 new ColorUIResource(204, 102, 102),
1575 "OptionPane.questionDialog.border.background",
1576 new ColorUIResource(51, 102, 51),
1577 "OptionPane.questionDialog.titlePane.foreground",
1578 new ColorUIResource(0, 51, 0),
1579 "OptionPane.questionDialog.titlePane.background",
1580 new ColorUIResource(153, 204, 153),
1581 "OptionPane.questionDialog.titlePane.shadow",
1582 new ColorUIResource(102, 153, 102),
1583 "OptionPane.warningDialog.border.background",
1584 new ColorUIResource(153, 102, 51),
1585 "OptionPane.warningDialog.titlePane.foreground",
1586 new ColorUIResource(102, 51, 0),
1587 "OptionPane.warningDialog.titlePane.background",
1588 new ColorUIResource(255, 204, 153),
1589 "OptionPane.warningDialog.titlePane.shadow",
1590 new ColorUIResource(204, 153, 102),
1591 // OptionPane fonts are defined below
1592
1593 // Separator
1594 "Separator.background",
1595 getSeparatorBackground(),
1596 "Separator.foreground",
1597 getSeparatorForeground(),
1598
1599 // Popup Menu
1600 "PopupMenu.border",
1601 popupMenuBorder,
1602 // Popup Menu Auditory Cue Mappings
1603 "PopupMenu.popupSound",
1604 "sounds/PopupMenuPopup.wav",
1605 "PopupMenu.font",
1606 menuTextValue,
1607
1608 // CB & RB Menu Item
1609 "CheckBoxMenuItem.border",
1610 menuItemBorder,
1611 "CheckBoxMenuItem.borderPainted",
1612 Boolean.TRUE,
1613 "CheckBoxMenuItem.font",
1614 menuTextValue,
1615 "CheckBoxMenuItem.selectionForeground",
1616 menuSelectedForeground,
1617 "CheckBoxMenuItem.selectionBackground",
1618 menuSelectedBackground,
1619 "CheckBoxMenuItem.disabledForeground",
1620 menuDisabledForeground,
1621 "CheckBoxMenuItem.acceleratorFont",
1622 subTextValue,
1623 "CheckBoxMenuItem.acceleratorForeground",
1624 acceleratorForeground,
1625 "CheckBoxMenuItem.acceleratorSelectionForeground",
1626 acceleratorSelectedForeground,
1627 "CheckBoxMenuItem.checkIcon",
1628 new SwingLazyValue(
1629 "javax.swing.plaf.metal.MetalIconFactory",
1630 "getCheckBoxMenuItemIcon"),
1631 "CheckBoxMenuItem.arrowIcon",
1632 new SwingLazyValue(
1633 "javax.swing.plaf.metal.MetalIconFactory",
1634 "getMenuItemArrowIcon"),
1635 "CheckBoxMenuItem.commandSound",
1636 "sounds/MenuItemCommand.wav",
1637
1638 "RadioButtonMenuItem.border",
1639 menuItemBorder,
1640 "RadioButtonMenuItem.borderPainted",
1641 Boolean.TRUE,
1642 "RadioButtonMenuItem.font",
1643 menuTextValue,
1644 "RadioButtonMenuItem.selectionForeground",
1645 menuSelectedForeground,
1646 "RadioButtonMenuItem.selectionBackground",
1647 menuSelectedBackground,
1648 "RadioButtonMenuItem.disabledForeground",
1649 menuDisabledForeground,
1650 "RadioButtonMenuItem.acceleratorFont",
1651 subTextValue,
1652 "RadioButtonMenuItem.acceleratorForeground",
1653 acceleratorForeground,
1654 "RadioButtonMenuItem.acceleratorSelectionForeground",
1655 acceleratorSelectedForeground,
1656 "RadioButtonMenuItem.checkIcon",
1657 new SwingLazyValue(
1658 "javax.swing.plaf.metal.MetalIconFactory",
1659 "getRadioButtonMenuItemIcon"),
1660 "RadioButtonMenuItem.arrowIcon",
1661 new SwingLazyValue(
1662 "javax.swing.plaf.metal.MetalIconFactory",
1663 "getMenuItemArrowIcon"),
1664 "RadioButtonMenuItem.commandSound",
1665 "sounds/MenuItemCommand.wav",
1666
1667 "Spinner.ancestorInputMap",
1668 new UIDefaults.LazyInputMap(new Object[] { "UP",
1669 "increment", "KP_UP", "increment", "DOWN",
1670 "decrement", "KP_DOWN", "decrement", }),
1671 "Spinner.arrowButtonInsets",
1672 zeroInsets,
1673 "Spinner.border",
1674 textFieldBorder,
1675 "Spinner.arrowButtonBorder",
1676 buttonBorder,
1677 "Spinner.font",
1678 controlTextValue,
1679
1680 // SplitPane
1681
1682 "SplitPane.dividerSize",
1683 new Integer(10),
1684 "SplitPane.ancestorInputMap",
1685 new UIDefaults.LazyInputMap(new Object[] { "UP",
1686 "negativeIncrement", "DOWN",
1687 "positiveIncrement", "LEFT",
1688 "negativeIncrement", "RIGHT",
1689 "positiveIncrement", "KP_UP",
1690 "negativeIncrement", "KP_DOWN",
1691 "positiveIncrement", "KP_LEFT",
1692 "negativeIncrement", "KP_RIGHT",
1693 "positiveIncrement", "HOME", "selectMin",
1694 "END", "selectMax", "F8", "startResize", "F6",
1695 "toggleFocus", "ctrl TAB", "focusOutForward",
1696 "ctrl shift TAB", "focusOutBackward" }),
1697 "SplitPane.centerOneTouchButtons",
1698 Boolean.FALSE,
1699 "SplitPane.dividerFocusColor",
1700 primaryControl,
1701
1702 // Tree
1703 // Tree.font was mapped to system font pre 1.4.1
1704 "Tree.font",
1705 userTextValue,
1706 "Tree.textBackground",
1707 getWindowBackground(),
1708 "Tree.selectionBorderColor",
1709 focusColor,
1710 "Tree.openIcon",
1711 new SwingLazyValue(
1712 "javax.swing.plaf.metal.MetalIconFactory",
1713 "getTreeFolderIcon"),
1714 "Tree.closedIcon",
1715 new SwingLazyValue(
1716 "javax.swing.plaf.metal.MetalIconFactory",
1717 "getTreeFolderIcon"),
1718 "Tree.leafIcon",
1719 new SwingLazyValue(
1720 "javax.swing.plaf.metal.MetalIconFactory",
1721 "getTreeLeafIcon"),
1722 "Tree.expandedIcon",
1723 new SwingLazyValue(
1724 "javax.swing.plaf.metal.MetalIconFactory",
1725 "getTreeControlIcon", new Object[] { Boolean
1726 .valueOf(MetalIconFactory.DARK) }),
1727 "Tree.collapsedIcon",
1728 new SwingLazyValue(
1729 "javax.swing.plaf.metal.MetalIconFactory",
1730 "getTreeControlIcon", new Object[] { Boolean
1731 .valueOf(MetalIconFactory.LIGHT) }),
1732
1733 "Tree.line",
1734 primaryControl, // horiz lines
1735 "Tree.hash",
1736 primaryControl, // legs
1737 "Tree.rowHeight",
1738 zero,
1739 "Tree.focusInputMap",
1740 new UIDefaults.LazyInputMap(new Object[] { "ADD",
1741 "expand", "SUBTRACT", "collapse", "ctrl C",
1742 "copy", "ctrl V", "paste", "ctrl X", "cut",
1743 "COPY", "copy", "PASTE", "paste", "CUT", "cut",
1744 "control INSERT", "copy", "shift INSERT",
1745 "paste", "shift DELETE", "cut", "UP",
1746 "selectPrevious", "KP_UP", "selectPrevious",
1747 "shift UP", "selectPreviousExtendSelection",
1748 "shift KP_UP", "selectPreviousExtendSelection",
1749 "ctrl shift UP",
1750 "selectPreviousExtendSelection",
1751 "ctrl shift KP_UP",
1752 "selectPreviousExtendSelection", "ctrl UP",
1753 "selectPreviousChangeLead", "ctrl KP_UP",
1754 "selectPreviousChangeLead", "DOWN",
1755 "selectNext", "KP_DOWN", "selectNext",
1756 "shift DOWN", "selectNextExtendSelection",
1757 "shift KP_DOWN", "selectNextExtendSelection",
1758 "ctrl shift DOWN", "selectNextExtendSelection",
1759 "ctrl shift KP_DOWN",
1760 "selectNextExtendSelection", "ctrl DOWN",
1761 "selectNextChangeLead", "ctrl KP_DOWN",
1762 "selectNextChangeLead", "RIGHT", "selectChild",
1763 "KP_RIGHT", "selectChild", "LEFT",
1764 "selectParent", "KP_LEFT", "selectParent",
1765 "PAGE_UP", "scrollUpChangeSelection",
1766 "shift PAGE_UP", "scrollUpExtendSelection",
1767 "ctrl shift PAGE_UP",
1768 "scrollUpExtendSelection", "ctrl PAGE_UP",
1769 "scrollUpChangeLead", "PAGE_DOWN",
1770 "scrollDownChangeSelection", "shift PAGE_DOWN",
1771 "scrollDownExtendSelection",
1772 "ctrl shift PAGE_DOWN",
1773 "scrollDownExtendSelection", "ctrl PAGE_DOWN",
1774 "scrollDownChangeLead", "HOME", "selectFirst",
1775 "shift HOME", "selectFirstExtendSelection",
1776 "ctrl shift HOME",
1777 "selectFirstExtendSelection", "ctrl HOME",
1778 "selectFirstChangeLead", "END", "selectLast",
1779 "shift END", "selectLastExtendSelection",
1780 "ctrl shift END", "selectLastExtendSelection",
1781 "ctrl END", "selectLastChangeLead", "F2",
1782 "startEditing", "ctrl A", "selectAll",
1783 "ctrl SLASH", "selectAll", "ctrl BACK_SLASH",
1784 "clearSelection", "ctrl LEFT", "scrollLeft",
1785 "ctrl KP_LEFT", "scrollLeft", "ctrl RIGHT",
1786 "scrollRight", "ctrl KP_RIGHT", "scrollRight",
1787 "SPACE", "addToSelection", "ctrl SPACE",
1788 "toggleAndAnchor", "shift SPACE", "extendTo",
1789 "ctrl shift SPACE", "moveSelectionTo" }),
1790 "Tree.ancestorInputMap",
1791 new UIDefaults.LazyInputMap(new Object[] { "ESCAPE",
1792 "cancel" }),
1793
1794 // ToolBar
1795 "ToolBar.border",
1796 toolBarBorder,
1797 "ToolBar.background",
1798 menuBackground,
1799 "ToolBar.foreground",
1800 getMenuForeground(),
1801 "ToolBar.font",
1802 menuTextValue,
1803 "ToolBar.dockingBackground",
1804 menuBackground,
1805 "ToolBar.floatingBackground",
1806 menuBackground,
1807 "ToolBar.dockingForeground",
1808 primaryControlDarkShadow,
1809 "ToolBar.floatingForeground",
1810 primaryControl,
1811 "ToolBar.rolloverBorder",
1812 new MetalLazyValue(
1813 "javax.swing.plaf.metal.MetalBorders",
1814 "getToolBarRolloverBorder"),
1815 "ToolBar.nonrolloverBorder",
1816 new MetalLazyValue(
1817 "javax.swing.plaf.metal.MetalBorders",
1818 "getToolBarNonrolloverBorder"),
1819 "ToolBar.ancestorInputMap",
1820 new UIDefaults.LazyInputMap(new Object[] { "UP",
1821 "navigateUp", "KP_UP", "navigateUp", "DOWN",
1822 "navigateDown", "KP_DOWN", "navigateDown",
1823 "LEFT", "navigateLeft", "KP_LEFT",
1824 "navigateLeft", "RIGHT", "navigateRight",
1825 "KP_RIGHT", "navigateRight" }),
1826
1827 // RootPane
1828 "RootPane.frameBorder",
1829 new MetalLazyValue(
1830 "javax.swing.plaf.metal.MetalBorders$FrameBorder"),
1831 "RootPane.plainDialogBorder",
1832 dialogBorder,
1833 "RootPane.informationDialogBorder",
1834 dialogBorder,
1835 "RootPane.errorDialogBorder",
1836 new MetalLazyValue(
1837 "javax.swing.plaf.metal.MetalBorders$ErrorDialogBorder"),
1838 "RootPane.colorChooserDialogBorder",
1839 questionDialogBorder,
1840 "RootPane.fileChooserDialogBorder",
1841 questionDialogBorder,
1842 "RootPane.questionDialogBorder",
1843 questionDialogBorder,
1844 "RootPane.warningDialogBorder",
1845 new MetalLazyValue(
1846 "javax.swing.plaf.metal.MetalBorders$WarningDialogBorder"),
1847 // These bindings are only enabled when there is a default
1848 // button set on the rootpane.
1849 "RootPane.defaultButtonWindowKeyBindings",
1850 new Object[] { "ENTER", "press", "released ENTER",
1851 "release", "ctrl ENTER", "press",
1852 "ctrl released ENTER", "release" }, };
1853
1854 table.putDefaults(defaults);
1855
1856 if (isWindows() && useSystemFonts() && theme.isSystemTheme()) {
1857 Toolkit kit = Toolkit.getDefaultToolkit();
1858 Object messageFont = new MetalFontDesktopProperty(
1859 "win.messagebox.font.height", kit,
1860 MetalTheme.CONTROL_TEXT_FONT);
1861
1862 defaults = new Object[] { "OptionPane.messageFont",
1863 messageFont, "OptionPane.buttonFont", messageFont, };
1864 table.putDefaults(defaults);
1865 }
1866
1867 flushUnreferenced(); // Remove old listeners
1868
1869 boolean lafCond = SwingUtilities2.isLocalDisplay();
1870 Object aaTextInfo = SwingUtilities2.AATextInfo
1871 .getAATextInfo(lafCond);
1872 table.put(SwingUtilities2.AA_TEXT_PROPERTY_KEY, aaTextInfo);
1873 new AATextListener(this );
1874 }
1875
1876 /**
1877 * Ensures the current {@code MetalTheme} is {@code non-null}. This is
1878 * a cover method for {@code getCurrentTheme}.
1879 *
1880 * @see #getCurrentTheme
1881 */
1882 protected void createDefaultTheme() {
1883 getCurrentTheme();
1884 }
1885
1886 /**
1887 * Returns the look and feel defaults. This invokes, in order,
1888 * {@code createDefaultTheme()}, {@code super.getDefaults()} and
1889 * {@code getCurrentTheme().addCustomEntriesToTable(table)}.
1890 * <p>
1891 * While this method is public, it should only be invoked by the
1892 * {@code UIManager} when the look and feel is set as the current
1893 * look and feel and after {@code initialize} has been invoked.
1894 *
1895 * @return the look and feel defaults
1896 *
1897 * @see #createDefaultTheme
1898 * @see javax.swing.plaf.basic.BasicLookAndFeel#getDefaults()
1899 * @see MetalTheme#addCustomEntriesToTable(UIDefaults)
1900 */
1901 public UIDefaults getDefaults() {
1902 // PENDING: move this to initialize when API changes are allowed
1903 METAL_LOOK_AND_FEEL_INITED = true;
1904
1905 createDefaultTheme();
1906 UIDefaults table = super .getDefaults();
1907 currentTheme.addCustomEntriesToTable(table);
1908 currentTheme.install();
1909 return table;
1910 }
1911
1912 /**
1913 * {@inheritDoc}
1914 *
1915 * @since 1.4
1916 */
1917 public void provideErrorFeedback(Component component) {
1918 super .provideErrorFeedback(component);
1919 }
1920
1921 /**
1922 * Set the theme used by <code>MetalLookAndFeel</code>.
1923 * <p>
1924 * After the theme is set, {@code MetalLookAndFeel} needs to be
1925 * re-installed and the uis need to be recreated. The following
1926 * shows how to do this:
1927 * <pre>
1928 * MetalLookAndFeel.setCurrentTheme(theme);
1929 *
1930 * // re-install the Metal Look and Feel
1931 * UIManager.setLookAndFeel(new MetalLookAndFeel());
1932 *
1933 * // Update the ComponentUIs for all Components. This
1934 * // needs to be invoked for all windows.
1935 * SwingUtilities.updateComponentTreeUI(rootComponent);
1936 * </pre>
1937 * If this is not done the results are undefined.
1938 *
1939 * @param theme the theme to use
1940 * @throws NullPointerException if {@code theme} is {@code null}
1941 * @see #getCurrentTheme
1942 */
1943 public static void setCurrentTheme(MetalTheme theme) {
1944 // NOTE: because you need to recreate the look and feel after
1945 // this step, we don't bother blowing away any potential windows
1946 // values.
1947 if (theme == null) {
1948 throw new NullPointerException("Can't have null theme");
1949 }
1950 currentTheme = theme;
1951 cachedAppContext = AppContext.getAppContext();
1952 cachedAppContext.put("currentMetalTheme", theme);
1953 }
1954
1955 /**
1956 * Return the theme currently being used by <code>MetalLookAndFeel</code>.
1957 * If the current theme is {@code null}, the default theme is created.
1958 *
1959 * @return the current theme
1960 * @see #setCurrentTheme
1961 * @since 1.5
1962 */
1963 public static MetalTheme getCurrentTheme() {
1964 AppContext context = AppContext.getAppContext();
1965
1966 if (cachedAppContext != context) {
1967 currentTheme = (MetalTheme) context
1968 .get("currentMetalTheme");
1969 if (currentTheme == null) {
1970 // This will happen in two cases:
1971 // . When MetalLookAndFeel is first being initialized.
1972 // . When a new AppContext has been created that hasn't
1973 // triggered UIManager to load a LAF. Rather than invoke
1974 // a method on the UIManager, which would trigger the loading
1975 // of a potentially different LAF, we directly set the
1976 // Theme here.
1977 if (useHighContrastTheme()) {
1978 currentTheme = new MetalHighContrastTheme();
1979 } else {
1980 // Create the default theme. We prefer Ocean, but will
1981 // use DefaultMetalTheme if told to.
1982 String theme = AccessController
1983 .doPrivileged(new GetPropertyAction(
1984 "swing.metalTheme"));
1985 if ("steel".equals(theme)) {
1986 currentTheme = new DefaultMetalTheme();
1987 } else {
1988 currentTheme = new OceanTheme();
1989 }
1990 }
1991 setCurrentTheme(currentTheme);
1992 }
1993 cachedAppContext = context;
1994 }
1995
1996 return currentTheme;
1997 }
1998
1999 /**
2000 * Returns an <code>Icon</code> with a disabled appearance.
2001 * This method is used to generate a disabled <code>Icon</code> when
2002 * one has not been specified. For example, if you create a
2003 * <code>JButton</code> and only specify an <code>Icon</code> via
2004 * <code>setIcon</code> this method will be called to generate the
2005 * disabled <code>Icon</code>. If null is passed as <code>icon</code>
2006 * this method returns null.
2007 * <p>
2008 * Some look and feels might not render the disabled Icon, in which
2009 * case they will ignore this.
2010 *
2011 * @param component JComponent that will display the Icon, may be null
2012 * @param icon Icon to generate disable icon from.
2013 * @return Disabled icon, or null if a suitable Icon can not be
2014 * generated.
2015 * @since 1.5
2016 */
2017 public Icon getDisabledIcon(JComponent component, Icon icon) {
2018 if ((icon instanceof ImageIcon)
2019 && MetalLookAndFeel.usingOcean()) {
2020 return MetalUtils
2021 .getOceanDisabledButtonIcon(((ImageIcon) icon)
2022 .getImage());
2023 }
2024 return super .getDisabledIcon(component, icon);
2025 }
2026
2027 /**
2028 * Returns an <code>Icon</code> for use by disabled
2029 * components that are also selected. This method is used to generate an
2030 * <code>Icon</code> for components that are in both the disabled and
2031 * selected states but do not have a specific <code>Icon</code> for this
2032 * state. For example, if you create a <code>JButton</code> and only
2033 * specify an <code>Icon</code> via <code>setIcon</code> this method
2034 * will be called to generate the disabled and selected
2035 * <code>Icon</code>. If null is passed as <code>icon</code> this method
2036 * returns null.
2037 * <p>
2038 * Some look and feels might not render the disabled and selected Icon,
2039 * in which case they will ignore this.
2040 *
2041 * @param component JComponent that will display the Icon, may be null
2042 * @param icon Icon to generate disabled and selected icon from.
2043 * @return Disabled and Selected icon, or null if a suitable Icon can not
2044 * be generated.
2045 * @since 1.5
2046 */
2047 public Icon getDisabledSelectedIcon(JComponent component, Icon icon) {
2048 if ((icon instanceof ImageIcon)
2049 && MetalLookAndFeel.usingOcean()) {
2050 return MetalUtils
2051 .getOceanDisabledButtonIcon(((ImageIcon) icon)
2052 .getImage());
2053 }
2054 return super .getDisabledSelectedIcon(component, icon);
2055 }
2056
2057 /**
2058 * Returns the control text font of the current theme. This is a
2059 * cover method for {@code getCurrentTheme().getControlTextColor()}.
2060 *
2061 * @return the control text font
2062 *
2063 * @see MetalTheme
2064 */
2065 public static FontUIResource getControlTextFont() {
2066 return getCurrentTheme().getControlTextFont();
2067 }
2068
2069 /**
2070 * Returns the sytem text font of the current theme. This is a
2071 * cover method for {@code getCurrentTheme().getSystemTextFont()}.
2072 *
2073 * @return the system text font
2074 *
2075 * @see MetalTheme
2076 */
2077 public static FontUIResource getSystemTextFont() {
2078 return getCurrentTheme().getSystemTextFont();
2079 }
2080
2081 /**
2082 * Returns the user text font of the current theme. This is a
2083 * cover method for {@code getCurrentTheme().getUserTextFont()}.
2084 *
2085 * @return the user text font
2086 *
2087 * @see MetalTheme
2088 */
2089 public static FontUIResource getUserTextFont() {
2090 return getCurrentTheme().getUserTextFont();
2091 }
2092
2093 /**
2094 * Returns the menu text font of the current theme. This is a
2095 * cover method for {@code getCurrentTheme().getMenuTextFont()}.
2096 *
2097 * @return the menu text font
2098 *
2099 * @see MetalTheme
2100 */
2101 public static FontUIResource getMenuTextFont() {
2102 return getCurrentTheme().getMenuTextFont();
2103 }
2104
2105 /**
2106 * Returns the window title font of the current theme. This is a
2107 * cover method for {@code getCurrentTheme().getWindowTitleFont()}.
2108 *
2109 * @return the window title font
2110 *
2111 * @see MetalTheme
2112 */
2113 public static FontUIResource getWindowTitleFont() {
2114 return getCurrentTheme().getWindowTitleFont();
2115 }
2116
2117 /**
2118 * Returns the sub-text font of the current theme. This is a
2119 * cover method for {@code getCurrentTheme().getSubTextFont()}.
2120 *
2121 * @return the sub-text font
2122 *
2123 * @see MetalTheme
2124 */
2125 public static FontUIResource getSubTextFont() {
2126 return getCurrentTheme().getSubTextFont();
2127 }
2128
2129 /**
2130 * Returns the desktop color of the current theme. This is a
2131 * cover method for {@code getCurrentTheme().getDesktopColor()}.
2132 *
2133 * @return the desktop color
2134 *
2135 * @see MetalTheme
2136 */
2137 public static ColorUIResource getDesktopColor() {
2138 return getCurrentTheme().getDesktopColor();
2139 }
2140
2141 /**
2142 * Returns the focus color of the current theme. This is a
2143 * cover method for {@code getCurrentTheme().getFocusColor()}.
2144 *
2145 * @return the focus color
2146 *
2147 * @see MetalTheme
2148 */
2149 public static ColorUIResource getFocusColor() {
2150 return getCurrentTheme().getFocusColor();
2151 }
2152
2153 /**
2154 * Returns the white color of the current theme. This is a
2155 * cover method for {@code getCurrentTheme().getWhite()}.
2156 *
2157 * @return the white color
2158 *
2159 * @see MetalTheme
2160 */
2161 public static ColorUIResource getWhite() {
2162 return getCurrentTheme().getWhite();
2163 }
2164
2165 /**
2166 * Returns the black color of the current theme. This is a
2167 * cover method for {@code getCurrentTheme().getBlack()}.
2168 *
2169 * @return the black color
2170 *
2171 * @see MetalTheme
2172 */
2173 public static ColorUIResource getBlack() {
2174 return getCurrentTheme().getBlack();
2175 }
2176
2177 /**
2178 * Returns the control color of the current theme. This is a
2179 * cover method for {@code getCurrentTheme().getControl()}.
2180 *
2181 * @return the control color
2182 *
2183 * @see MetalTheme
2184 */
2185 public static ColorUIResource getControl() {
2186 return getCurrentTheme().getControl();
2187 }
2188
2189 /**
2190 * Returns the control shadow color of the current theme. This is a
2191 * cover method for {@code getCurrentTheme().getControlShadow()}.
2192 *
2193 * @return the control shadow color
2194 *
2195 * @see MetalTheme
2196 */
2197 public static ColorUIResource getControlShadow() {
2198 return getCurrentTheme().getControlShadow();
2199 }
2200
2201 /**
2202 * Returns the control dark shadow color of the current theme. This is a
2203 * cover method for {@code getCurrentTheme().getControlDarkShadow()}.
2204 *
2205 * @return the control dark shadow color
2206 *
2207 * @see MetalTheme
2208 */
2209 public static ColorUIResource getControlDarkShadow() {
2210 return getCurrentTheme().getControlDarkShadow();
2211 }
2212
2213 /**
2214 * Returns the control info color of the current theme. This is a
2215 * cover method for {@code getCurrentTheme().getControlInfo()}.
2216 *
2217 * @return the control info color
2218 *
2219 * @see MetalTheme
2220 */
2221 public static ColorUIResource getControlInfo() {
2222 return getCurrentTheme().getControlInfo();
2223 }
2224
2225 /**
2226 * Returns the control highlight color of the current theme. This is a
2227 * cover method for {@code getCurrentTheme().getControlHighlight()}.
2228 *
2229 * @return the control highlight color
2230 *
2231 * @see MetalTheme
2232 */
2233 public static ColorUIResource getControlHighlight() {
2234 return getCurrentTheme().getControlHighlight();
2235 }
2236
2237 /**
2238 * Returns the control disabled color of the current theme. This is a
2239 * cover method for {@code getCurrentTheme().getControlDisabled()}.
2240 *
2241 * @return the control disabled color
2242 *
2243 * @see MetalTheme
2244 */
2245 public static ColorUIResource getControlDisabled() {
2246 return getCurrentTheme().getControlDisabled();
2247 }
2248
2249 /**
2250 * Returns the primary control color of the current theme. This is a
2251 * cover method for {@code getCurrentTheme().getPrimaryControl()}.
2252 *
2253 * @return the primary control color
2254 *
2255 * @see MetalTheme
2256 */
2257 public static ColorUIResource getPrimaryControl() {
2258 return getCurrentTheme().getPrimaryControl();
2259 }
2260
2261 /**
2262 * Returns the primary control shadow color of the current theme. This is a
2263 * cover method for {@code getCurrentTheme().getPrimaryControlShadow()}.
2264 *
2265 * @return the primary control shadow color
2266 *
2267 * @see MetalTheme
2268 */
2269 public static ColorUIResource getPrimaryControlShadow() {
2270 return getCurrentTheme().getPrimaryControlShadow();
2271 }
2272
2273 /**
2274 * Returns the primary control dark shadow color of the current
2275 * theme. This is a cover method for {@code
2276 * getCurrentTheme().getPrimaryControlDarkShadow()}.
2277 *
2278 * @return the primary control dark shadow color
2279 *
2280 * @see MetalTheme
2281 */
2282 public static ColorUIResource getPrimaryControlDarkShadow() {
2283 return getCurrentTheme().getPrimaryControlDarkShadow();
2284 }
2285
2286 /**
2287 * Returns the primary control info color of the current theme. This is a
2288 * cover method for {@code getCurrentTheme().getPrimaryControlInfo()}.
2289 *
2290 * @return the primary control info color
2291 *
2292 * @see MetalTheme
2293 */
2294 public static ColorUIResource getPrimaryControlInfo() {
2295 return getCurrentTheme().getPrimaryControlInfo();
2296 }
2297
2298 /**
2299 * Returns the primary control highlight color of the current
2300 * theme. This is a cover method for {@code
2301 * getCurrentTheme().getPrimaryControlHighlight()}.
2302 *
2303 * @return the primary control highlight color
2304 *
2305 * @see MetalTheme
2306 */
2307 public static ColorUIResource getPrimaryControlHighlight() {
2308 return getCurrentTheme().getPrimaryControlHighlight();
2309 }
2310
2311 /**
2312 * Returns the system text color of the current theme. This is a
2313 * cover method for {@code getCurrentTheme().getSystemTextColor()}.
2314 *
2315 * @return the system text color
2316 *
2317 * @see MetalTheme
2318 */
2319 public static ColorUIResource getSystemTextColor() {
2320 return getCurrentTheme().getSystemTextColor();
2321 }
2322
2323 /**
2324 * Returns the control text color of the current theme. This is a
2325 * cover method for {@code getCurrentTheme().getControlTextColor()}.
2326 *
2327 * @return the control text color
2328 *
2329 * @see MetalTheme
2330 */
2331 public static ColorUIResource getControlTextColor() {
2332 return getCurrentTheme().getControlTextColor();
2333 }
2334
2335 /**
2336 * Returns the inactive control text color of the current theme. This is a
2337 * cover method for {@code
2338 * getCurrentTheme().getInactiveControlTextColor()}.
2339 *
2340 * @return the inactive control text color
2341 *
2342 * @see MetalTheme
2343 */
2344 public static ColorUIResource getInactiveControlTextColor() {
2345 return getCurrentTheme().getInactiveControlTextColor();
2346 }
2347
2348 /**
2349 * Returns the inactive system text color of the current theme. This is a
2350 * cover method for {@code
2351 * getCurrentTheme().getInactiveSystemTextColor()}.
2352 *
2353 * @return the inactive system text color
2354 *
2355 * @see MetalTheme
2356 */
2357 public static ColorUIResource getInactiveSystemTextColor() {
2358 return getCurrentTheme().getInactiveSystemTextColor();
2359 }
2360
2361 /**
2362 * Returns the user text color of the current theme. This is a
2363 * cover method for {@code getCurrentTheme().getUserTextColor()}.
2364 *
2365 * @return the user text color
2366 *
2367 * @see MetalTheme
2368 */
2369 public static ColorUIResource getUserTextColor() {
2370 return getCurrentTheme().getUserTextColor();
2371 }
2372
2373 /**
2374 * Returns the text highlight color of the current theme. This is a
2375 * cover method for {@code getCurrentTheme().getTextHighlightColor()}.
2376 *
2377 * @return the text highlight color
2378 *
2379 * @see MetalTheme
2380 */
2381 public static ColorUIResource getTextHighlightColor() {
2382 return getCurrentTheme().getTextHighlightColor();
2383 }
2384
2385 /**
2386 * Returns the highlighted text color of the current theme. This is a
2387 * cover method for {@code getCurrentTheme().getHighlightedTextColor()}.
2388 *
2389 * @return the highlighted text color
2390 *
2391 * @see MetalTheme
2392 */
2393 public static ColorUIResource getHighlightedTextColor() {
2394 return getCurrentTheme().getHighlightedTextColor();
2395 }
2396
2397 /**
2398 * Returns the window background color of the current theme. This is a
2399 * cover method for {@code getCurrentTheme().getWindowBackground()}.
2400 *
2401 * @return the window background color
2402 *
2403 * @see MetalTheme
2404 */
2405 public static ColorUIResource getWindowBackground() {
2406 return getCurrentTheme().getWindowBackground();
2407 }
2408
2409 /**
2410 * Returns the window title background color of the current
2411 * theme. This is a cover method for {@code
2412 * getCurrentTheme().getWindowTitleBackground()}.
2413 *
2414 * @return the window title background color
2415 *
2416 * @see MetalTheme
2417 */
2418 public static ColorUIResource getWindowTitleBackground() {
2419 return getCurrentTheme().getWindowTitleBackground();
2420 }
2421
2422 /**
2423 * Returns the window title foreground color of the current
2424 * theme. This is a cover method for {@code
2425 * getCurrentTheme().getWindowTitleForeground()}.
2426 *
2427 * @return the window title foreground color
2428 *
2429 * @see MetalTheme
2430 */
2431 public static ColorUIResource getWindowTitleForeground() {
2432 return getCurrentTheme().getWindowTitleForeground();
2433 }
2434
2435 /**
2436 * Returns the window title inactive background color of the current
2437 * theme. This is a cover method for {@code
2438 * getCurrentTheme().getWindowTitleInactiveBackground()}.
2439 *
2440 * @return the window title inactive background color
2441 *
2442 * @see MetalTheme
2443 */
2444 public static ColorUIResource getWindowTitleInactiveBackground() {
2445 return getCurrentTheme().getWindowTitleInactiveBackground();
2446 }
2447
2448 /**
2449 * Returns the window title inactive foreground color of the current
2450 * theme. This is a cover method for {@code
2451 * getCurrentTheme().getWindowTitleInactiveForeground()}.
2452 *
2453 * @return the window title inactive foreground color
2454 *
2455 * @see MetalTheme
2456 */
2457 public static ColorUIResource getWindowTitleInactiveForeground() {
2458 return getCurrentTheme().getWindowTitleInactiveForeground();
2459 }
2460
2461 /**
2462 * Returns the menu background color of the current theme. This is
2463 * a cover method for {@code getCurrentTheme().getMenuBackground()}.
2464 *
2465 * @return the menu background color
2466 *
2467 * @see MetalTheme
2468 */
2469 public static ColorUIResource getMenuBackground() {
2470 return getCurrentTheme().getMenuBackground();
2471 }
2472
2473 /**
2474 * Returns the menu foreground color of the current theme. This is
2475 * a cover method for {@code getCurrentTheme().getMenuForeground()}.
2476 *
2477 * @return the menu foreground color
2478 *
2479 * @see MetalTheme
2480 */
2481 public static ColorUIResource getMenuForeground() {
2482 return getCurrentTheme().getMenuForeground();
2483 }
2484
2485 /**
2486 * Returns the menu selected background color of the current theme. This is
2487 * a cover method for
2488 * {@code getCurrentTheme().getMenuSelectedBackground()}.
2489 *
2490 * @return the menu selected background color
2491 *
2492 * @see MetalTheme
2493 */
2494 public static ColorUIResource getMenuSelectedBackground() {
2495 return getCurrentTheme().getMenuSelectedBackground();
2496 }
2497
2498 /**
2499 * Returns the menu selected foreground color of the current theme. This is
2500 * a cover method for
2501 * {@code getCurrentTheme().getMenuSelectedForeground()}.
2502 *
2503 * @return the menu selected foreground color
2504 *
2505 * @see MetalTheme
2506 */
2507 public static ColorUIResource getMenuSelectedForeground() {
2508 return getCurrentTheme().getMenuSelectedForeground();
2509 }
2510
2511 /**
2512 * Returns the menu disabled foreground color of the current theme. This is
2513 * a cover method for
2514 * {@code getCurrentTheme().getMenuDisabledForeground()}.
2515 *
2516 * @return the menu disabled foreground color
2517 *
2518 * @see MetalTheme
2519 */
2520 public static ColorUIResource getMenuDisabledForeground() {
2521 return getCurrentTheme().getMenuDisabledForeground();
2522 }
2523
2524 /**
2525 * Returns the separator background color of the current theme. This is
2526 * a cover method for {@code getCurrentTheme().getSeparatorBackground()}.
2527 *
2528 * @return the separator background color
2529 *
2530 * @see MetalTheme
2531 */
2532 public static ColorUIResource getSeparatorBackground() {
2533 return getCurrentTheme().getSeparatorBackground();
2534 }
2535
2536 /**
2537 * Returns the separator foreground color of the current theme. This is
2538 * a cover method for {@code getCurrentTheme().getSeparatorForeground()}.
2539 *
2540 * @return the separator foreground color
2541 *
2542 * @see MetalTheme
2543 */
2544 public static ColorUIResource getSeparatorForeground() {
2545 return getCurrentTheme().getSeparatorForeground();
2546 }
2547
2548 /**
2549 * Returns the accelerator foreground color of the current theme. This is
2550 * a cover method for {@code getCurrentTheme().getAcceleratorForeground()}.
2551 *
2552 * @return the separator accelerator foreground color
2553 *
2554 * @see MetalTheme
2555 */
2556 public static ColorUIResource getAcceleratorForeground() {
2557 return getCurrentTheme().getAcceleratorForeground();
2558 }
2559
2560 /**
2561 * Returns the accelerator selected foreground color of the
2562 * current theme. This is a cover method for {@code
2563 * getCurrentTheme().getAcceleratorSelectedForeground()}.
2564 *
2565 * @return the accelerator selected foreground color
2566 *
2567 * @see MetalTheme
2568 */
2569 public static ColorUIResource getAcceleratorSelectedForeground() {
2570 return getCurrentTheme().getAcceleratorSelectedForeground();
2571 }
2572
2573 /**
2574 * Returns a {@code LayoutStyle} implementing the Java look and feel
2575 * design guidelines as specified at
2576 * <a href="http://java.sun.com/products/jlf/ed2/book/HIG.Visual2.html">http://java.sun.com/products/jlf/ed2/book/HIG.Visual2.html</a>.
2577 *
2578 * @return LayoutStyle implementing the Java look and feel design
2579 * guidelines
2580 * @since 1.6
2581 */
2582 public LayoutStyle getLayoutStyle() {
2583 return MetalLayoutStyle.INSTANCE;
2584 }
2585
2586 /**
2587 * MetalLazyValue is a slimmed down version of <code>ProxyLaxyValue</code>.
2588 * The code is duplicate so that it can get at the package private
2589 * classes in metal.
2590 */
2591 private static class MetalLazyValue implements UIDefaults.LazyValue {
2592 /**
2593 * Name of the class to create.
2594 */
2595 private String className;
2596 private String methodName;
2597
2598 MetalLazyValue(String name) {
2599 this .className = name;
2600 }
2601
2602 MetalLazyValue(String name, String methodName) {
2603 this (name);
2604 this .methodName = methodName;
2605 }
2606
2607 public Object createValue(UIDefaults table) {
2608 try {
2609 final Class c = Class.forName(className);
2610
2611 if (methodName == null) {
2612 return c.newInstance();
2613 }
2614 Method method = (Method) AccessController
2615 .doPrivileged(new PrivilegedAction() {
2616 public Object run() {
2617 Method[] methods = c
2618 .getDeclaredMethods();
2619 for (int counter = methods.length - 1; counter >= 0; counter--) {
2620 if (methods[counter].getName()
2621 .equals(methodName)) {
2622 methods[counter]
2623 .setAccessible(true);
2624 return methods[counter];
2625 }
2626 }
2627 return null;
2628 }
2629 });
2630 if (method != null) {
2631 return method.invoke(null, (Object[]) null);
2632 }
2633 } catch (ClassNotFoundException cnfe) {
2634 } catch (InstantiationException ie) {
2635 } catch (IllegalAccessException iae) {
2636 } catch (InvocationTargetException ite) {
2637 }
2638 return null;
2639 }
2640 }
2641
2642 /**
2643 * FontActiveValue redirects to the appropriate metal theme method.
2644 */
2645 private static class FontActiveValue implements
2646 UIDefaults.ActiveValue {
2647 private int type;
2648 private MetalTheme theme;
2649
2650 FontActiveValue(MetalTheme theme, int type) {
2651 this .theme = theme;
2652 this .type = type;
2653 }
2654
2655 public Object createValue(UIDefaults table) {
2656 Object value = null;
2657 switch (type) {
2658 case MetalTheme.CONTROL_TEXT_FONT:
2659 value = theme.getControlTextFont();
2660 break;
2661 case MetalTheme.SYSTEM_TEXT_FONT:
2662 value = theme.getSystemTextFont();
2663 break;
2664 case MetalTheme.USER_TEXT_FONT:
2665 value = theme.getUserTextFont();
2666 break;
2667 case MetalTheme.MENU_TEXT_FONT:
2668 value = theme.getMenuTextFont();
2669 break;
2670 case MetalTheme.WINDOW_TITLE_FONT:
2671 value = theme.getWindowTitleFont();
2672 break;
2673 case MetalTheme.SUB_TEXT_FONT:
2674 value = theme.getSubTextFont();
2675 break;
2676 }
2677 return value;
2678 }
2679 }
2680
2681 static ReferenceQueue queue = new ReferenceQueue();
2682
2683 static void flushUnreferenced() {
2684 AATextListener aatl;
2685 while ((aatl = (AATextListener) queue.poll()) != null) {
2686 aatl.dispose();
2687 }
2688 }
2689
2690 static class AATextListener extends WeakReference implements
2691 PropertyChangeListener {
2692
2693 private String key = SunToolkit.DESKTOPFONTHINTS;
2694
2695 AATextListener(LookAndFeel laf) {
2696 super (laf, queue);
2697 Toolkit tk = Toolkit.getDefaultToolkit();
2698 tk.addPropertyChangeListener(key, this );
2699 }
2700
2701 public void propertyChange(PropertyChangeEvent pce) {
2702 LookAndFeel laf = (LookAndFeel) get();
2703 if (laf == null || laf != UIManager.getLookAndFeel()) {
2704 dispose();
2705 return;
2706 }
2707 UIDefaults defaults = UIManager.getLookAndFeelDefaults();
2708 boolean lafCond = SwingUtilities2.isLocalDisplay();
2709 Object aaTextInfo = SwingUtilities2.AATextInfo
2710 .getAATextInfo(lafCond);
2711 defaults.put(SwingUtilities2.AA_TEXT_PROPERTY_KEY,
2712 aaTextInfo);
2713 updateUI();
2714 }
2715
2716 void dispose() {
2717 Toolkit tk = Toolkit.getDefaultToolkit();
2718 tk.removePropertyChangeListener(key, this );
2719 }
2720
2721 /**
2722 * Updates the UI of the passed in window and all its children.
2723 */
2724 private static void updateWindowUI(Window window) {
2725 SwingUtilities.updateComponentTreeUI(window);
2726 Window ownedWins[] = window.getOwnedWindows();
2727 for (int i = 0; i < ownedWins.length; i++) {
2728 updateWindowUI(ownedWins[i]);
2729 }
2730 }
2731
2732 /**
2733 * Updates the UIs of all the known Frames.
2734 */
2735 private static void updateAllUIs() {
2736 Frame appFrames[] = Frame.getFrames();
2737 for (int j = 0; j < appFrames.length; j++) {
2738 updateWindowUI(appFrames[j]);
2739 }
2740 }
2741
2742 /**
2743 * Indicates if an updateUI call is pending.
2744 */
2745 private static boolean updatePending;
2746
2747 /**
2748 * Sets whether or not an updateUI call is pending.
2749 */
2750 private static synchronized void setUpdatePending(boolean update) {
2751 updatePending = update;
2752 }
2753
2754 /**
2755 * Returns true if a UI update is pending.
2756 */
2757 private static synchronized boolean isUpdatePending() {
2758 return updatePending;
2759 }
2760
2761 protected void updateUI() {
2762 if (!isUpdatePending()) {
2763 setUpdatePending(true);
2764 Runnable uiUpdater = new Runnable() {
2765 public void run() {
2766 updateAllUIs();
2767 setUpdatePending(false);
2768 }
2769 };
2770 SwingUtilities.invokeLater(uiUpdater);
2771 }
2772 }
2773 }
2774
2775 // From the JLF Design Guidelines:
2776 // http://java.sun.com/products/jlf/ed2/book/HIG.Visual2.html
2777 private static class MetalLayoutStyle extends DefaultLayoutStyle {
2778 private static MetalLayoutStyle INSTANCE = new MetalLayoutStyle();
2779
2780 @Override
2781 public int getPreferredGap(JComponent component1,
2782 JComponent component2, ComponentPlacement type,
2783 int position, Container parent) {
2784 // Checks args
2785 super .getPreferredGap(component1, component2, type,
2786 position, parent);
2787
2788 int offset = 0;
2789
2790 switch (type) {
2791 case INDENT:
2792 // Metal doesn't spec this.
2793 if (position == SwingConstants.EAST
2794 || position == SwingConstants.WEST) {
2795 int indent = getIndent(component1, position);
2796 if (indent > 0) {
2797 return indent;
2798 }
2799 return 12;
2800 }
2801 // Fall through to related.
2802 case RELATED:
2803 if (component1.getUIClassID() == "ToggleButtonUI"
2804 && component2.getUIClassID() == "ToggleButtonUI") {
2805 ButtonModel sourceModel = ((JToggleButton) component1)
2806 .getModel();
2807 ButtonModel targetModel = ((JToggleButton) component2)
2808 .getModel();
2809 if ((sourceModel instanceof DefaultButtonModel)
2810 && (targetModel instanceof DefaultButtonModel)
2811 && (((DefaultButtonModel) sourceModel)
2812 .getGroup() == ((DefaultButtonModel) targetModel)
2813 .getGroup())
2814 && ((DefaultButtonModel) sourceModel)
2815 .getGroup() != null) {
2816 // When toggle buttons are exclusive (that is,
2817 // they form a radio button set), separate
2818 // them with 2 pixels. This rule applies
2819 // whether the toggle buttons appear in a
2820 // toolbar or elsewhere in the interface.
2821 // Note: this number does not appear to
2822 // include any borders and so is not adjusted
2823 // by the border of the toggle button
2824 return 2;
2825 }
2826 // When toggle buttons are independent (like
2827 // checkboxes) and used outside a toolbar,
2828 // separate them with 5 pixels.
2829 if (usingOcean()) {
2830 return 6;
2831 }
2832 return 5;
2833 }
2834 offset = 6;
2835 break;
2836 case UNRELATED:
2837 offset = 12;
2838 break;
2839 }
2840 if (isLabelAndNonlabel(component1, component2, position)) {
2841 // Insert 12 pixels between the trailing edge of a
2842 // label and any associated components. Insert 12
2843 // pixels between the trailing edge of a label and the
2844 // component it describes when labels are
2845 // right-aligned. When labels are left-aligned, insert
2846 // 12 pixels between the trailing edge of the longest
2847 // label and its associated component
2848 return getButtonGap(component1, component2, position,
2849 offset + 6);
2850 }
2851 return getButtonGap(component1, component2, position,
2852 offset);
2853 }
2854
2855 @Override
2856 public int getContainerGap(JComponent component, int position,
2857 Container parent) {
2858 super .getContainerGap(component, position, parent);
2859 // Include 11 pixels between the bottom and right
2860 // borders of a dialog box and its command
2861 // buttons. (To the eye, the 11-pixel spacing appears
2862 // to be 12 pixels because the white borders on the
2863 // lower and right edges of the button components are
2864 // not visually significant.)
2865 // NOTE: this last text was designed with Steel in mind,
2866 // not Ocean.
2867 //
2868 // Insert 12 pixels between the edges of the panel and the
2869 // titled border. Insert 11 pixels between the top of the
2870 // title and the component above the titled border. Insert 12
2871 // pixels between the bottom of the title and the top of the
2872 // first label in the panel. Insert 11 pixels between
2873 // component groups and between the bottom of the last
2874 // component and the lower border.
2875 return getButtonGap(component, position,
2876 12 - getButtonAdjustment(component, position));
2877 }
2878
2879 @Override
2880 protected int getButtonGap(JComponent source,
2881 JComponent target, int position, int offset) {
2882 offset = super .getButtonGap(source, target, position,
2883 offset);
2884 if (offset > 0) {
2885 int buttonAdjustment = getButtonAdjustment(source,
2886 position);
2887 if (buttonAdjustment == 0) {
2888 buttonAdjustment = getButtonAdjustment(target,
2889 flipDirection(position));
2890 }
2891 offset -= buttonAdjustment;
2892 }
2893 if (offset < 0) {
2894 return 0;
2895 }
2896 return offset;
2897 }
2898
2899 private int getButtonAdjustment(JComponent source, int edge) {
2900 String classID = source.getUIClassID();
2901 if (classID == "ButtonUI" || classID == "ToggleButtonUI") {
2902 if (!usingOcean()
2903 && (edge == SwingConstants.EAST || edge == SwingConstants.SOUTH)) {
2904 if (source.getBorder() instanceof UIResource) {
2905 return 1;
2906 }
2907 }
2908 } else if (edge == SwingConstants.SOUTH) {
2909 if ((classID == "RadioButtonUI" || classID == "CheckBoxUI")
2910 && !usingOcean()) {
2911 return 1;
2912 }
2913 }
2914 return 0;
2915 }
2916 }
2917 }
|