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