1/* 2 * Copyright (c) 1997, 2017, 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/* 27 * <p>These classes are designed to be used while the 28 * corresponding <code>LookAndFeel</code> class has been installed 29 * (<code>UIManager.setLookAndFeel(new <i>XXX</i>LookAndFeel())</code>). 30 * Using them while a different <code>LookAndFeel</code> is installed 31 * may produce unexpected results, including exceptions. 32 * Additionally, changing the <code>LookAndFeel</code> 33 * maintained by the <code>UIManager</code> without updating the 34 * corresponding <code>ComponentUI</code> of any 35 * <code>JComponent</code>s may also produce unexpected results, 36 * such as the wrong colors showing up, and is generally not 37 * encouraged. 38 * 39 */ 40 41package com.sun.java.swing.plaf.windows; 42 43import java.awt.*; 44import java.awt.image.BufferedImage; 45import java.awt.image.ImageFilter; 46import java.awt.image.ImageProducer; 47import java.awt.image.FilteredImageSource; 48import java.awt.image.RGBImageFilter; 49 50import javax.swing.plaf.*; 51import javax.swing.*; 52import javax.swing.plaf.basic.*; 53import javax.swing.border.*; 54import javax.swing.text.DefaultEditorKit; 55import static javax.swing.UIDefaults.LazyValue; 56 57import java.awt.Font; 58import java.awt.Color; 59import java.awt.event.ActionEvent; 60 61import java.security.AccessController; 62 63import sun.awt.SunToolkit; 64import sun.awt.OSInfo; 65import sun.awt.shell.ShellFolder; 66import sun.font.FontUtilities; 67import sun.security.action.GetPropertyAction; 68 69import sun.swing.DefaultLayoutStyle; 70import sun.swing.ImageIconUIResource; 71import sun.swing.SwingAccessor; 72import sun.swing.icon.SortArrowIcon; 73import sun.swing.SwingUtilities2; 74import sun.swing.StringUIClientPropertyKey; 75import sun.swing.plaf.windows.ClassicSortArrowIcon; 76 77import static com.sun.java.swing.plaf.windows.TMSchema.*; 78import static com.sun.java.swing.plaf.windows.XPStyle.Skin; 79 80import com.sun.java.swing.plaf.windows.WindowsIconFactory.VistaMenuItemCheckIconFactory; 81 82/** 83 * Implements the Windows95/98/NT/2000 Look and Feel. 84 * UI classes not implemented specifically for Windows will 85 * default to those implemented in Basic. 86 * <p> 87 * <strong>Warning:</strong> 88 * Serialized objects of this class will not be compatible with 89 * future Swing releases. The current serialization support is appropriate 90 * for short term storage or RMI between applications running the same 91 * version of Swing. A future release of Swing will provide support for 92 * long term persistence. 93 * 94 * @author unattributed 95 */ 96@SuppressWarnings("serial") // Superclass is not serializable across versions 97public class WindowsLookAndFeel extends BasicLookAndFeel 98{ 99 /** 100 * A client property that can be used with any JComponent that will end up 101 * calling the LookAndFeel.getDisabledIcon method. This client property, 102 * when set to Boolean.TRUE, will cause getDisabledIcon to use an 103 * alternate algorithm for creating disabled icons to produce icons 104 * that appear similar to the native Windows file chooser 105 */ 106 static final Object HI_RES_DISABLED_ICON_CLIENT_KEY = 107 new StringUIClientPropertyKey( 108 "WindowsLookAndFeel.generateHiResDisabledIcon"); 109 110 private boolean updatePending = false; 111 112 private boolean useSystemFontSettings = true; 113 private boolean useSystemFontSizeSettings; 114 115 // These properties are not used directly, but are kept as 116 // private members to avoid being GC'd. 117 private DesktopProperty themeActive, dllName, colorName, sizeName; 118 private DesktopProperty aaSettings; 119 120 private transient LayoutStyle style; 121 122 /** 123 * Base dialog units along the horizontal axis. 124 */ 125 private int baseUnitX; 126 127 /** 128 * Base dialog units along the vertical axis. 129 */ 130 private int baseUnitY; 131 132 public String getName() { 133 return "Windows"; 134 } 135 136 public String getDescription() { 137 return "The Microsoft Windows Look and Feel"; 138 } 139 140 public String getID() { 141 return "Windows"; 142 } 143 144 public boolean isNativeLookAndFeel() { 145 return OSInfo.getOSType() == OSInfo.OSType.WINDOWS; 146 } 147 148 public boolean isSupportedLookAndFeel() { 149 return isNativeLookAndFeel(); 150 } 151 152 public void initialize() { 153 super.initialize(); 154 155 // Set the flag which determines which version of Windows should 156 // be rendered. This flag only need to be set once. 157 // if version <= 4.0 then the classic LAF should be loaded. 158 if (OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_95) <= 0) { 159 isClassicWindows = true; 160 } else { 161 isClassicWindows = false; 162 XPStyle.invalidateStyle(); 163 } 164 165 // Using the fonts set by the user can potentially cause 166 // performance and compatibility issues, so allow this feature 167 // to be switched off either at runtime or programmatically 168 // 169 String systemFonts = java.security.AccessController.doPrivileged( 170 new GetPropertyAction("swing.useSystemFontSettings")); 171 useSystemFontSettings = (systemFonts == null || 172 Boolean.valueOf(systemFonts).booleanValue()); 173 174 if (useSystemFontSettings) { 175 Object value = UIManager.get("Application.useSystemFontSettings"); 176 177 useSystemFontSettings = (value == null || 178 Boolean.TRUE.equals(value)); 179 } 180 KeyboardFocusManager.getCurrentKeyboardFocusManager(). 181 addKeyEventPostProcessor(WindowsRootPaneUI.altProcessor); 182 183 } 184 185 /** 186 * Initialize the uiClassID to BasicComponentUI mapping. 187 * The JComponent classes define their own uiClassID constants 188 * (see AbstractComponent.getUIClassID). This table must 189 * map those constants to a BasicComponentUI class of the 190 * appropriate type. 191 * 192 * @see BasicLookAndFeel#getDefaults 193 */ 194 protected void initClassDefaults(UIDefaults table) 195 { 196 super.initClassDefaults(table); 197 198 final String windowsPackageName = "com.sun.java.swing.plaf.windows."; 199 200 Object[] uiDefaults = { 201 "ButtonUI", windowsPackageName + "WindowsButtonUI", 202 "CheckBoxUI", windowsPackageName + "WindowsCheckBoxUI", 203 "CheckBoxMenuItemUI", windowsPackageName + "WindowsCheckBoxMenuItemUI", 204 "LabelUI", windowsPackageName + "WindowsLabelUI", 205 "RadioButtonUI", windowsPackageName + "WindowsRadioButtonUI", 206 "RadioButtonMenuItemUI", windowsPackageName + "WindowsRadioButtonMenuItemUI", 207 "ToggleButtonUI", windowsPackageName + "WindowsToggleButtonUI", 208 "ProgressBarUI", windowsPackageName + "WindowsProgressBarUI", 209 "SliderUI", windowsPackageName + "WindowsSliderUI", 210 "SeparatorUI", windowsPackageName + "WindowsSeparatorUI", 211 "SplitPaneUI", windowsPackageName + "WindowsSplitPaneUI", 212 "SpinnerUI", windowsPackageName + "WindowsSpinnerUI", 213 "TabbedPaneUI", windowsPackageName + "WindowsTabbedPaneUI", 214 "TextAreaUI", windowsPackageName + "WindowsTextAreaUI", 215 "TextFieldUI", windowsPackageName + "WindowsTextFieldUI", 216 "PasswordFieldUI", windowsPackageName + "WindowsPasswordFieldUI", 217 "TextPaneUI", windowsPackageName + "WindowsTextPaneUI", 218 "EditorPaneUI", windowsPackageName + "WindowsEditorPaneUI", 219 "TreeUI", windowsPackageName + "WindowsTreeUI", 220 "ToolBarUI", windowsPackageName + "WindowsToolBarUI", 221 "ToolBarSeparatorUI", windowsPackageName + "WindowsToolBarSeparatorUI", 222 "ComboBoxUI", windowsPackageName + "WindowsComboBoxUI", 223 "TableHeaderUI", windowsPackageName + "WindowsTableHeaderUI", 224 "InternalFrameUI", windowsPackageName + "WindowsInternalFrameUI", 225 "DesktopPaneUI", windowsPackageName + "WindowsDesktopPaneUI", 226 "DesktopIconUI", windowsPackageName + "WindowsDesktopIconUI", 227 "FileChooserUI", windowsPackageName + "WindowsFileChooserUI", 228 "MenuUI", windowsPackageName + "WindowsMenuUI", 229 "MenuItemUI", windowsPackageName + "WindowsMenuItemUI", 230 "MenuBarUI", windowsPackageName + "WindowsMenuBarUI", 231 "PopupMenuUI", windowsPackageName + "WindowsPopupMenuUI", 232 "PopupMenuSeparatorUI", windowsPackageName + "WindowsPopupMenuSeparatorUI", 233 "ScrollBarUI", windowsPackageName + "WindowsScrollBarUI", 234 "RootPaneUI", windowsPackageName + "WindowsRootPaneUI" 235 }; 236 237 table.putDefaults(uiDefaults); 238 } 239 240 /** 241 * Load the SystemColors into the defaults table. The keys 242 * for SystemColor defaults are the same as the names of 243 * the public fields in SystemColor. If the table is being 244 * created on a native Windows platform we use the SystemColor 245 * values, otherwise we create color objects whose values match 246 * the defaults Windows95 colors. 247 */ 248 protected void initSystemColorDefaults(UIDefaults table) 249 { 250 String[] defaultSystemColors = { 251 "desktop", "#005C5C", /* Color of the desktop background */ 252 "activeCaption", "#000080", /* Color for captions (title bars) when they are active. */ 253 "activeCaptionText", "#FFFFFF", /* Text color for text in captions (title bars). */ 254 "activeCaptionBorder", "#C0C0C0", /* Border color for caption (title bar) window borders. */ 255 "inactiveCaption", "#808080", /* Color for captions (title bars) when not active. */ 256 "inactiveCaptionText", "#C0C0C0", /* Text color for text in inactive captions (title bars). */ 257 "inactiveCaptionBorder", "#C0C0C0", /* Border color for inactive caption (title bar) window borders. */ 258 "window", "#FFFFFF", /* Default color for the interior of windows */ 259 "windowBorder", "#000000", /* ??? */ 260 "windowText", "#000000", /* ??? */ 261 "menu", "#C0C0C0", /* Background color for menus */ 262 "menuPressedItemB", "#000080", /* LightShadow of menubutton highlight */ 263 "menuPressedItemF", "#FFFFFF", /* Default color for foreground "text" in menu item */ 264 "menuText", "#000000", /* Text color for menus */ 265 "text", "#C0C0C0", /* Text background color */ 266 "textText", "#000000", /* Text foreground color */ 267 "textHighlight", "#000080", /* Text background color when selected */ 268 "textHighlightText", "#FFFFFF", /* Text color when selected */ 269 "textInactiveText", "#808080", /* Text color when disabled */ 270 "control", "#C0C0C0", /* Default color for controls (buttons, sliders, etc) */ 271 "controlText", "#000000", /* Default color for text in controls */ 272 "controlHighlight", "#C0C0C0", 273 274 /*"controlHighlight", "#E0E0E0",*/ /* Specular highlight (opposite of the shadow) */ 275 "controlLtHighlight", "#FFFFFF", /* Highlight color for controls */ 276 "controlShadow", "#808080", /* Shadow color for controls */ 277 "controlDkShadow", "#000000", /* Dark shadow color for controls */ 278 "scrollbar", "#E0E0E0", /* Scrollbar background (usually the "track") */ 279 "info", "#FFFFE1", /* ??? */ 280 "infoText", "#000000" /* ??? */ 281 }; 282 283 loadSystemColors(table, defaultSystemColors, isNativeLookAndFeel()); 284 } 285 286 /** 287 * Initialize the defaults table with the name of the ResourceBundle 288 * used for getting localized defaults. 289 */ 290 private void initResourceBundle(UIDefaults table) { 291 SwingAccessor.getUIDefaultsAccessor() 292 .addInternalBundle(table, 293 "com.sun.java.swing.plaf.windows.resources.windows"); 294 } 295 296 // XXX - there are probably a lot of redundant values that could be removed. 297 // ie. Take a look at RadioButtonBorder, etc... 298 protected void initComponentDefaults(UIDefaults table) 299 { 300 super.initComponentDefaults( table ); 301 302 initResourceBundle(table); 303 304 // *** Shared Fonts 305 LazyValue dialogPlain12 = t -> new FontUIResource(Font.DIALOG, Font.PLAIN, 12); 306 307 LazyValue sansSerifPlain12 = t -> new FontUIResource(Font.SANS_SERIF, Font.PLAIN, 12); 308 LazyValue monospacedPlain12 = t -> new FontUIResource(Font.MONOSPACED, Font.PLAIN, 12); 309 LazyValue dialogBold12 = t -> new FontUIResource(Font.DIALOG, Font.BOLD, 12); 310 311 // *** Colors 312 // XXX - some of these doens't seem to be used 313 ColorUIResource red = new ColorUIResource(Color.red); 314 ColorUIResource black = new ColorUIResource(Color.black); 315 ColorUIResource white = new ColorUIResource(Color.white); 316 ColorUIResource gray = new ColorUIResource(Color.gray); 317 ColorUIResource darkGray = new ColorUIResource(Color.darkGray); 318 ColorUIResource scrollBarTrackHighlight = darkGray; 319 320 // Set the flag which determines which version of Windows should 321 // be rendered. This flag only need to be set once. 322 // if version <= 4.0 then the classic LAF should be loaded. 323 isClassicWindows = OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_95) <= 0; 324 325 // *** Tree 326 Object treeExpandedIcon = WindowsTreeUI.ExpandedIcon.createExpandedIcon(); 327 328 Object treeCollapsedIcon = WindowsTreeUI.CollapsedIcon.createCollapsedIcon(); 329 330 331 // *** Text 332 Object fieldInputMap = new UIDefaults.LazyInputMap(new Object[] { 333 "control C", DefaultEditorKit.copyAction, 334 "control V", DefaultEditorKit.pasteAction, 335 "control X", DefaultEditorKit.cutAction, 336 "COPY", DefaultEditorKit.copyAction, 337 "PASTE", DefaultEditorKit.pasteAction, 338 "CUT", DefaultEditorKit.cutAction, 339 "control INSERT", DefaultEditorKit.copyAction, 340 "shift INSERT", DefaultEditorKit.pasteAction, 341 "shift DELETE", DefaultEditorKit.cutAction, 342 "control A", DefaultEditorKit.selectAllAction, 343 "control BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/, 344 "shift LEFT", DefaultEditorKit.selectionBackwardAction, 345 "shift RIGHT", DefaultEditorKit.selectionForwardAction, 346 "control LEFT", DefaultEditorKit.previousWordAction, 347 "control RIGHT", DefaultEditorKit.nextWordAction, 348 "control shift LEFT", DefaultEditorKit.selectionPreviousWordAction, 349 "control shift RIGHT", DefaultEditorKit.selectionNextWordAction, 350 "HOME", DefaultEditorKit.beginLineAction, 351 "END", DefaultEditorKit.endLineAction, 352 "shift HOME", DefaultEditorKit.selectionBeginLineAction, 353 "shift END", DefaultEditorKit.selectionEndLineAction, 354 "BACK_SPACE", DefaultEditorKit.deletePrevCharAction, 355 "shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction, 356 "ctrl H", DefaultEditorKit.deletePrevCharAction, 357 "DELETE", DefaultEditorKit.deleteNextCharAction, 358 "ctrl DELETE", DefaultEditorKit.deleteNextWordAction, 359 "ctrl BACK_SPACE", DefaultEditorKit.deletePrevWordAction, 360 "RIGHT", DefaultEditorKit.forwardAction, 361 "LEFT", DefaultEditorKit.backwardAction, 362 "KP_RIGHT", DefaultEditorKit.forwardAction, 363 "KP_LEFT", DefaultEditorKit.backwardAction, 364 "ENTER", JTextField.notifyAction, 365 "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/ 366 }); 367 368 Object passwordInputMap = new UIDefaults.LazyInputMap(new Object[] { 369 "control C", DefaultEditorKit.copyAction, 370 "control V", DefaultEditorKit.pasteAction, 371 "control X", DefaultEditorKit.cutAction, 372 "COPY", DefaultEditorKit.copyAction, 373 "PASTE", DefaultEditorKit.pasteAction, 374 "CUT", DefaultEditorKit.cutAction, 375 "control INSERT", DefaultEditorKit.copyAction, 376 "shift INSERT", DefaultEditorKit.pasteAction, 377 "shift DELETE", DefaultEditorKit.cutAction, 378 "control A", DefaultEditorKit.selectAllAction, 379 "control BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/, 380 "shift LEFT", DefaultEditorKit.selectionBackwardAction, 381 "shift RIGHT", DefaultEditorKit.selectionForwardAction, 382 "control LEFT", DefaultEditorKit.beginLineAction, 383 "control RIGHT", DefaultEditorKit.endLineAction, 384 "control shift LEFT", DefaultEditorKit.selectionBeginLineAction, 385 "control shift RIGHT", DefaultEditorKit.selectionEndLineAction, 386 "HOME", DefaultEditorKit.beginLineAction, 387 "END", DefaultEditorKit.endLineAction, 388 "shift HOME", DefaultEditorKit.selectionBeginLineAction, 389 "shift END", DefaultEditorKit.selectionEndLineAction, 390 "BACK_SPACE", DefaultEditorKit.deletePrevCharAction, 391 "shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction, 392 "ctrl H", DefaultEditorKit.deletePrevCharAction, 393 "DELETE", DefaultEditorKit.deleteNextCharAction, 394 "RIGHT", DefaultEditorKit.forwardAction, 395 "LEFT", DefaultEditorKit.backwardAction, 396 "KP_RIGHT", DefaultEditorKit.forwardAction, 397 "KP_LEFT", DefaultEditorKit.backwardAction, 398 "ENTER", JTextField.notifyAction, 399 "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/ 400 }); 401 402 Object multilineInputMap = new UIDefaults.LazyInputMap(new Object[] { 403 "control C", DefaultEditorKit.copyAction, 404 "control V", DefaultEditorKit.pasteAction, 405 "control X", DefaultEditorKit.cutAction, 406 "COPY", DefaultEditorKit.copyAction, 407 "PASTE", DefaultEditorKit.pasteAction, 408 "CUT", DefaultEditorKit.cutAction, 409 "control INSERT", DefaultEditorKit.copyAction, 410 "shift INSERT", DefaultEditorKit.pasteAction, 411 "shift DELETE", DefaultEditorKit.cutAction, 412 "shift LEFT", DefaultEditorKit.selectionBackwardAction, 413 "shift RIGHT", DefaultEditorKit.selectionForwardAction, 414 "control LEFT", DefaultEditorKit.previousWordAction, 415 "control RIGHT", DefaultEditorKit.nextWordAction, 416 "control shift LEFT", DefaultEditorKit.selectionPreviousWordAction, 417 "control shift RIGHT", DefaultEditorKit.selectionNextWordAction, 418 "control A", DefaultEditorKit.selectAllAction, 419 "control BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/, 420 "HOME", DefaultEditorKit.beginLineAction, 421 "END", DefaultEditorKit.endLineAction, 422 "shift HOME", DefaultEditorKit.selectionBeginLineAction, 423 "shift END", DefaultEditorKit.selectionEndLineAction, 424 "control HOME", DefaultEditorKit.beginAction, 425 "control END", DefaultEditorKit.endAction, 426 "control shift HOME", DefaultEditorKit.selectionBeginAction, 427 "control shift END", DefaultEditorKit.selectionEndAction, 428 "UP", DefaultEditorKit.upAction, 429 "DOWN", DefaultEditorKit.downAction, 430 "BACK_SPACE", DefaultEditorKit.deletePrevCharAction, 431 "shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction, 432 "ctrl H", DefaultEditorKit.deletePrevCharAction, 433 "DELETE", DefaultEditorKit.deleteNextCharAction, 434 "ctrl DELETE", DefaultEditorKit.deleteNextWordAction, 435 "ctrl BACK_SPACE", DefaultEditorKit.deletePrevWordAction, 436 "RIGHT", DefaultEditorKit.forwardAction, 437 "LEFT", DefaultEditorKit.backwardAction, 438 "KP_RIGHT", DefaultEditorKit.forwardAction, 439 "KP_LEFT", DefaultEditorKit.backwardAction, 440 "PAGE_UP", DefaultEditorKit.pageUpAction, 441 "PAGE_DOWN", DefaultEditorKit.pageDownAction, 442 "shift PAGE_UP", "selection-page-up", 443 "shift PAGE_DOWN", "selection-page-down", 444 "ctrl shift PAGE_UP", "selection-page-left", 445 "ctrl shift PAGE_DOWN", "selection-page-right", 446 "shift UP", DefaultEditorKit.selectionUpAction, 447 "shift DOWN", DefaultEditorKit.selectionDownAction, 448 "ENTER", DefaultEditorKit.insertBreakAction, 449 "TAB", DefaultEditorKit.insertTabAction, 450 "control T", "next-link-action", 451 "control shift T", "previous-link-action", 452 "control SPACE", "activate-link-action", 453 "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/ 454 }); 455 456 Object menuItemAcceleratorDelimiter = "+"; 457 458 Object ControlBackgroundColor = new DesktopProperty( 459 "win.3d.backgroundColor", 460 table.get("control")); 461 Object ControlLightColor = new DesktopProperty( 462 "win.3d.lightColor", 463 table.get("controlHighlight")); 464 Object ControlHighlightColor = new DesktopProperty( 465 "win.3d.highlightColor", 466 table.get("controlLtHighlight")); 467 Object ControlShadowColor = new DesktopProperty( 468 "win.3d.shadowColor", 469 table.get("controlShadow")); 470 Object ControlDarkShadowColor = new DesktopProperty( 471 "win.3d.darkShadowColor", 472 table.get("controlDkShadow")); 473 Object ControlTextColor = new DesktopProperty( 474 "win.button.textColor", 475 table.get("controlText")); 476 Object MenuBackgroundColor = new DesktopProperty( 477 "win.menu.backgroundColor", 478 table.get("menu")); 479 Object MenuBarBackgroundColor = new DesktopProperty( 480 "win.menubar.backgroundColor", 481 table.get("menu")); 482 Object MenuTextColor = new DesktopProperty( 483 "win.menu.textColor", 484 table.get("menuText")); 485 Object SelectionBackgroundColor = new DesktopProperty( 486 "win.item.highlightColor", 487 table.get("textHighlight")); 488 Object SelectionTextColor = new DesktopProperty( 489 "win.item.highlightTextColor", 490 table.get("textHighlightText")); 491 Object WindowBackgroundColor = new DesktopProperty( 492 "win.frame.backgroundColor", 493 table.get("window")); 494 Object WindowTextColor = new DesktopProperty( 495 "win.frame.textColor", 496 table.get("windowText")); 497 Object WindowBorderWidth = new DesktopProperty( 498 "win.frame.sizingBorderWidth", 499 Integer.valueOf(1)); 500 Object TitlePaneHeight = new DesktopProperty( 501 "win.frame.captionHeight", 502 Integer.valueOf(18)); 503 Object TitleButtonWidth = new DesktopProperty( 504 "win.frame.captionButtonWidth", 505 Integer.valueOf(16)); 506 Object TitleButtonHeight = new DesktopProperty( 507 "win.frame.captionButtonHeight", 508 Integer.valueOf(16)); 509 Object InactiveTextColor = new DesktopProperty( 510 "win.text.grayedTextColor", 511 table.get("textInactiveText")); 512 Object ScrollbarBackgroundColor = new DesktopProperty( 513 "win.scrollbar.backgroundColor", 514 table.get("scrollbar")); 515 Object buttonFocusColor = new FocusColorProperty(); 516 517 Object TextBackground = new XPColorValue(Part.EP_EDIT, null, Prop.FILLCOLOR, 518 WindowBackgroundColor); 519 //The following four lines were commented out as part of bug 4991597 520 //This code *is* correct, however it differs from WindowsXP and is, apparently 521 //a Windows XP bug. Until Windows fixes this bug, we shall also exhibit the same 522 //behavior 523 //Object ReadOnlyTextBackground = new XPColorValue(Part.EP_EDITTEXT, State.READONLY, Prop.FILLCOLOR, 524 // ControlBackgroundColor); 525 //Object DisabledTextBackground = new XPColorValue(Part.EP_EDITTEXT, State.DISABLED, Prop.FILLCOLOR, 526 // ControlBackgroundColor); 527 Object ReadOnlyTextBackground = ControlBackgroundColor; 528 Object DisabledTextBackground = ControlBackgroundColor; 529 530 Object MenuFont = dialogPlain12; 531 Object FixedControlFont = monospacedPlain12; 532 Object ControlFont = dialogPlain12; 533 Object MessageFont = dialogPlain12; 534 Object WindowFont = dialogBold12; 535 Object ToolTipFont = sansSerifPlain12; 536 Object IconFont = ControlFont; 537 538 Object scrollBarWidth = new DesktopProperty("win.scrollbar.width", Integer.valueOf(16)); 539 540 Object menuBarHeight = new DesktopProperty("win.menu.height", null); 541 542 Object hotTrackingOn = new DesktopProperty("win.item.hotTrackingOn", true); 543 544 Object showMnemonics = new DesktopProperty("win.menu.keyboardCuesOn", Boolean.TRUE); 545 546 if (useSystemFontSettings) { 547 MenuFont = getDesktopFontValue("win.menu.font", MenuFont); 548 FixedControlFont = getDesktopFontValue("win.ansiFixed.font", FixedControlFont); 549 ControlFont = getDesktopFontValue("win.defaultGUI.font", ControlFont); 550 MessageFont = getDesktopFontValue("win.messagebox.font", MessageFont); 551 WindowFont = getDesktopFontValue("win.frame.captionFont", WindowFont); 552 IconFont = getDesktopFontValue("win.icon.font", IconFont); 553 ToolTipFont = getDesktopFontValue("win.tooltip.font", ToolTipFont); 554 555 /* Put the desktop AA settings in the defaults. 556 * JComponent.setUI() retrieves this and makes it available 557 * as a client property on the JComponent. Use the same key name 558 * for both client property and UIDefaults. 559 * Also need to set up listeners for changes in these settings. 560 */ 561 SwingUtilities2.putAATextInfo(true, table); 562 this.aaSettings = 563 new FontDesktopProperty(SunToolkit.DESKTOPFONTHINTS); 564 } 565 if (useSystemFontSizeSettings) { 566 MenuFont = new WindowsFontSizeProperty("win.menu.font.height", Font.DIALOG, Font.PLAIN, 12); 567 FixedControlFont = new WindowsFontSizeProperty("win.ansiFixed.font.height", Font.MONOSPACED, 568 Font.PLAIN, 12); 569 ControlFont = new WindowsFontSizeProperty("win.defaultGUI.font.height", Font.DIALOG, Font.PLAIN, 12); 570 MessageFont = new WindowsFontSizeProperty("win.messagebox.font.height", Font.DIALOG, Font.PLAIN, 12); 571 WindowFont = new WindowsFontSizeProperty("win.frame.captionFont.height", Font.DIALOG, Font.BOLD, 12); 572 ToolTipFont = new WindowsFontSizeProperty("win.tooltip.font.height", Font.SANS_SERIF, Font.PLAIN, 12); 573 IconFont = new WindowsFontSizeProperty("win.icon.font.height", Font.DIALOG, Font.PLAIN, 12); 574 } 575 576 577 if (!(this instanceof WindowsClassicLookAndFeel) && 578 (OSInfo.getOSType() == OSInfo.OSType.WINDOWS && 579 OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_XP) >= 0) && 580 AccessController.doPrivileged(new GetPropertyAction("swing.noxp")) == null) { 581 582 // These desktop properties are not used directly, but are needed to 583 // trigger realoading of UI's. 584 this.themeActive = new TriggerDesktopProperty("win.xpstyle.themeActive"); 585 this.dllName = new TriggerDesktopProperty("win.xpstyle.dllName"); 586 this.colorName = new TriggerDesktopProperty("win.xpstyle.colorName"); 587 this.sizeName = new TriggerDesktopProperty("win.xpstyle.sizeName"); 588 } 589 590 591 Object[] defaults = { 592 // *** Auditory Feedback 593 // this key defines which of the various cues to render 594 // Overridden from BasicL&F. This L&F should play all sounds 595 // all the time. The infrastructure decides what to play. 596 // This is disabled until sound bugs can be resolved. 597 "AuditoryCues.playList", null, // table.get("AuditoryCues.cueList"), 598 599 "Application.useSystemFontSettings", Boolean.valueOf(useSystemFontSettings), 600 601 "TextField.focusInputMap", fieldInputMap, 602 "PasswordField.focusInputMap", passwordInputMap, 603 "TextArea.focusInputMap", multilineInputMap, 604 "TextPane.focusInputMap", multilineInputMap, 605 "EditorPane.focusInputMap", multilineInputMap, 606 607 // Buttons 608 "Button.font", ControlFont, 609 "Button.background", ControlBackgroundColor, 610 // Button.foreground, Button.shadow, Button.darkShadow, 611 // Button.disabledForground, and Button.disabledShadow are only 612 // used for Windows Classic. Windows XP will use colors 613 // from the current visual style. 614 "Button.foreground", ControlTextColor, 615 "Button.shadow", ControlShadowColor, 616 "Button.darkShadow", ControlDarkShadowColor, 617 "Button.light", ControlLightColor, 618 "Button.highlight", ControlHighlightColor, 619 "Button.disabledForeground", InactiveTextColor, 620 "Button.disabledShadow", ControlHighlightColor, 621 "Button.focus", buttonFocusColor, 622 "Button.dashedRectGapX", new XPValue(Integer.valueOf(3), Integer.valueOf(5)), 623 "Button.dashedRectGapY", new XPValue(Integer.valueOf(3), Integer.valueOf(4)), 624 "Button.dashedRectGapWidth", new XPValue(Integer.valueOf(6), Integer.valueOf(10)), 625 "Button.dashedRectGapHeight", new XPValue(Integer.valueOf(6), Integer.valueOf(8)), 626 "Button.textShiftOffset", new XPValue(Integer.valueOf(0), 627 Integer.valueOf(1)), 628 // W2K keyboard navigation hidding. 629 "Button.showMnemonics", showMnemonics, 630 "Button.focusInputMap", 631 new UIDefaults.LazyInputMap(new Object[] { 632 "SPACE", "pressed", 633 "released SPACE", "released" 634 }), 635 636 "Caret.width", 637 new DesktopProperty("win.caret.width", null), 638 639 "CheckBox.font", ControlFont, 640 "CheckBox.interiorBackground", WindowBackgroundColor, 641 "CheckBox.background", ControlBackgroundColor, 642 "CheckBox.foreground", WindowTextColor, 643 "CheckBox.shadow", ControlShadowColor, 644 "CheckBox.darkShadow", ControlDarkShadowColor, 645 "CheckBox.light", ControlLightColor, 646 "CheckBox.highlight", ControlHighlightColor, 647 "CheckBox.focus", buttonFocusColor, 648 "CheckBox.focusInputMap", 649 new UIDefaults.LazyInputMap(new Object[] { 650 "SPACE", "pressed", 651 "released SPACE", "released" 652 }), 653 // margin is 2 all the way around, BasicBorders.RadioButtonBorder 654 // (checkbox uses RadioButtonBorder) is 2 all the way around too. 655 "CheckBox.totalInsets", new Insets(4, 4, 4, 4), 656 657 "CheckBoxMenuItem.font", MenuFont, 658 "CheckBoxMenuItem.background", MenuBackgroundColor, 659 "CheckBoxMenuItem.foreground", MenuTextColor, 660 "CheckBoxMenuItem.selectionForeground", SelectionTextColor, 661 "CheckBoxMenuItem.selectionBackground", SelectionBackgroundColor, 662 "CheckBoxMenuItem.acceleratorForeground", MenuTextColor, 663 "CheckBoxMenuItem.acceleratorSelectionForeground", SelectionTextColor, 664 "CheckBoxMenuItem.commandSound", "win.sound.menuCommand", 665 666 "ComboBox.font", ControlFont, 667 "ComboBox.background", WindowBackgroundColor, 668 "ComboBox.foreground", WindowTextColor, 669 "ComboBox.buttonBackground", ControlBackgroundColor, 670 "ComboBox.buttonShadow", ControlShadowColor, 671 "ComboBox.buttonDarkShadow", ControlDarkShadowColor, 672 "ComboBox.buttonHighlight", ControlHighlightColor, 673 "ComboBox.selectionBackground", SelectionBackgroundColor, 674 "ComboBox.selectionForeground", SelectionTextColor, 675 "ComboBox.editorBorder", new XPValue(new EmptyBorder(1,4,1,1), 676 new EmptyBorder(1,4,1,4)), 677 "ComboBox.disabledBackground", 678 new XPColorValue(Part.CP_COMBOBOX, State.DISABLED, 679 Prop.FILLCOLOR, DisabledTextBackground), 680 "ComboBox.disabledForeground", 681 new XPColorValue(Part.CP_COMBOBOX, State.DISABLED, 682 Prop.TEXTCOLOR, InactiveTextColor), 683 "ComboBox.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[] { 684 "ESCAPE", "hidePopup", 685 "PAGE_UP", "pageUpPassThrough", 686 "PAGE_DOWN", "pageDownPassThrough", 687 "HOME", "homePassThrough", 688 "END", "endPassThrough", 689 "DOWN", "selectNext2", 690 "KP_DOWN", "selectNext2", 691 "UP", "selectPrevious2", 692 "KP_UP", "selectPrevious2", 693 "ENTER", "enterPressed", 694 "F4", "togglePopup", 695 "alt DOWN", "togglePopup", 696 "alt KP_DOWN", "togglePopup", 697 "alt UP", "togglePopup", 698 "alt KP_UP", "togglePopup" 699 }), 700 701 // DeskTop. 702 "Desktop.background", new DesktopProperty( 703 "win.mdi.backgroundColor", 704 table.get("desktop")), 705 "Desktop.ancestorInputMap", 706 new UIDefaults.LazyInputMap(new Object[] { 707 "ctrl F5", "restore", 708 "ctrl F4", "close", 709 "ctrl F7", "move", 710 "ctrl F8", "resize", 711 "RIGHT", "right", 712 "KP_RIGHT", "right", 713 "LEFT", "left", 714 "KP_LEFT", "left", 715 "UP", "up", 716 "KP_UP", "up", 717 "DOWN", "down", 718 "KP_DOWN", "down", 719 "ESCAPE", "escape", 720 "ctrl F9", "minimize", 721 "ctrl F10", "maximize", 722 "ctrl F6", "selectNextFrame", 723 "ctrl TAB", "selectNextFrame", 724 "ctrl alt F6", "selectNextFrame", 725 "shift ctrl alt F6", "selectPreviousFrame", 726 "ctrl F12", "navigateNext", 727 "shift ctrl F12", "navigatePrevious" 728 }), 729 730 // DesktopIcon 731 "DesktopIcon.width", Integer.valueOf(160), 732 733 "EditorPane.font", ControlFont, 734 "EditorPane.background", WindowBackgroundColor, 735 "EditorPane.foreground", WindowTextColor, 736 "EditorPane.selectionBackground", SelectionBackgroundColor, 737 "EditorPane.selectionForeground", SelectionTextColor, 738 "EditorPane.caretForeground", WindowTextColor, 739 "EditorPane.inactiveForeground", InactiveTextColor, 740 "EditorPane.inactiveBackground", WindowBackgroundColor, 741 "EditorPane.disabledBackground", DisabledTextBackground, 742 743 "FileChooser.homeFolderIcon", new LazyWindowsIcon(null, 744 "icons/HomeFolder.gif"), 745 "FileChooser.listFont", IconFont, 746 "FileChooser.listViewBackground", new XPColorValue(Part.LVP_LISTVIEW, null, Prop.FILLCOLOR, 747 WindowBackgroundColor), 748 "FileChooser.listViewBorder", new XPBorderValue(Part.LVP_LISTVIEW, 749 (LazyValue) t -> BorderUIResource.getLoweredBevelBorderUIResource()), 750 "FileChooser.listViewIcon", new LazyWindowsIcon("fileChooserIcon ListView", 751 "icons/ListView.gif"), 752 "FileChooser.listViewWindowsStyle", Boolean.TRUE, 753 "FileChooser.detailsViewIcon", new LazyWindowsIcon("fileChooserIcon DetailsView", 754 "icons/DetailsView.gif"), 755 "FileChooser.viewMenuIcon", new LazyWindowsIcon("fileChooserIcon ViewMenu", 756 "icons/ListView.gif"), 757 "FileChooser.upFolderIcon", new LazyWindowsIcon("fileChooserIcon UpFolder", 758 "icons/UpFolder.gif"), 759 "FileChooser.newFolderIcon", new LazyWindowsIcon("fileChooserIcon NewFolder", 760 "icons/NewFolder.gif"), 761 "FileChooser.useSystemExtensionHiding", Boolean.TRUE, 762 763 "FileChooser.usesSingleFilePane", Boolean.TRUE, 764 "FileChooser.noPlacesBar", new DesktopProperty("win.comdlg.noPlacesBar", 765 Boolean.FALSE), 766 "FileChooser.ancestorInputMap", 767 new UIDefaults.LazyInputMap(new Object[] { 768 "ESCAPE", "cancelSelection", 769 "F2", "editFileName", 770 "F5", "refresh", 771 "BACK_SPACE", "Go Up" 772 }), 773 774 "FileView.directoryIcon", SwingUtilities2.makeIcon(getClass(), 775 WindowsLookAndFeel.class, 776 "icons/Directory.gif"), 777 "FileView.fileIcon", SwingUtilities2.makeIcon(getClass(), 778 WindowsLookAndFeel.class, 779 "icons/File.gif"), 780 "FileView.computerIcon", SwingUtilities2.makeIcon(getClass(), 781 WindowsLookAndFeel.class, 782 "icons/Computer.gif"), 783 "FileView.hardDriveIcon", SwingUtilities2.makeIcon(getClass(), 784 WindowsLookAndFeel.class, 785 "icons/HardDrive.gif"), 786 "FileView.floppyDriveIcon", SwingUtilities2.makeIcon(getClass(), 787 WindowsLookAndFeel.class, 788 "icons/FloppyDrive.gif"), 789 790 "FormattedTextField.font", ControlFont, 791 "InternalFrame.titleFont", WindowFont, 792 "InternalFrame.titlePaneHeight", TitlePaneHeight, 793 "InternalFrame.titleButtonWidth", TitleButtonWidth, 794 "InternalFrame.titleButtonHeight", TitleButtonHeight, 795 "InternalFrame.titleButtonToolTipsOn", hotTrackingOn, 796 "InternalFrame.borderColor", ControlBackgroundColor, 797 "InternalFrame.borderShadow", ControlShadowColor, 798 "InternalFrame.borderDarkShadow", ControlDarkShadowColor, 799 "InternalFrame.borderHighlight", ControlHighlightColor, 800 "InternalFrame.borderLight", ControlLightColor, 801 "InternalFrame.borderWidth", WindowBorderWidth, 802 "InternalFrame.minimizeIconBackground", ControlBackgroundColor, 803 "InternalFrame.resizeIconHighlight", ControlLightColor, 804 "InternalFrame.resizeIconShadow", ControlShadowColor, 805 "InternalFrame.activeBorderColor", new DesktopProperty( 806 "win.frame.activeBorderColor", 807 table.get("windowBorder")), 808 "InternalFrame.inactiveBorderColor", new DesktopProperty( 809 "win.frame.inactiveBorderColor", 810 table.get("windowBorder")), 811 "InternalFrame.activeTitleBackground", new DesktopProperty( 812 "win.frame.activeCaptionColor", 813 table.get("activeCaption")), 814 "InternalFrame.activeTitleGradient", new DesktopProperty( 815 "win.frame.activeCaptionGradientColor", 816 table.get("activeCaption")), 817 "InternalFrame.activeTitleForeground", new DesktopProperty( 818 "win.frame.captionTextColor", 819 table.get("activeCaptionText")), 820 "InternalFrame.inactiveTitleBackground", new DesktopProperty( 821 "win.frame.inactiveCaptionColor", 822 table.get("inactiveCaption")), 823 "InternalFrame.inactiveTitleGradient", new DesktopProperty( 824 "win.frame.inactiveCaptionGradientColor", 825 table.get("inactiveCaption")), 826 "InternalFrame.inactiveTitleForeground", new DesktopProperty( 827 "win.frame.inactiveCaptionTextColor", 828 table.get("inactiveCaptionText")), 829 830 "InternalFrame.maximizeIcon", 831 WindowsIconFactory.createFrameMaximizeIcon(), 832 "InternalFrame.minimizeIcon", 833 WindowsIconFactory.createFrameMinimizeIcon(), 834 "InternalFrame.iconifyIcon", 835 WindowsIconFactory.createFrameIconifyIcon(), 836 "InternalFrame.closeIcon", 837 WindowsIconFactory.createFrameCloseIcon(), 838 "InternalFrame.icon", 839 (LazyValue) t -> new WindowsInternalFrameTitlePane.ScalableIconUIResource(new Object[]{ 840 // The constructor takes one arg: an array of UIDefaults.LazyValue 841 // representing the icons 842 SwingUtilities2.makeIcon(getClass(), BasicLookAndFeel.class, "icons/JavaCup16.png"), 843 SwingUtilities2.makeIcon(getClass(), WindowsLookAndFeel.class, "icons/JavaCup32.png") 844 }), 845 // Internal Frame Auditory Cue Mappings 846 "InternalFrame.closeSound", "win.sound.close", 847 "InternalFrame.maximizeSound", "win.sound.maximize", 848 "InternalFrame.minimizeSound", "win.sound.minimize", 849 "InternalFrame.restoreDownSound", "win.sound.restoreDown", 850 "InternalFrame.restoreUpSound", "win.sound.restoreUp", 851 852 "InternalFrame.windowBindings", new Object[] { 853 "shift ESCAPE", "showSystemMenu", 854 "ctrl SPACE", "showSystemMenu", 855 "ESCAPE", "hideSystemMenu"}, 856 857 // Label 858 "Label.font", ControlFont, 859 "Label.background", ControlBackgroundColor, 860 "Label.foreground", WindowTextColor, 861 "Label.disabledForeground", InactiveTextColor, 862 "Label.disabledShadow", ControlHighlightColor, 863 864 // List. 865 "List.font", ControlFont, 866 "List.background", WindowBackgroundColor, 867 "List.foreground", WindowTextColor, 868 "List.selectionBackground", SelectionBackgroundColor, 869 "List.selectionForeground", SelectionTextColor, 870 "List.lockToPositionOnScroll", Boolean.TRUE, 871 "List.focusInputMap", 872 new UIDefaults.LazyInputMap(new Object[] { 873 "ctrl C", "copy", 874 "ctrl V", "paste", 875 "ctrl X", "cut", 876 "COPY", "copy", 877 "PASTE", "paste", 878 "CUT", "cut", 879 "control INSERT", "copy", 880 "shift INSERT", "paste", 881 "shift DELETE", "cut", 882 "UP", "selectPreviousRow", 883 "KP_UP", "selectPreviousRow", 884 "shift UP", "selectPreviousRowExtendSelection", 885 "shift KP_UP", "selectPreviousRowExtendSelection", 886 "ctrl shift UP", "selectPreviousRowExtendSelection", 887 "ctrl shift KP_UP", "selectPreviousRowExtendSelection", 888 "ctrl UP", "selectPreviousRowChangeLead", 889 "ctrl KP_UP", "selectPreviousRowChangeLead", 890 "DOWN", "selectNextRow", 891 "KP_DOWN", "selectNextRow", 892 "shift DOWN", "selectNextRowExtendSelection", 893 "shift KP_DOWN", "selectNextRowExtendSelection", 894 "ctrl shift DOWN", "selectNextRowExtendSelection", 895 "ctrl shift KP_DOWN", "selectNextRowExtendSelection", 896 "ctrl DOWN", "selectNextRowChangeLead", 897 "ctrl KP_DOWN", "selectNextRowChangeLead", 898 "LEFT", "selectPreviousColumn", 899 "KP_LEFT", "selectPreviousColumn", 900 "shift LEFT", "selectPreviousColumnExtendSelection", 901 "shift KP_LEFT", "selectPreviousColumnExtendSelection", 902 "ctrl shift LEFT", "selectPreviousColumnExtendSelection", 903 "ctrl shift KP_LEFT", "selectPreviousColumnExtendSelection", 904 "ctrl LEFT", "selectPreviousColumnChangeLead", 905 "ctrl KP_LEFT", "selectPreviousColumnChangeLead", 906 "RIGHT", "selectNextColumn", 907 "KP_RIGHT", "selectNextColumn", 908 "shift RIGHT", "selectNextColumnExtendSelection", 909 "shift KP_RIGHT", "selectNextColumnExtendSelection", 910 "ctrl shift RIGHT", "selectNextColumnExtendSelection", 911 "ctrl shift KP_RIGHT", "selectNextColumnExtendSelection", 912 "ctrl RIGHT", "selectNextColumnChangeLead", 913 "ctrl KP_RIGHT", "selectNextColumnChangeLead", 914 "HOME", "selectFirstRow", 915 "shift HOME", "selectFirstRowExtendSelection", 916 "ctrl shift HOME", "selectFirstRowExtendSelection", 917 "ctrl HOME", "selectFirstRowChangeLead", 918 "END", "selectLastRow", 919 "shift END", "selectLastRowExtendSelection", 920 "ctrl shift END", "selectLastRowExtendSelection", 921 "ctrl END", "selectLastRowChangeLead", 922 "PAGE_UP", "scrollUp", 923 "shift PAGE_UP", "scrollUpExtendSelection", 924 "ctrl shift PAGE_UP", "scrollUpExtendSelection", 925 "ctrl PAGE_UP", "scrollUpChangeLead", 926 "PAGE_DOWN", "scrollDown", 927 "shift PAGE_DOWN", "scrollDownExtendSelection", 928 "ctrl shift PAGE_DOWN", "scrollDownExtendSelection", 929 "ctrl PAGE_DOWN", "scrollDownChangeLead", 930 "ctrl A", "selectAll", 931 "ctrl SLASH", "selectAll", 932 "ctrl BACK_SLASH", "clearSelection", 933 "SPACE", "addToSelection", 934 "ctrl SPACE", "toggleAndAnchor", 935 "shift SPACE", "extendTo", 936 "ctrl shift SPACE", "moveSelectionTo" 937 }), 938 939 // PopupMenu 940 "PopupMenu.font", MenuFont, 941 "PopupMenu.background", MenuBackgroundColor, 942 "PopupMenu.foreground", MenuTextColor, 943 "PopupMenu.popupSound", "win.sound.menuPopup", 944 "PopupMenu.consumeEventOnClose", Boolean.TRUE, 945 946 // Menus 947 "Menu.font", MenuFont, 948 "Menu.foreground", MenuTextColor, 949 "Menu.background", MenuBackgroundColor, 950 "Menu.useMenuBarBackgroundForTopLevel", Boolean.TRUE, 951 "Menu.selectionForeground", SelectionTextColor, 952 "Menu.selectionBackground", SelectionBackgroundColor, 953 "Menu.acceleratorForeground", MenuTextColor, 954 "Menu.acceleratorSelectionForeground", SelectionTextColor, 955 "Menu.menuPopupOffsetX", Integer.valueOf(0), 956 "Menu.menuPopupOffsetY", Integer.valueOf(0), 957 "Menu.submenuPopupOffsetX", Integer.valueOf(-4), 958 "Menu.submenuPopupOffsetY", Integer.valueOf(-3), 959 "Menu.crossMenuMnemonic", Boolean.FALSE, 960 "Menu.preserveTopLevelSelection", Boolean.TRUE, 961 962 // MenuBar. 963 "MenuBar.font", MenuFont, 964 "MenuBar.background", new XPValue(MenuBarBackgroundColor, 965 MenuBackgroundColor), 966 "MenuBar.foreground", MenuTextColor, 967 "MenuBar.shadow", ControlShadowColor, 968 "MenuBar.highlight", ControlHighlightColor, 969 "MenuBar.height", menuBarHeight, 970 "MenuBar.rolloverEnabled", hotTrackingOn, 971 "MenuBar.windowBindings", new Object[] { 972 "F10", "takeFocus" }, 973 974 "MenuItem.font", MenuFont, 975 "MenuItem.acceleratorFont", MenuFont, 976 "MenuItem.foreground", MenuTextColor, 977 "MenuItem.background", MenuBackgroundColor, 978 "MenuItem.selectionForeground", SelectionTextColor, 979 "MenuItem.selectionBackground", SelectionBackgroundColor, 980 "MenuItem.disabledForeground", InactiveTextColor, 981 "MenuItem.acceleratorForeground", MenuTextColor, 982 "MenuItem.acceleratorSelectionForeground", SelectionTextColor, 983 "MenuItem.acceleratorDelimiter", menuItemAcceleratorDelimiter, 984 // Menu Item Auditory Cue Mapping 985 "MenuItem.commandSound", "win.sound.menuCommand", 986 // indicates that keyboard navigation won't skip disabled menu items 987 "MenuItem.disabledAreNavigable", Boolean.TRUE, 988 989 "RadioButton.font", ControlFont, 990 "RadioButton.interiorBackground", WindowBackgroundColor, 991 "RadioButton.background", ControlBackgroundColor, 992 "RadioButton.foreground", WindowTextColor, 993 "RadioButton.shadow", ControlShadowColor, 994 "RadioButton.darkShadow", ControlDarkShadowColor, 995 "RadioButton.light", ControlLightColor, 996 "RadioButton.highlight", ControlHighlightColor, 997 "RadioButton.focus", buttonFocusColor, 998 "RadioButton.focusInputMap", 999 new UIDefaults.LazyInputMap(new Object[] { 1000 "SPACE", "pressed", 1001 "released SPACE", "released" 1002 }), 1003 // margin is 2 all the way around, BasicBorders.RadioButtonBorder 1004 // is 2 all the way around too. 1005 "RadioButton.totalInsets", new Insets(4, 4, 4, 4), 1006 1007 1008 "RadioButtonMenuItem.font", MenuFont, 1009 "RadioButtonMenuItem.foreground", MenuTextColor, 1010 "RadioButtonMenuItem.background", MenuBackgroundColor, 1011 "RadioButtonMenuItem.selectionForeground", SelectionTextColor, 1012 "RadioButtonMenuItem.selectionBackground", SelectionBackgroundColor, 1013 "RadioButtonMenuItem.disabledForeground", InactiveTextColor, 1014 "RadioButtonMenuItem.acceleratorForeground", MenuTextColor, 1015 "RadioButtonMenuItem.acceleratorSelectionForeground", SelectionTextColor, 1016 "RadioButtonMenuItem.commandSound", "win.sound.menuCommand", 1017 1018 // OptionPane. 1019 "OptionPane.font", MessageFont, 1020 "OptionPane.messageFont", MessageFont, 1021 "OptionPane.buttonFont", MessageFont, 1022 "OptionPane.background", ControlBackgroundColor, 1023 "OptionPane.foreground", WindowTextColor, 1024 "OptionPane.buttonMinimumWidth", new XPDLUValue(50, 50, SwingConstants.EAST), 1025 "OptionPane.messageForeground", ControlTextColor, 1026 "OptionPane.errorIcon", new LazyWindowsIcon("optionPaneIcon Error", 1027 "icons/Error.gif"), 1028 "OptionPane.informationIcon", new LazyWindowsIcon("optionPaneIcon Information", 1029 "icons/Inform.gif"), 1030 "OptionPane.questionIcon", new LazyWindowsIcon("optionPaneIcon Question", 1031 "icons/Question.gif"), 1032 "OptionPane.warningIcon", new LazyWindowsIcon("optionPaneIcon Warning", 1033 "icons/Warn.gif"), 1034 "OptionPane.windowBindings", new Object[] { 1035 "ESCAPE", "close" }, 1036 // Option Pane Auditory Cue Mappings 1037 "OptionPane.errorSound", "win.sound.hand", // Error 1038 "OptionPane.informationSound", "win.sound.asterisk", // Info Plain 1039 "OptionPane.questionSound", "win.sound.question", // Question 1040 "OptionPane.warningSound", "win.sound.exclamation", // Warning 1041 1042 "FormattedTextField.focusInputMap", 1043 new UIDefaults.LazyInputMap(new Object[] { 1044 "ctrl C", DefaultEditorKit.copyAction, 1045 "ctrl V", DefaultEditorKit.pasteAction, 1046 "ctrl X", DefaultEditorKit.cutAction, 1047 "COPY", DefaultEditorKit.copyAction, 1048 "PASTE", DefaultEditorKit.pasteAction, 1049 "CUT", DefaultEditorKit.cutAction, 1050 "control INSERT", DefaultEditorKit.copyAction, 1051 "shift INSERT", DefaultEditorKit.pasteAction, 1052 "shift DELETE", DefaultEditorKit.cutAction, 1053 "shift LEFT", DefaultEditorKit.selectionBackwardAction, 1054 "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction, 1055 "shift RIGHT", DefaultEditorKit.selectionForwardAction, 1056 "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction, 1057 "ctrl LEFT", DefaultEditorKit.previousWordAction, 1058 "ctrl KP_LEFT", DefaultEditorKit.previousWordAction, 1059 "ctrl RIGHT", DefaultEditorKit.nextWordAction, 1060 "ctrl KP_RIGHT", DefaultEditorKit.nextWordAction, 1061 "ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction, 1062 "ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction, 1063 "ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction, 1064 "ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction, 1065 "ctrl A", DefaultEditorKit.selectAllAction, 1066 "HOME", DefaultEditorKit.beginLineAction, 1067 "END", DefaultEditorKit.endLineAction, 1068 "shift HOME", DefaultEditorKit.selectionBeginLineAction, 1069 "shift END", DefaultEditorKit.selectionEndLineAction, 1070 "BACK_SPACE", DefaultEditorKit.deletePrevCharAction, 1071 "shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction, 1072 "ctrl H", DefaultEditorKit.deletePrevCharAction, 1073 "DELETE", DefaultEditorKit.deleteNextCharAction, 1074 "ctrl DELETE", DefaultEditorKit.deleteNextWordAction, 1075 "ctrl BACK_SPACE", DefaultEditorKit.deletePrevWordAction, 1076 "RIGHT", DefaultEditorKit.forwardAction, 1077 "LEFT", DefaultEditorKit.backwardAction, 1078 "KP_RIGHT", DefaultEditorKit.forwardAction, 1079 "KP_LEFT", DefaultEditorKit.backwardAction, 1080 "ENTER", JTextField.notifyAction, 1081 "ctrl BACK_SLASH", "unselect", 1082 "control shift O", "toggle-componentOrientation", 1083 "ESCAPE", "reset-field-edit", 1084 "UP", "increment", 1085 "KP_UP", "increment", 1086 "DOWN", "decrement", 1087 "KP_DOWN", "decrement", 1088 }), 1089 "FormattedTextField.inactiveBackground", ReadOnlyTextBackground, 1090 "FormattedTextField.disabledBackground", DisabledTextBackground, 1091 "FormattedTextField.background", TextBackground, 1092 "FormattedTextField.foreground", WindowTextColor, 1093 1094 // *** Panel 1095 "Panel.font", ControlFont, 1096 "Panel.background", ControlBackgroundColor, 1097 "Panel.foreground", WindowTextColor, 1098 1099 // *** PasswordField 1100 "PasswordField.font", ControlFont, 1101 "PasswordField.background", TextBackground, 1102 "PasswordField.foreground", WindowTextColor, 1103 "PasswordField.inactiveForeground", InactiveTextColor, // for disabled 1104 "PasswordField.inactiveBackground", ReadOnlyTextBackground, // for readonly 1105 "PasswordField.disabledBackground", DisabledTextBackground, // for disabled 1106 "PasswordField.selectionBackground", SelectionBackgroundColor, 1107 "PasswordField.selectionForeground", SelectionTextColor, 1108 "PasswordField.caretForeground",WindowTextColor, 1109 "PasswordField.echoChar", new XPValue((char)0x25CF, '*'), 1110 1111 // *** ProgressBar 1112 "ProgressBar.font", ControlFont, 1113 "ProgressBar.foreground", SelectionBackgroundColor, 1114 "ProgressBar.background", ControlBackgroundColor, 1115 "ProgressBar.shadow", ControlShadowColor, 1116 "ProgressBar.highlight", ControlHighlightColor, 1117 "ProgressBar.selectionForeground", ControlBackgroundColor, 1118 "ProgressBar.selectionBackground", SelectionBackgroundColor, 1119 "ProgressBar.cellLength", Integer.valueOf(7), 1120 "ProgressBar.cellSpacing", Integer.valueOf(2), 1121 "ProgressBar.indeterminateInsets", new Insets(3, 3, 3, 3), 1122 1123 // *** RootPane. 1124 // These bindings are only enabled when there is a default 1125 // button set on the rootpane. 1126 "RootPane.defaultButtonWindowKeyBindings", new Object[] { 1127 "ENTER", "press", 1128 "released ENTER", "release", 1129 "ctrl ENTER", "press", 1130 "ctrl released ENTER", "release" 1131 }, 1132 1133 // *** ScrollBar. 1134 "ScrollBar.background", ScrollbarBackgroundColor, 1135 "ScrollBar.foreground", ControlBackgroundColor, 1136 "ScrollBar.track", white, 1137 "ScrollBar.trackForeground", ScrollbarBackgroundColor, 1138 "ScrollBar.trackHighlight", black, 1139 "ScrollBar.trackHighlightForeground", scrollBarTrackHighlight, 1140 "ScrollBar.thumb", ControlBackgroundColor, 1141 "ScrollBar.thumbHighlight", ControlHighlightColor, 1142 "ScrollBar.thumbDarkShadow", ControlDarkShadowColor, 1143 "ScrollBar.thumbShadow", ControlShadowColor, 1144 "ScrollBar.width", scrollBarWidth, 1145 "ScrollBar.ancestorInputMap", 1146 new UIDefaults.LazyInputMap(new Object[] { 1147 "RIGHT", "positiveUnitIncrement", 1148 "KP_RIGHT", "positiveUnitIncrement", 1149 "DOWN", "positiveUnitIncrement", 1150 "KP_DOWN", "positiveUnitIncrement", 1151 "PAGE_DOWN", "positiveBlockIncrement", 1152 "ctrl PAGE_DOWN", "positiveBlockIncrement", 1153 "LEFT", "negativeUnitIncrement", 1154 "KP_LEFT", "negativeUnitIncrement", 1155 "UP", "negativeUnitIncrement", 1156 "KP_UP", "negativeUnitIncrement", 1157 "PAGE_UP", "negativeBlockIncrement", 1158 "ctrl PAGE_UP", "negativeBlockIncrement", 1159 "HOME", "minScroll", 1160 "END", "maxScroll" 1161 }), 1162 1163 // *** ScrollPane. 1164 "ScrollPane.font", ControlFont, 1165 "ScrollPane.background", ControlBackgroundColor, 1166 "ScrollPane.foreground", ControlTextColor, 1167 "ScrollPane.ancestorInputMap", 1168 new UIDefaults.LazyInputMap(new Object[] { 1169 "RIGHT", "unitScrollRight", 1170 "KP_RIGHT", "unitScrollRight", 1171 "DOWN", "unitScrollDown", 1172 "KP_DOWN", "unitScrollDown", 1173 "LEFT", "unitScrollLeft", 1174 "KP_LEFT", "unitScrollLeft", 1175 "UP", "unitScrollUp", 1176 "KP_UP", "unitScrollUp", 1177 "PAGE_UP", "scrollUp", 1178 "PAGE_DOWN", "scrollDown", 1179 "ctrl PAGE_UP", "scrollLeft", 1180 "ctrl PAGE_DOWN", "scrollRight", 1181 "ctrl HOME", "scrollHome", 1182 "ctrl END", "scrollEnd" 1183 }), 1184 1185 // *** Separator 1186 "Separator.background", ControlHighlightColor, 1187 "Separator.foreground", ControlShadowColor, 1188 1189 // *** Slider. 1190 "Slider.font", ControlFont, 1191 "Slider.foreground", ControlBackgroundColor, 1192 "Slider.background", ControlBackgroundColor, 1193 "Slider.highlight", ControlHighlightColor, 1194 "Slider.shadow", ControlShadowColor, 1195 "Slider.focus", ControlDarkShadowColor, 1196 "Slider.focusInputMap", 1197 new UIDefaults.LazyInputMap(new Object[] { 1198 "RIGHT", "positiveUnitIncrement", 1199 "KP_RIGHT", "positiveUnitIncrement", 1200 "DOWN", "negativeUnitIncrement", 1201 "KP_DOWN", "negativeUnitIncrement", 1202 "PAGE_DOWN", "negativeBlockIncrement", 1203 "LEFT", "negativeUnitIncrement", 1204 "KP_LEFT", "negativeUnitIncrement", 1205 "UP", "positiveUnitIncrement", 1206 "KP_UP", "positiveUnitIncrement", 1207 "PAGE_UP", "positiveBlockIncrement", 1208 "HOME", "minScroll", 1209 "END", "maxScroll" 1210 }), 1211 1212 // Spinner 1213 "Spinner.font", ControlFont, 1214 "Spinner.ancestorInputMap", 1215 new UIDefaults.LazyInputMap(new Object[] { 1216 "UP", "increment", 1217 "KP_UP", "increment", 1218 "DOWN", "decrement", 1219 "KP_DOWN", "decrement", 1220 }), 1221 1222 // *** SplitPane 1223 "SplitPane.background", ControlBackgroundColor, 1224 "SplitPane.highlight", ControlHighlightColor, 1225 "SplitPane.shadow", ControlShadowColor, 1226 "SplitPane.darkShadow", ControlDarkShadowColor, 1227 "SplitPane.dividerSize", Integer.valueOf(5), 1228 "SplitPane.ancestorInputMap", 1229 new UIDefaults.LazyInputMap(new Object[] { 1230 "UP", "negativeIncrement", 1231 "DOWN", "positiveIncrement", 1232 "LEFT", "negativeIncrement", 1233 "RIGHT", "positiveIncrement", 1234 "KP_UP", "negativeIncrement", 1235 "KP_DOWN", "positiveIncrement", 1236 "KP_LEFT", "negativeIncrement", 1237 "KP_RIGHT", "positiveIncrement", 1238 "HOME", "selectMin", 1239 "END", "selectMax", 1240 "F8", "startResize", 1241 "F6", "toggleFocus", 1242 "ctrl TAB", "focusOutForward", 1243 "ctrl shift TAB", "focusOutBackward" 1244 }), 1245 1246 // *** TabbedPane 1247 "TabbedPane.tabsOverlapBorder", new XPValue(Boolean.TRUE, Boolean.FALSE), 1248 "TabbedPane.tabInsets", new XPValue(new InsetsUIResource(1, 4, 1, 4), 1249 new InsetsUIResource(0, 4, 1, 4)), 1250 "TabbedPane.tabAreaInsets", new XPValue(new InsetsUIResource(3, 2, 2, 2), 1251 new InsetsUIResource(3, 2, 0, 2)), 1252 "TabbedPane.font", ControlFont, 1253 "TabbedPane.background", ControlBackgroundColor, 1254 "TabbedPane.foreground", ControlTextColor, 1255 "TabbedPane.highlight", ControlHighlightColor, 1256 "TabbedPane.light", ControlLightColor, 1257 "TabbedPane.shadow", ControlShadowColor, 1258 "TabbedPane.darkShadow", ControlDarkShadowColor, 1259 "TabbedPane.focus", ControlTextColor, 1260 "TabbedPane.focusInputMap", 1261 new UIDefaults.LazyInputMap(new Object[] { 1262 "RIGHT", "navigateRight", 1263 "KP_RIGHT", "navigateRight", 1264 "LEFT", "navigateLeft", 1265 "KP_LEFT", "navigateLeft", 1266 "UP", "navigateUp", 1267 "KP_UP", "navigateUp", 1268 "DOWN", "navigateDown", 1269 "KP_DOWN", "navigateDown", 1270 "ctrl DOWN", "requestFocusForVisibleComponent", 1271 "ctrl KP_DOWN", "requestFocusForVisibleComponent", 1272 }), 1273 "TabbedPane.ancestorInputMap", 1274 new UIDefaults.LazyInputMap(new Object[] { 1275 "ctrl TAB", "navigateNext", 1276 "ctrl shift TAB", "navigatePrevious", 1277 "ctrl PAGE_DOWN", "navigatePageDown", 1278 "ctrl PAGE_UP", "navigatePageUp", 1279 "ctrl UP", "requestFocus", 1280 "ctrl KP_UP", "requestFocus", 1281 }), 1282 1283 // *** Table 1284 "Table.font", ControlFont, 1285 "Table.foreground", ControlTextColor, // cell text color 1286 "Table.background", WindowBackgroundColor, // cell background color 1287 "Table.highlight", ControlHighlightColor, 1288 "Table.light", ControlLightColor, 1289 "Table.shadow", ControlShadowColor, 1290 "Table.darkShadow", ControlDarkShadowColor, 1291 "Table.selectionForeground", SelectionTextColor, 1292 "Table.selectionBackground", SelectionBackgroundColor, 1293 "Table.gridColor", gray, // grid line color 1294 "Table.focusCellBackground", WindowBackgroundColor, 1295 "Table.focusCellForeground", ControlTextColor, 1296 "Table.ancestorInputMap", 1297 new UIDefaults.LazyInputMap(new Object[] { 1298 "ctrl C", "copy", 1299 "ctrl V", "paste", 1300 "ctrl X", "cut", 1301 "COPY", "copy", 1302 "PASTE", "paste", 1303 "CUT", "cut", 1304 "control INSERT", "copy", 1305 "shift INSERT", "paste", 1306 "shift DELETE", "cut", 1307 "RIGHT", "selectNextColumn", 1308 "KP_RIGHT", "selectNextColumn", 1309 "shift RIGHT", "selectNextColumnExtendSelection", 1310 "shift KP_RIGHT", "selectNextColumnExtendSelection", 1311 "ctrl shift RIGHT", "selectNextColumnExtendSelection", 1312 "ctrl shift KP_RIGHT", "selectNextColumnExtendSelection", 1313 "ctrl RIGHT", "selectNextColumnChangeLead", 1314 "ctrl KP_RIGHT", "selectNextColumnChangeLead", 1315 "LEFT", "selectPreviousColumn", 1316 "KP_LEFT", "selectPreviousColumn", 1317 "shift LEFT", "selectPreviousColumnExtendSelection", 1318 "shift KP_LEFT", "selectPreviousColumnExtendSelection", 1319 "ctrl shift LEFT", "selectPreviousColumnExtendSelection", 1320 "ctrl shift KP_LEFT", "selectPreviousColumnExtendSelection", 1321 "ctrl LEFT", "selectPreviousColumnChangeLead", 1322 "ctrl KP_LEFT", "selectPreviousColumnChangeLead", 1323 "DOWN", "selectNextRow", 1324 "KP_DOWN", "selectNextRow", 1325 "shift DOWN", "selectNextRowExtendSelection", 1326 "shift KP_DOWN", "selectNextRowExtendSelection", 1327 "ctrl shift DOWN", "selectNextRowExtendSelection", 1328 "ctrl shift KP_DOWN", "selectNextRowExtendSelection", 1329 "ctrl DOWN", "selectNextRowChangeLead", 1330 "ctrl KP_DOWN", "selectNextRowChangeLead", 1331 "UP", "selectPreviousRow", 1332 "KP_UP", "selectPreviousRow", 1333 "shift UP", "selectPreviousRowExtendSelection", 1334 "shift KP_UP", "selectPreviousRowExtendSelection", 1335 "ctrl shift UP", "selectPreviousRowExtendSelection", 1336 "ctrl shift KP_UP", "selectPreviousRowExtendSelection", 1337 "ctrl UP", "selectPreviousRowChangeLead", 1338 "ctrl KP_UP", "selectPreviousRowChangeLead", 1339 "HOME", "selectFirstColumn", 1340 "shift HOME", "selectFirstColumnExtendSelection", 1341 "ctrl shift HOME", "selectFirstRowExtendSelection", 1342 "ctrl HOME", "selectFirstRow", 1343 "END", "selectLastColumn", 1344 "shift END", "selectLastColumnExtendSelection", 1345 "ctrl shift END", "selectLastRowExtendSelection", 1346 "ctrl END", "selectLastRow", 1347 "PAGE_UP", "scrollUpChangeSelection", 1348 "shift PAGE_UP", "scrollUpExtendSelection", 1349 "ctrl shift PAGE_UP", "scrollLeftExtendSelection", 1350 "ctrl PAGE_UP", "scrollLeftChangeSelection", 1351 "PAGE_DOWN", "scrollDownChangeSelection", 1352 "shift PAGE_DOWN", "scrollDownExtendSelection", 1353 "ctrl shift PAGE_DOWN", "scrollRightExtendSelection", 1354 "ctrl PAGE_DOWN", "scrollRightChangeSelection", 1355 "TAB", "selectNextColumnCell", 1356 "shift TAB", "selectPreviousColumnCell", 1357 "ENTER", "selectNextRowCell", 1358 "shift ENTER", "selectPreviousRowCell", 1359 "ctrl A", "selectAll", 1360 "ctrl SLASH", "selectAll", 1361 "ctrl BACK_SLASH", "clearSelection", 1362 "ESCAPE", "cancel", 1363 "F2", "startEditing", 1364 "SPACE", "addToSelection", 1365 "ctrl SPACE", "toggleAndAnchor", 1366 "shift SPACE", "extendTo", 1367 "ctrl shift SPACE", "moveSelectionTo", 1368 "F8", "focusHeader" 1369 }), 1370 "Table.sortIconHighlight", ControlShadowColor, 1371 "Table.sortIconLight", white, 1372 1373 "TableHeader.font", ControlFont, 1374 "TableHeader.foreground", ControlTextColor, // header text color 1375 "TableHeader.background", ControlBackgroundColor, // header background 1376 "TableHeader.focusCellBackground", 1377 new XPValue(XPValue.NULL_VALUE, // use default bg from XP styles 1378 WindowBackgroundColor), // or white bg otherwise 1379 1380 // *** TextArea 1381 "TextArea.font", FixedControlFont, 1382 "TextArea.background", WindowBackgroundColor, 1383 "TextArea.foreground", WindowTextColor, 1384 "TextArea.inactiveForeground", InactiveTextColor, 1385 "TextArea.inactiveBackground", WindowBackgroundColor, 1386 "TextArea.disabledBackground", DisabledTextBackground, 1387 "TextArea.selectionBackground", SelectionBackgroundColor, 1388 "TextArea.selectionForeground", SelectionTextColor, 1389 "TextArea.caretForeground", WindowTextColor, 1390 1391 // *** TextField 1392 "TextField.font", ControlFont, 1393 "TextField.background", TextBackground, 1394 "TextField.foreground", WindowTextColor, 1395 "TextField.shadow", ControlShadowColor, 1396 "TextField.darkShadow", ControlDarkShadowColor, 1397 "TextField.light", ControlLightColor, 1398 "TextField.highlight", ControlHighlightColor, 1399 "TextField.inactiveForeground", InactiveTextColor, // for disabled 1400 "TextField.inactiveBackground", ReadOnlyTextBackground, // for readonly 1401 "TextField.disabledBackground", DisabledTextBackground, // for disabled 1402 "TextField.selectionBackground", SelectionBackgroundColor, 1403 "TextField.selectionForeground", SelectionTextColor, 1404 "TextField.caretForeground", WindowTextColor, 1405 1406 // *** TextPane 1407 "TextPane.font", ControlFont, 1408 "TextPane.background", WindowBackgroundColor, 1409 "TextPane.foreground", WindowTextColor, 1410 "TextPane.selectionBackground", SelectionBackgroundColor, 1411 "TextPane.selectionForeground", SelectionTextColor, 1412 "TextPane.inactiveBackground", WindowBackgroundColor, 1413 "TextPane.disabledBackground", DisabledTextBackground, 1414 "TextPane.caretForeground", WindowTextColor, 1415 1416 // *** TitledBorder 1417 "TitledBorder.font", ControlFont, 1418 "TitledBorder.titleColor", 1419 new XPColorValue(Part.BP_GROUPBOX, null, Prop.TEXTCOLOR, 1420 WindowTextColor), 1421 1422 // *** ToggleButton 1423 "ToggleButton.font", ControlFont, 1424 "ToggleButton.background", ControlBackgroundColor, 1425 "ToggleButton.foreground", ControlTextColor, 1426 "ToggleButton.shadow", ControlShadowColor, 1427 "ToggleButton.darkShadow", ControlDarkShadowColor, 1428 "ToggleButton.light", ControlLightColor, 1429 "ToggleButton.highlight", ControlHighlightColor, 1430 "ToggleButton.focus", ControlTextColor, 1431 "ToggleButton.textShiftOffset", Integer.valueOf(1), 1432 "ToggleButton.focusInputMap", 1433 new UIDefaults.LazyInputMap(new Object[] { 1434 "SPACE", "pressed", 1435 "released SPACE", "released" 1436 }), 1437 1438 // *** ToolBar 1439 "ToolBar.font", MenuFont, 1440 "ToolBar.background", ControlBackgroundColor, 1441 "ToolBar.foreground", ControlTextColor, 1442 "ToolBar.shadow", ControlShadowColor, 1443 "ToolBar.darkShadow", ControlDarkShadowColor, 1444 "ToolBar.light", ControlLightColor, 1445 "ToolBar.highlight", ControlHighlightColor, 1446 "ToolBar.dockingBackground", ControlBackgroundColor, 1447 "ToolBar.dockingForeground", red, 1448 "ToolBar.floatingBackground", ControlBackgroundColor, 1449 "ToolBar.floatingForeground", darkGray, 1450 "ToolBar.ancestorInputMap", 1451 new UIDefaults.LazyInputMap(new Object[] { 1452 "UP", "navigateUp", 1453 "KP_UP", "navigateUp", 1454 "DOWN", "navigateDown", 1455 "KP_DOWN", "navigateDown", 1456 "LEFT", "navigateLeft", 1457 "KP_LEFT", "navigateLeft", 1458 "RIGHT", "navigateRight", 1459 "KP_RIGHT", "navigateRight" 1460 }), 1461 "ToolBar.separatorSize", null, 1462 1463 // *** ToolTip 1464 "ToolTip.font", ToolTipFont, 1465 "ToolTip.background", new DesktopProperty("win.tooltip.backgroundColor", table.get("info")), 1466 "ToolTip.foreground", new DesktopProperty("win.tooltip.textColor", table.get("infoText")), 1467 1468 // *** ToolTipManager 1469 "ToolTipManager.enableToolTipMode", "activeApplication", 1470 1471 // *** Tree 1472 "Tree.selectionBorderColor", black, 1473 "Tree.drawDashedFocusIndicator", Boolean.TRUE, 1474 "Tree.lineTypeDashed", Boolean.TRUE, 1475 "Tree.font", ControlFont, 1476 "Tree.background", WindowBackgroundColor, 1477 "Tree.foreground", WindowTextColor, 1478 "Tree.hash", gray, 1479 "Tree.leftChildIndent", Integer.valueOf(8), 1480 "Tree.rightChildIndent", Integer.valueOf(11), 1481 "Tree.textForeground", WindowTextColor, 1482 "Tree.textBackground", WindowBackgroundColor, 1483 "Tree.selectionForeground", SelectionTextColor, 1484 "Tree.selectionBackground", SelectionBackgroundColor, 1485 "Tree.expandedIcon", treeExpandedIcon, 1486 "Tree.collapsedIcon", treeCollapsedIcon, 1487 "Tree.openIcon", new ActiveWindowsIcon("win.icon.shellIconBPP", 1488 "shell32Icon 5", "icons/TreeOpen.gif"), 1489 "Tree.closedIcon", new ActiveWindowsIcon("win.icon.shellIconBPP", 1490 "shell32Icon 4", "icons/TreeClosed.gif"), 1491 "Tree.focusInputMap", 1492 new UIDefaults.LazyInputMap(new Object[] { 1493 "ADD", "expand", 1494 "SUBTRACT", "collapse", 1495 "ctrl C", "copy", 1496 "ctrl V", "paste", 1497 "ctrl X", "cut", 1498 "COPY", "copy", 1499 "PASTE", "paste", 1500 "CUT", "cut", 1501 "control INSERT", "copy", 1502 "shift INSERT", "paste", 1503 "shift DELETE", "cut", 1504 "UP", "selectPrevious", 1505 "KP_UP", "selectPrevious", 1506 "shift UP", "selectPreviousExtendSelection", 1507 "shift KP_UP", "selectPreviousExtendSelection", 1508 "ctrl shift UP", "selectPreviousExtendSelection", 1509 "ctrl shift KP_UP", "selectPreviousExtendSelection", 1510 "ctrl UP", "selectPreviousChangeLead", 1511 "ctrl KP_UP", "selectPreviousChangeLead", 1512 "DOWN", "selectNext", 1513 "KP_DOWN", "selectNext", 1514 "shift DOWN", "selectNextExtendSelection", 1515 "shift KP_DOWN", "selectNextExtendSelection", 1516 "ctrl shift DOWN", "selectNextExtendSelection", 1517 "ctrl shift KP_DOWN", "selectNextExtendSelection", 1518 "ctrl DOWN", "selectNextChangeLead", 1519 "ctrl KP_DOWN", "selectNextChangeLead", 1520 "RIGHT", "selectChild", 1521 "KP_RIGHT", "selectChild", 1522 "LEFT", "selectParent", 1523 "KP_LEFT", "selectParent", 1524 "PAGE_UP", "scrollUpChangeSelection", 1525 "shift PAGE_UP", "scrollUpExtendSelection", 1526 "ctrl shift PAGE_UP", "scrollUpExtendSelection", 1527 "ctrl PAGE_UP", "scrollUpChangeLead", 1528 "PAGE_DOWN", "scrollDownChangeSelection", 1529 "shift PAGE_DOWN", "scrollDownExtendSelection", 1530 "ctrl shift PAGE_DOWN", "scrollDownExtendSelection", 1531 "ctrl PAGE_DOWN", "scrollDownChangeLead", 1532 "HOME", "selectFirst", 1533 "shift HOME", "selectFirstExtendSelection", 1534 "ctrl shift HOME", "selectFirstExtendSelection", 1535 "ctrl HOME", "selectFirstChangeLead", 1536 "END", "selectLast", 1537 "shift END", "selectLastExtendSelection", 1538 "ctrl shift END", "selectLastExtendSelection", 1539 "ctrl END", "selectLastChangeLead", 1540 "F2", "startEditing", 1541 "ctrl A", "selectAll", 1542 "ctrl SLASH", "selectAll", 1543 "ctrl BACK_SLASH", "clearSelection", 1544 "ctrl LEFT", "scrollLeft", 1545 "ctrl KP_LEFT", "scrollLeft", 1546 "ctrl RIGHT", "scrollRight", 1547 "ctrl KP_RIGHT", "scrollRight", 1548 "SPACE", "addToSelection", 1549 "ctrl SPACE", "toggleAndAnchor", 1550 "shift SPACE", "extendTo", 1551 "ctrl shift SPACE", "moveSelectionTo" 1552 }), 1553 "Tree.ancestorInputMap", 1554 new UIDefaults.LazyInputMap(new Object[] { 1555 "ESCAPE", "cancel" 1556 }), 1557 1558 // *** Viewport 1559 "Viewport.font", ControlFont, 1560 "Viewport.background", ControlBackgroundColor, 1561 "Viewport.foreground", WindowTextColor, 1562 1563 1564 }; 1565 1566 table.putDefaults(defaults); 1567 table.putDefaults(getLazyValueDefaults()); 1568 initVistaComponentDefaults(table); 1569 } 1570 1571 static boolean isOnVista() { 1572 return OSInfo.getOSType() == OSInfo.OSType.WINDOWS 1573 && OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_VISTA) >= 0; 1574 } 1575 1576 static boolean isOnWindows7() { 1577 return OSInfo.getOSType() == OSInfo.OSType.WINDOWS 1578 && OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_7) >= 0; 1579 } 1580 1581 private void initVistaComponentDefaults(UIDefaults table) { 1582 if (! isOnVista()) { 1583 return; 1584 } 1585 /* START handling menus for Vista */ 1586 String[] menuClasses = { "MenuItem", "Menu", 1587 "CheckBoxMenuItem", "RadioButtonMenuItem", 1588 }; 1589 1590 Object menuDefaults[] = new Object[menuClasses.length * 2]; 1591 1592 /* all the menus need to be non opaque. */ 1593 for (int i = 0, j = 0; i < menuClasses.length; i++) { 1594 String key = menuClasses[i] + ".opaque"; 1595 Object oldValue = table.get(key); 1596 menuDefaults[j++] = key; 1597 menuDefaults[j++] = 1598 new XPValue(Boolean.FALSE, oldValue); 1599 } 1600 table.putDefaults(menuDefaults); 1601 1602 /* 1603 * acceleratorSelectionForeground color is the same as 1604 * acceleratorForeground 1605 */ 1606 for (int i = 0, j = 0; i < menuClasses.length; i++) { 1607 String key = menuClasses[i] + ".acceleratorSelectionForeground"; 1608 Object oldValue = table.get(key); 1609 menuDefaults[j++] = key; 1610 menuDefaults[j++] = 1611 new XPValue( 1612 table.getColor( 1613 menuClasses[i] + ".acceleratorForeground"), 1614 oldValue); 1615 } 1616 table.putDefaults(menuDefaults); 1617 1618 /* they have the same MenuItemCheckIconFactory */ 1619 VistaMenuItemCheckIconFactory menuItemCheckIconFactory = 1620 WindowsIconFactory.getMenuItemCheckIconFactory(); 1621 for (int i = 0, j = 0; i < menuClasses.length; i++) { 1622 String key = menuClasses[i] + ".checkIconFactory"; 1623 Object oldValue = table.get(key); 1624 menuDefaults[j++] = key; 1625 menuDefaults[j++] = 1626 new XPValue(menuItemCheckIconFactory, oldValue); 1627 } 1628 table.putDefaults(menuDefaults); 1629 1630 for (int i = 0, j = 0; i < menuClasses.length; i++) { 1631 String key = menuClasses[i] + ".checkIcon"; 1632 Object oldValue = table.get(key); 1633 menuDefaults[j++] = key; 1634 menuDefaults[j++] = 1635 new XPValue(menuItemCheckIconFactory.getIcon(menuClasses[i]), 1636 oldValue); 1637 } 1638 table.putDefaults(menuDefaults); 1639 1640 1641 /* height can be even */ 1642 for (int i = 0, j = 0; i < menuClasses.length; i++) { 1643 String key = menuClasses[i] + ".evenHeight"; 1644 Object oldValue = table.get(key); 1645 menuDefaults[j++] = key; 1646 menuDefaults[j++] = new XPValue(Boolean.TRUE, oldValue); 1647 } 1648 table.putDefaults(menuDefaults); 1649 1650 /*For Windows7 margin and checkIconOffset should be greater than 0 */ 1651 if (!isOnWindows7()) { 1652 /* no margins */ 1653 InsetsUIResource insets = new InsetsUIResource(0, 0, 0, 0); 1654 for (int i = 0, j = 0; i < menuClasses.length; i++) { 1655 String key = menuClasses[i] + ".margin"; 1656 Object oldValue = table.get(key); 1657 menuDefaults[j++] = key; 1658 menuDefaults[j++] = new XPValue(insets, oldValue); 1659 } 1660 table.putDefaults(menuDefaults); 1661 1662 /* set checkIcon offset */ 1663 Integer checkIconOffsetInteger = 1664 Integer.valueOf(0); 1665 for (int i = 0, j = 0; i < menuClasses.length; i++) { 1666 String key = menuClasses[i] + ".checkIconOffset"; 1667 Object oldValue = table.get(key); 1668 menuDefaults[j++] = key; 1669 menuDefaults[j++] = 1670 new XPValue(checkIconOffsetInteger, oldValue); 1671 } 1672 table.putDefaults(menuDefaults); 1673 } 1674 /* set width of the gap after check icon */ 1675 Integer afterCheckIconGap = WindowsPopupMenuUI.getSpanBeforeGutter() 1676 + WindowsPopupMenuUI.getGutterWidth() 1677 + WindowsPopupMenuUI.getSpanAfterGutter(); 1678 for (int i = 0, j = 0; i < menuClasses.length; i++) { 1679 String key = menuClasses[i] + ".afterCheckIconGap"; 1680 Object oldValue = table.get(key); 1681 menuDefaults[j++] = key; 1682 menuDefaults[j++] = 1683 new XPValue(afterCheckIconGap, oldValue); 1684 } 1685 table.putDefaults(menuDefaults); 1686 1687 /* text is started after this position */ 1688 Object minimumTextOffset = new UIDefaults.ActiveValue() { 1689 public Object createValue(UIDefaults table) { 1690 return VistaMenuItemCheckIconFactory.getIconWidth() 1691 + WindowsPopupMenuUI.getSpanBeforeGutter() 1692 + WindowsPopupMenuUI.getGutterWidth() 1693 + WindowsPopupMenuUI.getSpanAfterGutter(); 1694 } 1695 }; 1696 for (int i = 0, j = 0; i < menuClasses.length; i++) { 1697 String key = menuClasses[i] + ".minimumTextOffset"; 1698 Object oldValue = table.get(key); 1699 menuDefaults[j++] = key; 1700 menuDefaults[j++] = new XPValue(minimumTextOffset, oldValue); 1701 } 1702 table.putDefaults(menuDefaults); 1703 1704 /* 1705 * JPopupMenu has a bit of free space around menu items 1706 */ 1707 String POPUP_MENU_BORDER = "PopupMenu.border"; 1708 1709 Object popupMenuBorder = new XPBorderValue(Part.MENU, 1710 (LazyValue) t -> BasicBorders.getInternalFrameBorder(), 1711 BorderFactory.createEmptyBorder(2, 2, 2, 2)); 1712 table.put(POPUP_MENU_BORDER, popupMenuBorder); 1713 /* END handling menus for Vista */ 1714 1715 /* START table handling for Vista */ 1716 table.put("Table.ascendingSortIcon", new XPValue( 1717 new SkinIcon(Part.HP_HEADERSORTARROW, State.SORTEDDOWN), 1718 (LazyValue) t -> new ClassicSortArrowIcon(true))); 1719 table.put("Table.descendingSortIcon", new XPValue( 1720 new SkinIcon(Part.HP_HEADERSORTARROW, State.SORTEDUP), 1721 (LazyValue) t -> new ClassicSortArrowIcon(false))); 1722 /* END table handling for Vista */ 1723 } 1724 1725 /** 1726 * If we support loading of fonts from the desktop this will return 1727 * a DesktopProperty representing the font. If the font can't be 1728 * represented in the current encoding this will return null and 1729 * turn off the use of system fonts. 1730 */ 1731 private Object getDesktopFontValue(String fontName, Object backup) { 1732 if (useSystemFontSettings) { 1733 return new WindowsFontProperty(fontName, backup); 1734 } 1735 return null; 1736 } 1737 1738 // When a desktop property change is detected, these classes must be 1739 // reinitialized in the defaults table to ensure the classes reference 1740 // the updated desktop property values (colors mostly) 1741 // 1742 private Object[] getLazyValueDefaults() { 1743 1744 Object buttonBorder = 1745 new XPBorderValue(Part.BP_PUSHBUTTON, 1746 (LazyValue) t -> BasicBorders.getButtonBorder()); 1747 1748 Object textFieldBorder = 1749 new XPBorderValue(Part.EP_EDIT, 1750 (LazyValue) t -> BasicBorders.getTextFieldBorder()); 1751 1752 Object textFieldMargin = 1753 new XPValue(new InsetsUIResource(2, 2, 2, 2), 1754 new InsetsUIResource(1, 1, 1, 1)); 1755 1756 Object spinnerBorder = 1757 new XPBorderValue(Part.EP_EDIT, textFieldBorder, 1758 new EmptyBorder(2, 2, 2, 2)); 1759 1760 Object spinnerArrowInsets = 1761 new XPValue(new InsetsUIResource(1, 1, 1, 1), 1762 null); 1763 1764 Object comboBoxBorder = new XPBorderValue(Part.CP_COMBOBOX, textFieldBorder); 1765 1766 // For focus rectangle for cells and trees. 1767 LazyValue focusCellHighlightBorder = t -> WindowsBorders.getFocusCellHighlightBorder(); 1768 1769 LazyValue etchedBorder = t -> BorderUIResource.getEtchedBorderUIResource(); 1770 1771 LazyValue internalFrameBorder = t -> WindowsBorders.getInternalFrameBorder(); 1772 1773 LazyValue loweredBevelBorder = t -> BorderUIResource.getLoweredBevelBorderUIResource(); 1774 1775 1776 LazyValue marginBorder = t -> new BasicBorders.MarginBorder(); 1777 1778 LazyValue menuBarBorder = t -> BasicBorders.getMenuBarBorder(); 1779 1780 1781 Object popupMenuBorder = new XPBorderValue(Part.MENU, 1782 (LazyValue) t -> BasicBorders.getInternalFrameBorder()); 1783 1784 // *** ProgressBar 1785 LazyValue progressBarBorder = t -> WindowsBorders.getProgressBarBorder(); 1786 1787 LazyValue radioButtonBorder = t -> BasicBorders.getRadioButtonBorder(); 1788 1789 Object scrollPaneBorder = 1790 new XPBorderValue(Part.LBP_LISTBOX, textFieldBorder); 1791 1792 Object tableScrollPaneBorder = 1793 new XPBorderValue(Part.LBP_LISTBOX, loweredBevelBorder); 1794 1795 LazyValue tableHeaderBorder = t -> WindowsBorders.getTableHeaderBorder(); 1796 1797 // *** ToolBar 1798 LazyValue toolBarBorder = t -> WindowsBorders.getToolBarBorder(); 1799 1800 // *** ToolTips 1801 LazyValue toolTipBorder = t -> BorderUIResource.getBlackLineBorderUIResource(); 1802 1803 1804 1805 LazyValue checkBoxIcon = t -> WindowsIconFactory.getCheckBoxIcon(); 1806 1807 LazyValue radioButtonIcon = t -> WindowsIconFactory.getRadioButtonIcon(); 1808 1809 LazyValue radioButtonMenuItemIcon = t -> WindowsIconFactory.getRadioButtonMenuItemIcon(); 1810 1811 LazyValue menuItemCheckIcon = t -> WindowsIconFactory.getMenuItemCheckIcon(); 1812 1813 LazyValue menuItemArrowIcon = t -> WindowsIconFactory.getMenuItemArrowIcon(); 1814 1815 LazyValue menuArrowIcon = t -> WindowsIconFactory.getMenuArrowIcon(); 1816 1817 Color highlight = (Color) Toolkit.getDefaultToolkit(). 1818 getDesktopProperty("win.3d.highlightColor"); 1819 1820 Color shadow = (Color) Toolkit.getDefaultToolkit(). 1821 getDesktopProperty("win.3d.shadowColor"); 1822 1823 Object[] lazyDefaults = { 1824 "Button.border", buttonBorder, 1825 "CheckBox.border", radioButtonBorder, 1826 "ComboBox.border", comboBoxBorder, 1827 "DesktopIcon.border", internalFrameBorder, 1828 "FormattedTextField.border", textFieldBorder, 1829 "FormattedTextField.margin", textFieldMargin, 1830 "InternalFrame.border", internalFrameBorder, 1831 "List.focusCellHighlightBorder", focusCellHighlightBorder, 1832 "Table.focusCellHighlightBorder", focusCellHighlightBorder, 1833 "Menu.border", marginBorder, 1834 "MenuBar.border", menuBarBorder, 1835 "MenuItem.border", marginBorder, 1836 "PasswordField.border", textFieldBorder, 1837 "PasswordField.margin", textFieldMargin, 1838 "PopupMenu.border", popupMenuBorder, 1839 "ProgressBar.border", progressBarBorder, 1840 "RadioButton.border", radioButtonBorder, 1841 "ScrollPane.border", scrollPaneBorder, 1842 "Spinner.border", spinnerBorder, 1843 "Spinner.arrowButtonInsets", spinnerArrowInsets, 1844 "Spinner.arrowButtonSize", new Dimension(17, 9), 1845 "Table.scrollPaneBorder", tableScrollPaneBorder, 1846 "TableHeader.cellBorder", tableHeaderBorder, 1847 "TextArea.margin", textFieldMargin, 1848 "TextField.border", textFieldBorder, 1849 "TextField.margin", textFieldMargin, 1850 "TitledBorder.border", new UIDefaults.LazyValue() { 1851 public Object createValue(UIDefaults table) { 1852 return new BorderUIResource. 1853 EtchedBorderUIResource(highlight, shadow); 1854 } 1855 }, 1856 "ToggleButton.border", radioButtonBorder, 1857 "ToolBar.border", toolBarBorder, 1858 "ToolTip.border", toolTipBorder, 1859 1860 "CheckBox.icon", checkBoxIcon, 1861 "Menu.arrowIcon", menuArrowIcon, 1862 "MenuItem.checkIcon", menuItemCheckIcon, 1863 "MenuItem.arrowIcon", menuItemArrowIcon, 1864 "RadioButton.icon", radioButtonIcon, 1865 "RadioButtonMenuItem.checkIcon", radioButtonMenuItemIcon, 1866 "InternalFrame.layoutTitlePaneAtOrigin", 1867 new XPValue(Boolean.TRUE, Boolean.FALSE), 1868 "Table.ascendingSortIcon", new XPValue( 1869 (LazyValue) t -> new SortArrowIcon(true,"Table.sortIconColor"), 1870 (LazyValue) t -> new ClassicSortArrowIcon(true)), 1871 "Table.descendingSortIcon", new XPValue( 1872 (LazyValue) t -> new SortArrowIcon(false,"Table.sortIconColor"), 1873 (LazyValue) t -> new ClassicSortArrowIcon(false)), 1874 }; 1875 1876 return lazyDefaults; 1877 } 1878 1879 public void uninitialize() { 1880 super.uninitialize(); 1881 1882 if (WindowsPopupMenuUI.mnemonicListener != null) { 1883 MenuSelectionManager.defaultManager(). 1884 removeChangeListener(WindowsPopupMenuUI.mnemonicListener); 1885 } 1886 KeyboardFocusManager.getCurrentKeyboardFocusManager(). 1887 removeKeyEventPostProcessor(WindowsRootPaneUI.altProcessor); 1888 DesktopProperty.flushUnreferencedProperties(); 1889 } 1890 1891 1892 // Toggle flag for drawing the mnemonic state 1893 private static boolean isMnemonicHidden = true; 1894 1895 // Flag which indicates that the Win98/Win2k/WinME features 1896 // should be disabled. 1897 private static boolean isClassicWindows = false; 1898 1899 /** 1900 * Sets the state of the hide mnemonic flag. This flag is used by the 1901 * component UI delegates to determine if the mnemonic should be rendered. 1902 * This method is a non operation if the underlying operating system 1903 * does not support the mnemonic hiding feature. 1904 * 1905 * @param hide true if mnemonics should be hidden 1906 * @since 1.4 1907 */ 1908 public static void setMnemonicHidden(boolean hide) { 1909 if (UIManager.getBoolean("Button.showMnemonics") == true) { 1910 // Do not hide mnemonics if the UI defaults do not support this 1911 isMnemonicHidden = false; 1912 } else { 1913 isMnemonicHidden = hide; 1914 } 1915 } 1916 1917 /** 1918 * Gets the state of the hide mnemonic flag. This only has meaning 1919 * if this feature is supported by the underlying OS. 1920 * 1921 * @return true if mnemonics are hidden, otherwise, false 1922 * @see #setMnemonicHidden 1923 * @since 1.4 1924 */ 1925 public static boolean isMnemonicHidden() { 1926 if (UIManager.getBoolean("Button.showMnemonics") == true) { 1927 // Do not hide mnemonics if the UI defaults do not support this 1928 isMnemonicHidden = false; 1929 } 1930 return isMnemonicHidden; 1931 } 1932 1933 /** 1934 * Gets the state of the flag which indicates if the old Windows 1935 * look and feel should be rendered. This flag is used by the 1936 * component UI delegates as a hint to determine which style the component 1937 * should be rendered. 1938 * 1939 * @return true if Windows 95 and Windows NT 4 look and feel should 1940 * be rendered 1941 * @since 1.4 1942 */ 1943 public static boolean isClassicWindows() { 1944 return isClassicWindows; 1945 } 1946 1947 /** 1948 * <p> 1949 * Invoked when the user attempts an invalid operation, 1950 * such as pasting into an uneditable <code>JTextField</code> 1951 * that has focus. 1952 * </p> 1953 * <p> 1954 * If the user has enabled visual error indication on 1955 * the desktop, this method will flash the caption bar 1956 * of the active window. The user can also set the 1957 * property awt.visualbell=true to achieve the same 1958 * results. 1959 * </p> 1960 * 1961 * @param component Component the error occurred in, may be 1962 * null indicating the error condition is 1963 * not directly associated with a 1964 * <code>Component</code>. 1965 * 1966 * @see javax.swing.LookAndFeel#provideErrorFeedback 1967 */ 1968 public void provideErrorFeedback(Component component) { 1969 super.provideErrorFeedback(component); 1970 } 1971 1972 /** 1973 * {@inheritDoc} 1974 */ 1975 public LayoutStyle getLayoutStyle() { 1976 LayoutStyle style = this.style; 1977 if (style == null) { 1978 style = new WindowsLayoutStyle(); 1979 this.style = style; 1980 } 1981 return style; 1982 } 1983 1984 // ********* Auditory Cue support methods and objects ********* 1985 1986 /** 1987 * Returns an <code>Action</code>. 1988 * <P> 1989 * This Action contains the information and logic to render an 1990 * auditory cue. The <code>Object</code> that is passed to this 1991 * method contains the information needed to render the auditory 1992 * cue. Normally, this <code>Object</code> is a <code>String</code> 1993 * that points to a <code>Toolkit</code> <code>desktopProperty</code>. 1994 * This <code>desktopProperty</code> is resolved by AWT and the 1995 * Windows OS. 1996 * <P> 1997 * This <code>Action</code>'s <code>actionPerformed</code> method 1998 * is fired by the <code>playSound</code> method. 1999 * 2000 * @return an Action which knows how to render the auditory 2001 * cue for one particular system or user activity 2002 * @see #playSound(Action) 2003 * @since 1.4 2004 */ 2005 protected Action createAudioAction(Object key) { 2006 if (key != null) { 2007 String audioKey = (String)key; 2008 String audioValue = (String)UIManager.get(key); 2009 return new AudioAction(audioKey, audioValue); 2010 } else { 2011 return null; 2012 } 2013 } 2014 2015 static void repaintRootPane(Component c) { 2016 JRootPane root = null; 2017 for (; c != null; c = c.getParent()) { 2018 if (c instanceof JRootPane) { 2019 root = (JRootPane)c; 2020 } 2021 } 2022 2023 if (root != null) { 2024 root.repaint(); 2025 } else { 2026 c.repaint(); 2027 } 2028 } 2029 2030 /** 2031 * Pass the name String to the super constructor. This is used 2032 * later to identify the Action and decide whether to play it or 2033 * not. Store the resource String. It is used to get the audio 2034 * resource. In this case, the resource is a <code>Runnable</code> 2035 * supplied by <code>Toolkit</code>. This <code>Runnable</code> is 2036 * effectively a pointer down into the Win32 OS that knows how to 2037 * play the right sound. 2038 * 2039 * @since 1.4 2040 */ 2041 @SuppressWarnings("serial") // Superclass is not serializable across versions 2042 private static class AudioAction extends AbstractAction { 2043 private Runnable audioRunnable; 2044 private String audioResource; 2045 /** 2046 * We use the String as the name of the Action and as a pointer to 2047 * the underlying OSes audio resource. 2048 */ 2049 public AudioAction(String name, String resource) { 2050 super(name); 2051 audioResource = resource; 2052 } 2053 public void actionPerformed(ActionEvent e) { 2054 if (audioRunnable == null) { 2055 audioRunnable = (Runnable)Toolkit.getDefaultToolkit().getDesktopProperty(audioResource); 2056 } 2057 if (audioRunnable != null) { 2058 // Runnable appears to block until completed playing, hence 2059 // start up another thread to handle playing. 2060 new Thread(null, audioRunnable, "Audio", 0, false).start(); 2061 } 2062 } 2063 } 2064 2065 /** 2066 * Gets an <code>Icon</code> from the native libraries if available, 2067 * otherwise gets it from an image resource file. 2068 */ 2069 private static class LazyWindowsIcon implements UIDefaults.LazyValue { 2070 private String nativeImage; 2071 private String resource; 2072 2073 LazyWindowsIcon(String nativeImage, String resource) { 2074 this.nativeImage = nativeImage; 2075 this.resource = resource; 2076 } 2077 2078 public Object createValue(UIDefaults table) { 2079 if (nativeImage != null) { 2080 Image image = (Image)ShellFolder.get(nativeImage); 2081 if (image != null) { 2082 return new ImageIcon(image); 2083 } 2084 } 2085 return SwingUtilities2.makeIcon(getClass(), 2086 WindowsLookAndFeel.class, 2087 resource); 2088 } 2089 } 2090 2091 2092 /** 2093 * Gets an <code>Icon</code> from the native libraries if available. 2094 * A desktop property is used to trigger reloading the icon when needed. 2095 */ 2096 private class ActiveWindowsIcon implements UIDefaults.ActiveValue { 2097 private Icon icon; 2098 private String nativeImageName; 2099 private String fallbackName; 2100 private DesktopProperty desktopProperty; 2101 2102 ActiveWindowsIcon(String desktopPropertyName, 2103 String nativeImageName, String fallbackName) { 2104 this.nativeImageName = nativeImageName; 2105 this.fallbackName = fallbackName; 2106 2107 if (OSInfo.getOSType() == OSInfo.OSType.WINDOWS && 2108 OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_XP) < 0) { 2109 // This desktop property is needed to trigger reloading the icon. 2110 // It is kept in member variable to avoid GC. 2111 this.desktopProperty = new TriggerDesktopProperty(desktopPropertyName) { 2112 @Override protected void updateUI() { 2113 icon = null; 2114 super.updateUI(); 2115 } 2116 }; 2117 } 2118 } 2119 2120 @Override 2121 public Object createValue(UIDefaults table) { 2122 if (icon == null) { 2123 Image image = (Image)ShellFolder.get(nativeImageName); 2124 if (image != null) { 2125 icon = new ImageIconUIResource(image); 2126 } 2127 } 2128 if (icon == null && fallbackName != null) { 2129 UIDefaults.LazyValue fallback = (UIDefaults.LazyValue) 2130 SwingUtilities2.makeIcon(WindowsLookAndFeel.class, 2131 BasicLookAndFeel.class, fallbackName); 2132 icon = (Icon) fallback.createValue(table); 2133 } 2134 return icon; 2135 } 2136 } 2137 2138 /** 2139 * Icon backed-up by XP Skin. 2140 */ 2141 private static class SkinIcon implements Icon, UIResource { 2142 private final Part part; 2143 private final State state; 2144 SkinIcon(Part part, State state) { 2145 this.part = part; 2146 this.state = state; 2147 } 2148 2149 /** 2150 * Draw the icon at the specified location. Icon implementations 2151 * may use the Component argument to get properties useful for 2152 * painting, e.g. the foreground or background color. 2153 */ 2154 public void paintIcon(Component c, Graphics g, int x, int y) { 2155 XPStyle xp = XPStyle.getXP(); 2156 assert xp != null; 2157 if (xp != null) { 2158 Skin skin = xp.getSkin(null, part); 2159 skin.paintSkin(g, x, y, state); 2160 } 2161 } 2162 2163 /** 2164 * Returns the icon's width. 2165 * 2166 * @return an int specifying the fixed width of the icon. 2167 */ 2168 public int getIconWidth() { 2169 int width = 0; 2170 XPStyle xp = XPStyle.getXP(); 2171 assert xp != null; 2172 if (xp != null) { 2173 Skin skin = xp.getSkin(null, part); 2174 width = skin.getWidth(); 2175 } 2176 return width; 2177 } 2178 2179 /** 2180 * Returns the icon's height. 2181 * 2182 * @return an int specifying the fixed height of the icon. 2183 */ 2184 public int getIconHeight() { 2185 int height = 0; 2186 XPStyle xp = XPStyle.getXP(); 2187 if (xp != null) { 2188 Skin skin = xp.getSkin(null, part); 2189 height = skin.getHeight(); 2190 } 2191 return height; 2192 } 2193 2194 } 2195 2196 /** 2197 * DesktopProperty for fonts. If a font with the name 'MS Sans Serif' 2198 * is returned, it is mapped to 'Microsoft Sans Serif'. 2199 */ 2200 private static class WindowsFontProperty extends DesktopProperty { 2201 WindowsFontProperty(String key, Object backup) { 2202 super(key, backup); 2203 } 2204 2205 public void invalidate(LookAndFeel laf) { 2206 if ("win.defaultGUI.font.height".equals(getKey())) { 2207 ((WindowsLookAndFeel)laf).style = null; 2208 } 2209 super.invalidate(laf); 2210 } 2211 2212 protected Object configureValue(Object value) { 2213 if (value instanceof Font) { 2214 Font font = (Font)value; 2215 if ("MS Sans Serif".equals(font.getName())) { 2216 int size = font.getSize(); 2217 // 4950968: Workaround to mimic the way Windows maps the default 2218 // font size of 6 pts to the smallest available bitmap font size. 2219 // This happens mostly on Win 98/Me & NT. 2220 int dpi; 2221 try { 2222 dpi = Toolkit.getDefaultToolkit().getScreenResolution(); 2223 } catch (HeadlessException ex) { 2224 dpi = 96; 2225 } 2226 if (Math.round(size * 72F / dpi) < 8) { 2227 size = Math.round(8 * dpi / 72F); 2228 } 2229 Font msFont = new FontUIResource("Microsoft Sans Serif", 2230 font.getStyle(), size); 2231 if (msFont.getName() != null && 2232 msFont.getName().equals(msFont.getFamily())) { 2233 font = msFont; 2234 } else if (size != font.getSize()) { 2235 font = new FontUIResource("MS Sans Serif", 2236 font.getStyle(), size); 2237 } 2238 } 2239 2240 if (FontUtilities.fontSupportsDefaultEncoding(font)) { 2241 if (!(font instanceof UIResource)) { 2242 font = new FontUIResource(font); 2243 } 2244 } 2245 else { 2246 font = FontUtilities.getCompositeFontUIResource(font); 2247 } 2248 return font; 2249 2250 } 2251 return super.configureValue(value); 2252 } 2253 } 2254 2255 2256 /** 2257 * DesktopProperty for fonts that only gets sizes from the desktop, 2258 * font name and style are passed into the constructor 2259 */ 2260 private static class WindowsFontSizeProperty extends DesktopProperty { 2261 private String fontName; 2262 private int fontSize; 2263 private int fontStyle; 2264 2265 WindowsFontSizeProperty(String key, String fontName, 2266 int fontStyle, int fontSize) { 2267 super(key, null); 2268 this.fontName = fontName; 2269 this.fontSize = fontSize; 2270 this.fontStyle = fontStyle; 2271 } 2272 2273 protected Object configureValue(Object value) { 2274 if (value == null) { 2275 value = new FontUIResource(fontName, fontStyle, fontSize); 2276 } 2277 else if (value instanceof Integer) { 2278 value = new FontUIResource(fontName, fontStyle, 2279 ((Integer)value).intValue()); 2280 } 2281 return value; 2282 } 2283 } 2284 2285 2286 /** 2287 * A value wrapper that actively retrieves values from xp or falls back 2288 * to the classic value if not running XP styles. 2289 */ 2290 private static class XPValue implements UIDefaults.ActiveValue { 2291 protected Object classicValue, xpValue; 2292 2293 // A constant that lets you specify null when using XP styles. 2294 private static final Object NULL_VALUE = new Object(); 2295 2296 XPValue(Object xpValue, Object classicValue) { 2297 this.xpValue = xpValue; 2298 this.classicValue = classicValue; 2299 } 2300 2301 public Object createValue(UIDefaults table) { 2302 Object value = null; 2303 if (XPStyle.getXP() != null) { 2304 value = getXPValue(table); 2305 } 2306 2307 if (value == null) { 2308 value = getClassicValue(table); 2309 } else if (value == NULL_VALUE) { 2310 value = null; 2311 } 2312 2313 return value; 2314 } 2315 2316 protected Object getXPValue(UIDefaults table) { 2317 return recursiveCreateValue(xpValue, table); 2318 } 2319 2320 protected Object getClassicValue(UIDefaults table) { 2321 return recursiveCreateValue(classicValue, table); 2322 } 2323 2324 private Object recursiveCreateValue(Object value, UIDefaults table) { 2325 if (value instanceof UIDefaults.LazyValue) { 2326 value = ((UIDefaults.LazyValue)value).createValue(table); 2327 } 2328 if (value instanceof UIDefaults.ActiveValue) { 2329 return ((UIDefaults.ActiveValue)value).createValue(table); 2330 } else { 2331 return value; 2332 } 2333 } 2334 } 2335 2336 private static class XPBorderValue extends XPValue { 2337 private final Border extraMargin; 2338 2339 XPBorderValue(Part xpValue, Object classicValue) { 2340 this(xpValue, classicValue, null); 2341 } 2342 2343 XPBorderValue(Part xpValue, Object classicValue, Border extraMargin) { 2344 super(xpValue, classicValue); 2345 this.extraMargin = extraMargin; 2346 } 2347 2348 public Object getXPValue(UIDefaults table) { 2349 XPStyle xp = XPStyle.getXP(); 2350 Border xpBorder = xp != null ? xp.getBorder(null, (Part)xpValue) : null; 2351 if (xpBorder != null && extraMargin != null) { 2352 return new BorderUIResource. 2353 CompoundBorderUIResource(xpBorder, extraMargin); 2354 } else { 2355 return xpBorder; 2356 } 2357 } 2358 } 2359 2360 private static class XPColorValue extends XPValue { 2361 XPColorValue(Part part, State state, Prop prop, Object classicValue) { 2362 super(new XPColorValueKey(part, state, prop), classicValue); 2363 } 2364 2365 public Object getXPValue(UIDefaults table) { 2366 XPColorValueKey key = (XPColorValueKey)xpValue; 2367 XPStyle xp = XPStyle.getXP(); 2368 return xp != null ? xp.getColor(key.skin, key.prop, null) : null; 2369 } 2370 2371 private static class XPColorValueKey { 2372 Skin skin; 2373 Prop prop; 2374 2375 XPColorValueKey(Part part, State state, Prop prop) { 2376 this.skin = new Skin(part, state); 2377 this.prop = prop; 2378 } 2379 } 2380 } 2381 2382 private class XPDLUValue extends XPValue { 2383 private int direction; 2384 2385 XPDLUValue(int xpdlu, int classicdlu, int direction) { 2386 super(Integer.valueOf(xpdlu), Integer.valueOf(classicdlu)); 2387 this.direction = direction; 2388 } 2389 2390 public Object getXPValue(UIDefaults table) { 2391 int px = dluToPixels(((Integer)xpValue).intValue(), direction); 2392 return Integer.valueOf(px); 2393 } 2394 2395 public Object getClassicValue(UIDefaults table) { 2396 int px = dluToPixels(((Integer)classicValue).intValue(), direction); 2397 return Integer.valueOf(px); 2398 } 2399 } 2400 2401 private class TriggerDesktopProperty extends DesktopProperty { 2402 TriggerDesktopProperty(String key) { 2403 super(key, null); 2404 // This call adds a property change listener for the property, 2405 // which triggers a call to updateUI(). The value returned 2406 // is not interesting here. 2407 getValueFromDesktop(); 2408 } 2409 2410 protected void updateUI() { 2411 super.updateUI(); 2412 2413 // Make sure property change listener is readded each time 2414 getValueFromDesktop(); 2415 } 2416 } 2417 2418 private class FontDesktopProperty extends TriggerDesktopProperty { 2419 FontDesktopProperty(String key) { 2420 super(key); 2421 } 2422 2423 protected void updateUI() { 2424 UIDefaults defaults = UIManager.getLookAndFeelDefaults(); 2425 SwingUtilities2.putAATextInfo(true, defaults); 2426 super.updateUI(); 2427 } 2428 } 2429 2430 // Windows LayoutStyle. From: 2431 // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwue/html/ch14e.asp 2432 @SuppressWarnings("fallthrough") 2433 private class WindowsLayoutStyle extends DefaultLayoutStyle { 2434 @Override 2435 public int getPreferredGap(JComponent component1, 2436 JComponent component2, ComponentPlacement type, int position, 2437 Container parent) { 2438 // Checks args 2439 super.getPreferredGap(component1, component2, type, position, 2440 parent); 2441 2442 switch(type) { 2443 case INDENT: 2444 // Windows doesn't spec this 2445 if (position == SwingConstants.EAST || 2446 position == SwingConstants.WEST) { 2447 int indent = getIndent(component1, position); 2448 if (indent > 0) { 2449 return indent; 2450 } 2451 return 10; 2452 } 2453 // Fall through to related. 2454 case RELATED: 2455 if (isLabelAndNonlabel(component1, component2, position)) { 2456 // Between text labels and their associated controls (for 2457 // example, text boxes and list boxes): 3 2458 // NOTE: We're not honoring: 2459 // 'Text label beside a button 3 down from the top of 2460 // the button,' but I suspect that is an attempt to 2461 // enforce a baseline layout which will be handled 2462 // separately. In order to enforce this we would need 2463 // this API to return a more complicated type (Insets, 2464 // or something else). 2465 return getButtonGap(component1, component2, position, 2466 dluToPixels(3, position)); 2467 } 2468 // Between related controls: 4 2469 return getButtonGap(component1, component2, position, 2470 dluToPixels(4, position)); 2471 case UNRELATED: 2472 // Between unrelated controls: 7 2473 return getButtonGap(component1, component2, position, 2474 dluToPixels(7, position)); 2475 } 2476 return 0; 2477 } 2478 2479 @Override 2480 public int getContainerGap(JComponent component, int position, 2481 Container parent) { 2482 // Checks args 2483 super.getContainerGap(component, position, parent); 2484 return getButtonGap(component, position, dluToPixels(7, position)); 2485 } 2486 2487 } 2488 2489 /** 2490 * Converts the dialog unit argument to pixels along the specified 2491 * axis. 2492 */ 2493 private int dluToPixels(int dlu, int direction) { 2494 if (baseUnitX == 0) { 2495 calculateBaseUnits(); 2496 } 2497 if (direction == SwingConstants.EAST || 2498 direction == SwingConstants.WEST) { 2499 return dlu * baseUnitX / 4; 2500 } 2501 assert (direction == SwingConstants.NORTH || 2502 direction == SwingConstants.SOUTH); 2503 return dlu * baseUnitY / 8; 2504 } 2505 2506 /** 2507 * Calculates the dialog unit mapping. 2508 */ 2509 @SuppressWarnings("deprecation") 2510 private void calculateBaseUnits() { 2511 // This calculation comes from: 2512 // http://support.microsoft.com/default.aspx?scid=kb;EN-US;125681 2513 FontMetrics metrics = Toolkit.getDefaultToolkit().getFontMetrics( 2514 UIManager.getFont("Button.font")); 2515 baseUnitX = metrics.stringWidth( 2516 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"); 2517 baseUnitX = (baseUnitX / 26 + 1) / 2; 2518 // The -1 comes from experimentation. 2519 baseUnitY = metrics.getAscent() + metrics.getDescent() - 1; 2520 } 2521 2522 /** 2523 * {@inheritDoc} 2524 * 2525 * @since 1.6 2526 */ 2527 public Icon getDisabledIcon(JComponent component, Icon icon) { 2528 // if the component has a HI_RES_DISABLED_ICON_CLIENT_KEY 2529 // client property set to Boolean.TRUE, then use the new 2530 // hi res algorithm for creating the disabled icon (used 2531 // in particular by the WindowsFileChooserUI class) 2532 if (icon != null 2533 && component != null 2534 && Boolean.TRUE.equals(component.getClientProperty(HI_RES_DISABLED_ICON_CLIENT_KEY)) 2535 && icon.getIconWidth() > 0 2536 && icon.getIconHeight() > 0) { 2537 BufferedImage img = new BufferedImage(icon.getIconWidth(), 2538 icon.getIconWidth(), BufferedImage.TYPE_INT_ARGB); 2539 icon.paintIcon(component, img.getGraphics(), 0, 0); 2540 ImageFilter filter = new RGBGrayFilter(); 2541 ImageProducer producer = new FilteredImageSource(img.getSource(), filter); 2542 Image resultImage = component.createImage(producer); 2543 return new ImageIconUIResource(resultImage); 2544 } 2545 return super.getDisabledIcon(component, icon); 2546 } 2547 2548 private static class RGBGrayFilter extends RGBImageFilter { 2549 public RGBGrayFilter() { 2550 canFilterIndexColorModel = true; 2551 } 2552 public int filterRGB(int x, int y, int rgb) { 2553 // find the average of red, green, and blue 2554 float avg = (((rgb >> 16) & 0xff) / 255f + 2555 ((rgb >> 8) & 0xff) / 255f + 2556 (rgb & 0xff) / 255f) / 3; 2557 // pull out the alpha channel 2558 float alpha = (((rgb>>24)&0xff)/255f); 2559 // calc the average 2560 avg = Math.min(1.0f, (1f-avg)/(100.0f/35.0f) + avg); 2561 // turn back into rgb 2562 int rgbval = (int)(alpha * 255f) << 24 | 2563 (int)(avg * 255f) << 16 | 2564 (int)(avg * 255f) << 8 | 2565 (int)(avg * 255f); 2566 return rgbval; 2567 } 2568 } 2569 2570 private static class FocusColorProperty extends DesktopProperty { 2571 public FocusColorProperty () { 2572 // Fallback value is never used because of the configureValue method doesn't return null 2573 super("win.3d.backgroundColor", Color.BLACK); 2574 } 2575 2576 @Override 2577 protected Object configureValue(Object value) { 2578 Object highContrastOn = Toolkit.getDefaultToolkit(). 2579 getDesktopProperty("win.highContrast.on"); 2580 if (highContrastOn == null || !((Boolean) highContrastOn).booleanValue()) { 2581 return Color.BLACK; 2582 } 2583 return Color.BLACK.equals(value) ? Color.WHITE : Color.BLACK; 2584 } 2585 } 2586 2587} 2588