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