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