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