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