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