1. /*
  2. * @(#)WindowsLookAndFeel.java 1.182 04/06/15
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. /*
  8. * <p>These classes are designed to be used while the
  9. * corresponding <code>LookAndFeel</code> class has been installed
  10. * (<code>UIManager.setLookAndFeel(new <i>XXX</i>LookAndFeel())</code>).
  11. * Using them while a different <code>LookAndFeel</code> is installed
  12. * may produce unexpected results, including exceptions.
  13. * Additionally, changing the <code>LookAndFeel</code>
  14. * maintained by the <code>UIManager</code> without updating the
  15. * corresponding <code>ComponentUI</code> of any
  16. * <code>JComponent</code>s may also produce unexpected results,
  17. * such as the wrong colors showing up, and is generally not
  18. * encouraged.
  19. *
  20. */
  21. package com.sun.java.swing.plaf.windows;
  22. import java.awt.*;
  23. import javax.swing.plaf.*;
  24. import javax.swing.*;
  25. import javax.swing.plaf.basic.*;
  26. import javax.swing.border.*;
  27. import javax.swing.text.JTextComponent;
  28. import javax.swing.text.DefaultEditorKit;
  29. import java.awt.Font;
  30. import java.awt.Color;
  31. import java.awt.SystemColor;
  32. import java.awt.event.KeyEvent;
  33. import java.awt.event.InputEvent;
  34. import java.awt.event.ActionEvent;
  35. import java.beans.PropertyChangeListener;
  36. import java.beans.PropertyChangeEvent;
  37. import java.net.URL;
  38. import java.io.Serializable;
  39. import java.security.AccessController;
  40. import java.util.*;
  41. import sun.awt.shell.ShellFolder;
  42. import sun.font.FontManager;
  43. import sun.security.action.GetPropertyAction;
  44. import sun.swing.SwingLazyValue;
  45. /**
  46. * Implements the Windows95/98/NT/2000 Look and Feel.
  47. * UI classes not implemented specifically for Windows will
  48. * default to those implemented in Basic.
  49. * <p>
  50. * <strong>Warning:</strong>
  51. * Serialized objects of this class will not be compatible with
  52. * future Swing releases. The current serialization support is appropriate
  53. * for short term storage or RMI between applications running the same
  54. * version of Swing. A future release of Swing will provide support for
  55. * long term persistence.
  56. *
  57. * @version 1.182 06/15/04
  58. * @author unattributed
  59. */
  60. public class WindowsLookAndFeel extends BasicLookAndFeel
  61. {
  62. private Toolkit toolkit;
  63. private boolean updatePending = false;
  64. private boolean useSystemFontSettings = true;
  65. private boolean useSystemFontSizeSettings;
  66. // This property is not used directly, but is kept as
  67. // a private member to avoid it being GC'd.
  68. private DesktopProperty xpStyleColorName;
  69. public String getName() {
  70. return "Windows";
  71. }
  72. public String getDescription() {
  73. return "The Microsoft Windows Look and Feel";
  74. }
  75. public String getID() {
  76. return "Windows";
  77. }
  78. public boolean isNativeLookAndFeel() {
  79. String osName = System.getProperty("os.name");
  80. return (osName != null) && (osName.indexOf("Windows") != -1);
  81. }
  82. public boolean isSupportedLookAndFeel() {
  83. return isNativeLookAndFeel();
  84. }
  85. public void initialize() {
  86. super.initialize();
  87. toolkit = Toolkit.getDefaultToolkit();
  88. // Set the flag which determines which version of Windows should
  89. // be rendered. This flag only need to be set once.
  90. // if version <= 4.0 then the classic LAF should be loaded.
  91. String osVersion = System.getProperty("os.version");
  92. if (osVersion != null) {
  93. Float version = Float.valueOf(osVersion);
  94. if (version.floatValue() <= 4.0) {
  95. isClassicWindows = true;
  96. } else {
  97. isClassicWindows = false;
  98. XPStyle.invalidateStyle();
  99. }
  100. }
  101. // Using the fonts set by the user can potentially cause
  102. // performance and compatibility issues, so allow this feature
  103. // to be switched off either at runtime or programmatically
  104. //
  105. String systemFonts = (String) java.security.AccessController.doPrivileged(
  106. new GetPropertyAction("swing.useSystemFontSettings"));
  107. useSystemFontSettings = (systemFonts == null ||
  108. Boolean.valueOf(systemFonts).booleanValue());
  109. if (useSystemFontSettings) {
  110. Object value = UIManager.get("Application.useSystemFontSettings");
  111. useSystemFontSettings = (value == null ||
  112. Boolean.TRUE.equals(value));
  113. }
  114. KeyboardFocusManager.getCurrentKeyboardFocusManager().
  115. addKeyEventPostProcessor(WindowsRootPaneUI.altProcessor);
  116. }
  117. /**
  118. * Initialize the uiClassID to BasicComponentUI mapping.
  119. * The JComponent classes define their own uiClassID constants
  120. * (see AbstractComponent.getUIClassID). This table must
  121. * map those constants to a BasicComponentUI class of the
  122. * appropriate type.
  123. *
  124. * @see BasicLookAndFeel#getDefaults
  125. */
  126. protected void initClassDefaults(UIDefaults table)
  127. {
  128. super.initClassDefaults(table);
  129. final String windowsPackageName = "com.sun.java.swing.plaf.windows.";
  130. Object[] uiDefaults = {
  131. "ButtonUI", windowsPackageName + "WindowsButtonUI",
  132. "CheckBoxUI", windowsPackageName + "WindowsCheckBoxUI",
  133. "CheckBoxMenuItemUI", windowsPackageName + "WindowsCheckBoxMenuItemUI",
  134. "LabelUI", windowsPackageName + "WindowsLabelUI",
  135. "RadioButtonUI", windowsPackageName + "WindowsRadioButtonUI",
  136. "RadioButtonMenuItemUI", windowsPackageName + "WindowsRadioButtonMenuItemUI",
  137. "ToggleButtonUI", windowsPackageName + "WindowsToggleButtonUI",
  138. "ProgressBarUI", windowsPackageName + "WindowsProgressBarUI",
  139. "SliderUI", windowsPackageName + "WindowsSliderUI",
  140. "SeparatorUI", windowsPackageName + "WindowsSeparatorUI",
  141. "SplitPaneUI", windowsPackageName + "WindowsSplitPaneUI",
  142. "SpinnerUI", windowsPackageName + "WindowsSpinnerUI",
  143. "TabbedPaneUI", windowsPackageName + "WindowsTabbedPaneUI",
  144. "TextAreaUI", windowsPackageName + "WindowsTextAreaUI",
  145. "TextFieldUI", windowsPackageName + "WindowsTextFieldUI",
  146. "PasswordFieldUI", windowsPackageName + "WindowsPasswordFieldUI",
  147. "TextPaneUI", windowsPackageName + "WindowsTextPaneUI",
  148. "EditorPaneUI", windowsPackageName + "WindowsEditorPaneUI",
  149. "TreeUI", windowsPackageName + "WindowsTreeUI",
  150. "ToolBarUI", windowsPackageName + "WindowsToolBarUI",
  151. "ToolBarSeparatorUI", windowsPackageName + "WindowsToolBarSeparatorUI",
  152. "ComboBoxUI", windowsPackageName + "WindowsComboBoxUI",
  153. "TableHeaderUI", windowsPackageName + "WindowsTableHeaderUI",
  154. "InternalFrameUI", windowsPackageName + "WindowsInternalFrameUI",
  155. "DesktopPaneUI", windowsPackageName + "WindowsDesktopPaneUI",
  156. "DesktopIconUI", windowsPackageName + "WindowsDesktopIconUI",
  157. "FileChooserUI", windowsPackageName + "WindowsFileChooserUI",
  158. "MenuUI", windowsPackageName + "WindowsMenuUI",
  159. "MenuItemUI", windowsPackageName + "WindowsMenuItemUI",
  160. "MenuBarUI", windowsPackageName + "WindowsMenuBarUI",
  161. "PopupMenuUI", windowsPackageName + "WindowsPopupMenuUI",
  162. "ScrollBarUI", windowsPackageName + "WindowsScrollBarUI",
  163. "RootPaneUI", windowsPackageName + "WindowsRootPaneUI"
  164. };
  165. table.putDefaults(uiDefaults);
  166. }
  167. /**
  168. * Load the SystemColors into the defaults table. The keys
  169. * for SystemColor defaults are the same as the names of
  170. * the public fields in SystemColor. If the table is being
  171. * created on a native Windows platform we use the SystemColor
  172. * values, otherwise we create color objects whose values match
  173. * the defaults Windows95 colors.
  174. */
  175. protected void initSystemColorDefaults(UIDefaults table)
  176. {
  177. String[] defaultSystemColors = {
  178. "desktop", "#005C5C", /* Color of the desktop background */
  179. "activeCaption", "#000080", /* Color for captions (title bars) when they are active. */
  180. "activeCaptionText", "#FFFFFF", /* Text color for text in captions (title bars). */
  181. "activeCaptionBorder", "#C0C0C0", /* Border color for caption (title bar) window borders. */
  182. "inactiveCaption", "#808080", /* Color for captions (title bars) when not active. */
  183. "inactiveCaptionText", "#C0C0C0", /* Text color for text in inactive captions (title bars). */
  184. "inactiveCaptionBorder", "#C0C0C0", /* Border color for inactive caption (title bar) window borders. */
  185. "window", "#FFFFFF", /* Default color for the interior of windows */
  186. "windowBorder", "#000000", /* ??? */
  187. "windowText", "#000000", /* ??? */
  188. "menu", "#C0C0C0", /* Background color for menus */
  189. "menuPressedItemB", "#000080", /* LightShadow of menubutton highlight */
  190. "menuPressedItemF", "#FFFFFF", /* Default color for foreground "text" in menu item */
  191. "menuText", "#000000", /* Text color for menus */
  192. "text", "#C0C0C0", /* Text background color */
  193. "textText", "#000000", /* Text foreground color */
  194. "textHighlight", "#000080", /* Text background color when selected */
  195. "textHighlightText", "#FFFFFF", /* Text color when selected */
  196. "textInactiveText", "#808080", /* Text color when disabled */
  197. "control", "#C0C0C0", /* Default color for controls (buttons, sliders, etc) */
  198. "controlText", "#000000", /* Default color for text in controls */
  199. "controlHighlight", "#C0C0C0",
  200. /*"controlHighlight", "#E0E0E0",*/ /* Specular highlight (opposite of the shadow) */
  201. "controlLtHighlight", "#FFFFFF", /* Highlight color for controls */
  202. "controlShadow", "#808080", /* Shadow color for controls */
  203. "controlDkShadow", "#000000", /* Dark shadow color for controls */
  204. "scrollbar", "#E0E0E0", /* Scrollbar background (usually the "track") */
  205. "info", "#FFFFE1", /* ??? */
  206. "infoText", "#000000" /* ??? */
  207. };
  208. loadSystemColors(table, defaultSystemColors, isNativeLookAndFeel());
  209. }
  210. /**
  211. * Initialize the defaults table with the name of the ResourceBundle
  212. * used for getting localized defaults.
  213. */
  214. private void initResourceBundle(UIDefaults table) {
  215. table.addResourceBundle( "com.sun.java.swing.plaf.windows.resources.windows" );
  216. }
  217. // XXX - there are probably a lot of redundant values that could be removed.
  218. // ie. Take a look at RadioButtonBorder, etc...
  219. protected void initComponentDefaults(UIDefaults table)
  220. {
  221. super.initComponentDefaults( table );
  222. initResourceBundle(table);
  223. // *** Shared Fonts
  224. Integer twelve = new Integer(12);
  225. Integer eight = new Integer(8);
  226. Integer ten = new Integer(10);
  227. Integer fontPlain = new Integer(Font.PLAIN);
  228. Integer fontBold = new Integer(Font.BOLD);
  229. Object dialogPlain12 = new SwingLazyValue(
  230. "javax.swing.plaf.FontUIResource",
  231. null,
  232. new Object[] {"Dialog", fontPlain, twelve});
  233. Object sansSerifPlain12 = new SwingLazyValue(
  234. "javax.swing.plaf.FontUIResource",
  235. null,
  236. new Object[] {"SansSerif", fontPlain, twelve});
  237. Object monospacedPlain12 = new SwingLazyValue(
  238. "javax.swing.plaf.FontUIResource",
  239. null,
  240. new Object[] {"MonoSpaced", fontPlain, twelve});
  241. Object dialogBold12 = new SwingLazyValue(
  242. "javax.swing.plaf.FontUIResource",
  243. null,
  244. new Object[] {"Dialog", fontBold, twelve});
  245. // *** Colors
  246. // XXX - some of these doens't seem to be used
  247. ColorUIResource red = new ColorUIResource(Color.red);
  248. ColorUIResource black = new ColorUIResource(Color.black);
  249. ColorUIResource white = new ColorUIResource(Color.white);
  250. ColorUIResource yellow = new ColorUIResource(Color.yellow);
  251. ColorUIResource gray = new ColorUIResource(Color.gray);
  252. ColorUIResource lightGray = new ColorUIResource(Color.lightGray);
  253. ColorUIResource darkGray = new ColorUIResource(Color.darkGray);
  254. ColorUIResource scrollBarTrack = lightGray;
  255. ColorUIResource scrollBarTrackHighlight = darkGray;
  256. // Set the flag which determines which version of Windows should
  257. // be rendered. This flag only need to be set once.
  258. // if version <= 4.0 then the classic LAF should be loaded.
  259. String osVersion = System.getProperty("os.version");
  260. if (osVersion != null) {
  261. try {
  262. Float version = Float.valueOf(osVersion);
  263. if (version.floatValue() <= 4.0) {
  264. isClassicWindows = true;
  265. } else {
  266. isClassicWindows = false;
  267. }
  268. } catch (NumberFormatException ex) {
  269. isClassicWindows = false;
  270. }
  271. }
  272. // *** Tree
  273. ColorUIResource treeSelection = new ColorUIResource(0, 0, 128);
  274. Object treeExpandedIcon = WindowsTreeUI.ExpandedIcon.createExpandedIcon();
  275. Object treeCollapsedIcon = WindowsTreeUI.CollapsedIcon.createCollapsedIcon();
  276. // *** Text
  277. Object fieldInputMap = new UIDefaults.LazyInputMap(new Object[] {
  278. "control C", DefaultEditorKit.copyAction,
  279. "control V", DefaultEditorKit.pasteAction,
  280. "control X", DefaultEditorKit.cutAction,
  281. "COPY", DefaultEditorKit.copyAction,
  282. "PASTE", DefaultEditorKit.pasteAction,
  283. "CUT", DefaultEditorKit.cutAction,
  284. "control INSERT", DefaultEditorKit.copyAction,
  285. "shift INSERT", DefaultEditorKit.pasteAction,
  286. "shift DELETE", DefaultEditorKit.cutAction,
  287. "control A", DefaultEditorKit.selectAllAction,
  288. "control BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/,
  289. "shift LEFT", DefaultEditorKit.selectionBackwardAction,
  290. "shift RIGHT", DefaultEditorKit.selectionForwardAction,
  291. "control LEFT", DefaultEditorKit.previousWordAction,
  292. "control RIGHT", DefaultEditorKit.nextWordAction,
  293. "control shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
  294. "control shift RIGHT", DefaultEditorKit.selectionNextWordAction,
  295. "HOME", DefaultEditorKit.beginLineAction,
  296. "END", DefaultEditorKit.endLineAction,
  297. "shift HOME", DefaultEditorKit.selectionBeginLineAction,
  298. "shift END", DefaultEditorKit.selectionEndLineAction,
  299. "BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
  300. "ctrl H", DefaultEditorKit.deletePrevCharAction,
  301. "DELETE", DefaultEditorKit.deleteNextCharAction,
  302. "RIGHT", DefaultEditorKit.forwardAction,
  303. "LEFT", DefaultEditorKit.backwardAction,
  304. "KP_RIGHT", DefaultEditorKit.forwardAction,
  305. "KP_LEFT", DefaultEditorKit.backwardAction,
  306. "ENTER", JTextField.notifyAction,
  307. "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
  308. });
  309. Object passwordInputMap = new UIDefaults.LazyInputMap(new Object[] {
  310. "control C", DefaultEditorKit.copyAction,
  311. "control V", DefaultEditorKit.pasteAction,
  312. "control X", DefaultEditorKit.cutAction,
  313. "COPY", DefaultEditorKit.copyAction,
  314. "PASTE", DefaultEditorKit.pasteAction,
  315. "CUT", DefaultEditorKit.cutAction,
  316. "control INSERT", DefaultEditorKit.copyAction,
  317. "shift INSERT", DefaultEditorKit.pasteAction,
  318. "shift DELETE", DefaultEditorKit.cutAction,
  319. "control A", DefaultEditorKit.selectAllAction,
  320. "control BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/,
  321. "shift LEFT", DefaultEditorKit.selectionBackwardAction,
  322. "shift RIGHT", DefaultEditorKit.selectionForwardAction,
  323. "control LEFT", DefaultEditorKit.beginLineAction,
  324. "control RIGHT", DefaultEditorKit.endLineAction,
  325. "control shift LEFT", DefaultEditorKit.selectionBeginLineAction,
  326. "control shift RIGHT", DefaultEditorKit.selectionEndLineAction,
  327. "HOME", DefaultEditorKit.beginLineAction,
  328. "END", DefaultEditorKit.endLineAction,
  329. "shift HOME", DefaultEditorKit.selectionBeginLineAction,
  330. "shift END", DefaultEditorKit.selectionEndLineAction,
  331. "BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
  332. "ctrl H", DefaultEditorKit.deletePrevCharAction,
  333. "DELETE", DefaultEditorKit.deleteNextCharAction,
  334. "RIGHT", DefaultEditorKit.forwardAction,
  335. "LEFT", DefaultEditorKit.backwardAction,
  336. "KP_RIGHT", DefaultEditorKit.forwardAction,
  337. "KP_LEFT", DefaultEditorKit.backwardAction,
  338. "ENTER", JTextField.notifyAction,
  339. "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
  340. });
  341. Object multilineInputMap = new UIDefaults.LazyInputMap(new Object[] {
  342. "control C", DefaultEditorKit.copyAction,
  343. "control V", DefaultEditorKit.pasteAction,
  344. "control X", DefaultEditorKit.cutAction,
  345. "COPY", DefaultEditorKit.copyAction,
  346. "PASTE", DefaultEditorKit.pasteAction,
  347. "CUT", DefaultEditorKit.cutAction,
  348. "control INSERT", DefaultEditorKit.copyAction,
  349. "shift INSERT", DefaultEditorKit.pasteAction,
  350. "shift DELETE", DefaultEditorKit.cutAction,
  351. "shift LEFT", DefaultEditorKit.selectionBackwardAction,
  352. "shift RIGHT", DefaultEditorKit.selectionForwardAction,
  353. "control LEFT", DefaultEditorKit.previousWordAction,
  354. "control RIGHT", DefaultEditorKit.nextWordAction,
  355. "control shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
  356. "control shift RIGHT", DefaultEditorKit.selectionNextWordAction,
  357. "control A", DefaultEditorKit.selectAllAction,
  358. "control BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/,
  359. "HOME", DefaultEditorKit.beginLineAction,
  360. "END", DefaultEditorKit.endLineAction,
  361. "shift HOME", DefaultEditorKit.selectionBeginLineAction,
  362. "shift END", DefaultEditorKit.selectionEndLineAction,
  363. "control HOME", DefaultEditorKit.beginAction,
  364. "control END", DefaultEditorKit.endAction,
  365. "control shift HOME", DefaultEditorKit.selectionBeginAction,
  366. "control shift END", DefaultEditorKit.selectionEndAction,
  367. "UP", DefaultEditorKit.upAction,
  368. "DOWN", DefaultEditorKit.downAction,
  369. "BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
  370. "ctrl H", DefaultEditorKit.deletePrevCharAction,
  371. "DELETE", DefaultEditorKit.deleteNextCharAction,
  372. "RIGHT", DefaultEditorKit.forwardAction,
  373. "LEFT", DefaultEditorKit.backwardAction,
  374. "KP_RIGHT", DefaultEditorKit.forwardAction,
  375. "KP_LEFT", DefaultEditorKit.backwardAction,
  376. "PAGE_UP", DefaultEditorKit.pageUpAction,
  377. "PAGE_DOWN", DefaultEditorKit.pageDownAction,
  378. "shift PAGE_UP", "selection-page-up",
  379. "shift PAGE_DOWN", "selection-page-down",
  380. "ctrl shift PAGE_UP", "selection-page-left",
  381. "ctrl shift PAGE_DOWN", "selection-page-right",
  382. "shift UP", DefaultEditorKit.selectionUpAction,
  383. "shift DOWN", DefaultEditorKit.selectionDownAction,
  384. "ENTER", DefaultEditorKit.insertBreakAction,
  385. "TAB", DefaultEditorKit.insertTabAction,
  386. "control T", "next-link-action",
  387. "control shift T", "previous-link-action",
  388. "control SPACE", "activate-link-action",
  389. "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
  390. });
  391. Object menuItemAcceleratorDelimiter = new String("+");
  392. Object ControlBackgroundColor = new DesktopProperty(
  393. "win.3d.backgroundColor",
  394. table.get("control"),
  395. toolkit);
  396. Object ControlLightColor = new DesktopProperty(
  397. "win.3d.lightColor",
  398. table.get("controlHighlight"),
  399. toolkit);
  400. Object ControlHighlightColor = new DesktopProperty(
  401. "win.3d.highlightColor",
  402. table.get("controlLtHighlight"),
  403. toolkit);
  404. Object ControlShadowColor = new DesktopProperty(
  405. "win.3d.shadowColor",
  406. table.get("controlShadow"),
  407. toolkit);
  408. Object ControlDarkShadowColor = new DesktopProperty(
  409. "win.3d.darkShadowColor",
  410. table.get("controlDkShadow"),
  411. toolkit);
  412. Object ControlTextColor = new DesktopProperty(
  413. "win.button.textColor",
  414. table.get("controlText"),
  415. toolkit);
  416. Object MenuBackgroundColor = new DesktopProperty(
  417. "win.menu.backgroundColor",
  418. table.get("menu"),
  419. toolkit);
  420. Object MenuBarBackgroundColor = new DesktopProperty(
  421. "win.menubar.backgroundColor",
  422. table.get("menu"),
  423. toolkit);
  424. Object MenuTextColor = new DesktopProperty(
  425. "win.menu.textColor",
  426. table.get("menuText"),
  427. toolkit);
  428. Object SelectionBackgroundColor = new DesktopProperty(
  429. "win.item.highlightColor",
  430. table.get("textHighlight"),
  431. toolkit);
  432. Object SelectionTextColor = new DesktopProperty(
  433. "win.item.highlightTextColor",
  434. table.get("textHighlightText"),
  435. toolkit);
  436. Object WindowBackgroundColor = new DesktopProperty(
  437. "win.frame.backgroundColor",
  438. table.get("window"),
  439. toolkit);
  440. Object WindowTextColor = new DesktopProperty(
  441. "win.frame.textColor",
  442. table.get("windowText"),
  443. toolkit);
  444. Object WindowBorderWidth = new DesktopProperty(
  445. "win.frame.sizingBorderWidth",
  446. new Integer(1),
  447. toolkit);
  448. Object TitlePaneHeight = new DesktopProperty(
  449. "win.frame.captionHeight",
  450. new Integer(18),
  451. toolkit);
  452. Object TitleButtonWidth = new DesktopProperty(
  453. "win.frame.captionButtonWidth",
  454. new Integer(16),
  455. toolkit);
  456. Object TitleButtonHeight = new DesktopProperty(
  457. "win.frame.captionButtonHeight",
  458. new Integer(16),
  459. toolkit);
  460. Object InactiveTextColor = new DesktopProperty(
  461. "win.text.grayedTextColor",
  462. table.get("textInactiveText"),
  463. toolkit);
  464. Object ScrollbarBackgroundColor = new DesktopProperty(
  465. "win.scrollbar.backgroundColor",
  466. table.get("scrollbar"),
  467. toolkit);
  468. Object TextBackground = new XPColorValue("edit.fillcolor",
  469. WindowBackgroundColor);
  470. Object ReadOnlyTextBackground = new XPColorValue("edit.edittext(readonly).fillcolor",
  471. ControlBackgroundColor);
  472. Object DisabledTextBackground = new XPColorValue("edit.edittext(disabled).fillcolor",
  473. ControlBackgroundColor);
  474. Object MenuFont = dialogPlain12;
  475. Object FixedControlFont = monospacedPlain12;
  476. Object ControlFont = dialogPlain12;
  477. Object MessageFont = dialogPlain12;
  478. Object WindowFont = dialogBold12;
  479. Object ToolTipFont = sansSerifPlain12;
  480. Object IconFont = ControlFont;
  481. Object scrollBarWidth = new DesktopProperty("win.scrollbar.width",
  482. new Integer(16), toolkit);
  483. Object showMnemonics = new DesktopProperty("win.menu.keyboardCuesOn",
  484. Boolean.TRUE, toolkit);
  485. if (useSystemFontSettings) {
  486. MenuFont = getDesktopFontValue("win.menu.font", MenuFont, toolkit);
  487. FixedControlFont = getDesktopFontValue("win.ansiFixed.font",
  488. FixedControlFont, toolkit);
  489. ControlFont = getDesktopFontValue("win.defaultGUI.font",
  490. ControlFont, toolkit);
  491. MessageFont = getDesktopFontValue("win.messagebox.font",
  492. MessageFont, toolkit);
  493. WindowFont = getDesktopFontValue("win.frame.captionFont",
  494. WindowFont, toolkit);
  495. IconFont = getDesktopFontValue("win.icon.font",
  496. IconFont, toolkit);
  497. ToolTipFont = getDesktopFontValue("win.tooltip.font", ToolTipFont,
  498. toolkit);
  499. }
  500. if (useSystemFontSizeSettings) {
  501. MenuFont = new WindowsFontSizeProperty("win.menu.font.height",
  502. toolkit, "Dialog", Font.PLAIN, 12);
  503. FixedControlFont = new WindowsFontSizeProperty(
  504. "win.ansiFixed.font.height", toolkit, "MonoSpaced",
  505. Font.PLAIN, 12);
  506. ControlFont = new WindowsFontSizeProperty(
  507. "win.defaultGUI.font.height", toolkit, "Dialog",
  508. Font.PLAIN, 12);
  509. MessageFont = new WindowsFontSizeProperty(
  510. "win.messagebox.font.height",
  511. toolkit, "Dialog", Font.PLAIN, 12);
  512. WindowFont = new WindowsFontSizeProperty(
  513. "win.frame.captionFont.height", toolkit,
  514. "Dialog", Font.BOLD, 12);
  515. ToolTipFont = new WindowsFontSizeProperty(
  516. "win.tooltip.font.height", toolkit, "SansSerif",
  517. Font.PLAIN, 12);
  518. IconFont = new WindowsFontSizeProperty(
  519. "win.icon.font.height", toolkit, "Dialog",
  520. Font.PLAIN, 12);
  521. }
  522. if (!(this instanceof WindowsClassicLookAndFeel) &&
  523. System.getProperty("os.name").startsWith("Windows XP") &&
  524. AccessController.doPrivileged(new GetPropertyAction("swing.noxp")) == null) {
  525. // This desktop property is not used directly, but is needed to
  526. // trigger realoading of UI's.
  527. this.xpStyleColorName =
  528. new DesktopProperty("win.xpstyle.colorName", null, toolkit) {
  529. /*initializer*/ {
  530. // This call adds a property change listener for the property,
  531. // which triggers a call to updateUI(). The value returned
  532. // is not interesting here.
  533. getValueFromDesktop();
  534. }
  535. protected void updateUI() {
  536. super.updateUI();
  537. // Make sure property change listener is readded each time
  538. getValueFromDesktop();
  539. }
  540. };
  541. }
  542. Object[] defaults = {
  543. // *** Auditory Feedback
  544. // this key defines which of the various cues to render
  545. // Overridden from BasicL&F. This L&F should play all sounds
  546. // all the time. The infrastructure decides what to play.
  547. // This is disabled until sound bugs can be resolved.
  548. "AuditoryCues.playList", null, // table.get("AuditoryCues.cueList"),
  549. "Application.useSystemFontSettings", Boolean.valueOf(useSystemFontSettings),
  550. "TextField.focusInputMap", fieldInputMap,
  551. "PasswordField.focusInputMap", passwordInputMap,
  552. "TextArea.focusInputMap", multilineInputMap,
  553. "TextPane.focusInputMap", multilineInputMap,
  554. "EditorPane.focusInputMap", multilineInputMap,
  555. // Buttons
  556. "Button.font", ControlFont,
  557. "Button.background", ControlBackgroundColor,
  558. "Button.foreground", ControlTextColor,
  559. "Button.shadow", ControlShadowColor,
  560. "Button.darkShadow", ControlDarkShadowColor,
  561. "Button.light", ControlLightColor,
  562. "Button.highlight", ControlHighlightColor,
  563. "Button.disabledForeground", InactiveTextColor,
  564. "Button.disabledShadow", ControlHighlightColor,
  565. "Button.focus", black,
  566. "Button.dashedRectGapX", new Integer(5),
  567. "Button.dashedRectGapY", new Integer(4),
  568. "Button.dashedRectGapWidth", new Integer(10),
  569. "Button.dashedRectGapHeight", new Integer(8),
  570. "Button.textShiftOffset", new Integer(1),
  571. // W2K keyboard navigation hidding.
  572. "Button.showMnemonics", showMnemonics,
  573. "Button.focusInputMap",
  574. new UIDefaults.LazyInputMap(new Object[] {
  575. "SPACE", "pressed",
  576. "released SPACE", "released"
  577. }),
  578. "CheckBox.font", ControlFont,
  579. "CheckBox.interiorBackground", WindowBackgroundColor,
  580. "CheckBox.background", ControlBackgroundColor,
  581. "CheckBox.foreground", ControlTextColor,
  582. "CheckBox.shadow", ControlShadowColor,
  583. "CheckBox.darkShadow", ControlDarkShadowColor,
  584. "CheckBox.light", ControlLightColor,
  585. "CheckBox.highlight", ControlHighlightColor,
  586. "CheckBox.focus", black,
  587. "CheckBox.focusInputMap",
  588. new UIDefaults.LazyInputMap(new Object[] {
  589. "SPACE", "pressed",
  590. "released SPACE", "released"
  591. }),
  592. "CheckBoxMenuItem.font", MenuFont,
  593. "CheckBoxMenuItem.background", MenuBackgroundColor,
  594. "CheckBoxMenuItem.foreground", MenuTextColor,
  595. "CheckBoxMenuItem.selectionForeground", SelectionTextColor,
  596. "CheckBoxMenuItem.selectionBackground", SelectionBackgroundColor,
  597. "CheckBoxMenuItem.acceleratorForeground", MenuTextColor,
  598. "CheckBoxMenuItem.acceleratorSelectionForeground", SelectionTextColor,
  599. "CheckBoxMenuItem.commandSound", "win.sound.menuCommand",
  600. "ComboBox.font", ControlFont,
  601. "ComboBox.background", WindowBackgroundColor,
  602. "ComboBox.foreground", WindowTextColor,
  603. "ComboBox.buttonBackground", ControlBackgroundColor,
  604. "ComboBox.buttonShadow", ControlShadowColor,
  605. "ComboBox.buttonDarkShadow", ControlDarkShadowColor,
  606. "ComboBox.buttonHighlight", ControlHighlightColor,
  607. "ComboBox.selectionBackground", SelectionBackgroundColor,
  608. "ComboBox.selectionForeground", SelectionTextColor,
  609. "ComboBox.disabledBackground", ControlBackgroundColor,
  610. "ComboBox.disabledForeground", InactiveTextColor,
  611. "ComboBox.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[] {
  612. "ESCAPE", "hidePopup",
  613. "PAGE_UP", "pageUpPassThrough",
  614. "PAGE_DOWN", "pageDownPassThrough",
  615. "HOME", "homePassThrough",
  616. "END", "endPassThrough",
  617. "DOWN", "selectNext2",
  618. "KP_DOWN", "selectNext2",
  619. "UP", "selectPrevious2",
  620. "KP_UP", "selectPrevious2",
  621. "ENTER", "enterPressed",
  622. "F4", "togglePopup"
  623. }),
  624. // DeskTop.
  625. "Desktop.background", new DesktopProperty(
  626. "win.desktop.backgroundColor",
  627. table.get("desktop"),
  628. toolkit),
  629. "Desktop.ancestorInputMap",
  630. new UIDefaults.LazyInputMap(new Object[] {
  631. "ctrl F5", "restore",
  632. "ctrl F4", "close",
  633. "ctrl F7", "move",
  634. "ctrl F8", "resize",
  635. "RIGHT", "right",
  636. "KP_RIGHT", "right",
  637. "LEFT", "left",
  638. "KP_LEFT", "left",
  639. "UP", "up",
  640. "KP_UP", "up",
  641. "DOWN", "down",
  642. "KP_DOWN", "down",
  643. "ESCAPE", "escape",
  644. "ctrl F9", "minimize",
  645. "ctrl F10", "maximize",
  646. "ctrl F6", "selectNextFrame",
  647. "ctrl TAB", "selectNextFrame",
  648. "ctrl alt F6", "selectNextFrame",
  649. "shift ctrl alt F6", "selectPreviousFrame",
  650. "ctrl F12", "navigateNext",
  651. "shift ctrl F12", "navigatePrevious"
  652. }),
  653. // DesktopIcon
  654. "DesktopIcon.width", new Integer(160),
  655. "EditorPane.font", ControlFont,
  656. "EditorPane.background", WindowBackgroundColor,
  657. "EditorPane.foreground", WindowTextColor,
  658. "EditorPane.selectionBackground", SelectionBackgroundColor,
  659. "EditorPane.selectionForeground", SelectionTextColor,
  660. "EditorPane.caretForeground", WindowTextColor,
  661. "EditorPane.inactiveForeground", InactiveTextColor,
  662. "FileChooser.homeFolderIcon", new LazyWindowsIcon(null,
  663. "icons/HomeFolder.gif"),
  664. "FileChooser.listFont", IconFont,
  665. "FileChooser.listViewBackground", new XPColorValue("listview.fillcolor",
  666. WindowBackgroundColor),
  667. "FileChooser.listViewBorder", new XPBorderValue("listview",
  668. new SwingLazyValue(
  669. "javax.swing.plaf.BorderUIResource",
  670. "getLoweredBevelBorderUIResource")),
  671. "FileChooser.listViewIcon", new LazyWindowsIcon("fileChooserIcon ListView",
  672. "icons/ListView.gif"),
  673. "FileChooser.listViewWindowsStyle", Boolean.TRUE,
  674. "FileChooser.detailsViewIcon", new LazyWindowsIcon("fileChooserIcon DetailsView",
  675. "icons/DetailsView.gif"),
  676. "FileChooser.upFolderIcon", new LazyWindowsIcon("fileChooserIcon UpFolder",
  677. "icons/UpFolder.gif"),
  678. "FileChooser.newFolderIcon", new LazyWindowsIcon("fileChooserIcon NewFolder",
  679. "icons/NewFolder.gif"),
  680. "FileChooser.useSystemExtensionHiding", Boolean.TRUE,
  681. "FileChooser.lookInLabelMnemonic", new Integer(KeyEvent.VK_I),
  682. "FileChooser.fileNameLabelMnemonic", new Integer(KeyEvent.VK_N),
  683. "FileChooser.filesOfTypeLabelMnemonic", new Integer(KeyEvent.VK_T),
  684. "FileChooser.usesSingleFilePane", Boolean.TRUE,
  685. "FileChooser.ancestorInputMap",
  686. new UIDefaults.LazyInputMap(new Object[] {
  687. "ESCAPE", "cancelSelection",
  688. "F2", "editFileName",
  689. "F5", "refresh",
  690. "BACK_SPACE", "Go Up",
  691. "ENTER", "approveSelection"
  692. }),
  693. "FileView.directoryIcon", LookAndFeel.makeIcon(getClass(), "icons/Directory.gif"),
  694. "FileView.fileIcon", LookAndFeel.makeIcon(getClass(), "icons/File.gif"),
  695. "FileView.computerIcon", LookAndFeel.makeIcon(getClass(), "icons/Computer.gif"),
  696. "FileView.hardDriveIcon", LookAndFeel.makeIcon(getClass(), "icons/HardDrive.gif"),
  697. "FileView.floppyDriveIcon", LookAndFeel.makeIcon(getClass(), "icons/FloppyDrive.gif"),
  698. "InternalFrame.titleFont", WindowFont,
  699. "InternalFrame.titlePaneHeight", TitlePaneHeight,
  700. "InternalFrame.titleButtonWidth", TitleButtonWidth,
  701. "InternalFrame.titleButtonHeight", TitleButtonHeight,
  702. "InternalFrame.borderColor", ControlBackgroundColor,
  703. "InternalFrame.borderShadow", ControlShadowColor,
  704. "InternalFrame.borderDarkShadow", ControlDarkShadowColor,
  705. "InternalFrame.borderHighlight", ControlHighlightColor,
  706. "InternalFrame.borderLight", ControlLightColor,
  707. "InternalFrame.borderWidth", WindowBorderWidth,
  708. "InternalFrame.minimizeIconBackground", ControlBackgroundColor,
  709. "InternalFrame.resizeIconHighlight", ControlLightColor,
  710. "InternalFrame.resizeIconShadow", ControlShadowColor,
  711. "InternalFrame.activeBorderColor", new DesktopProperty(
  712. "win.frame.activeBorderColor",
  713. table.get("windowBorder"),
  714. toolkit),
  715. "InternalFrame.inactiveBorderColor", new DesktopProperty(
  716. "win.frame.inactiveBorderColor",
  717. table.get("windowBorder"),
  718. toolkit),
  719. "InternalFrame.activeTitleBackground", new DesktopProperty(
  720. "win.frame.activeCaptionColor",
  721. table.get("activeCaption"),
  722. toolkit),
  723. "InternalFrame.activeTitleGradient", new DesktopProperty(
  724. "win.frame.activeCaptionGradientColor",
  725. table.get("activeCaption"),
  726. toolkit),
  727. "InternalFrame.activeTitleForeground", new DesktopProperty(
  728. "win.frame.captionTextColor",
  729. table.get("activeCaptionText"),
  730. toolkit),
  731. "InternalFrame.inactiveTitleBackground", new DesktopProperty(
  732. "win.frame.inactiveCaptionColor",
  733. table.get("inactiveCaption"),
  734. toolkit),
  735. "InternalFrame.inactiveTitleGradient", new DesktopProperty(
  736. "win.frame.inactiveCaptionGradientColor",
  737. table.get("inactiveCaption"),
  738. toolkit),
  739. "InternalFrame.inactiveTitleForeground", new DesktopProperty(
  740. "win.frame.inactiveCaptionTextColor",
  741. table.get("inactiveCaptionText"),
  742. toolkit),
  743. "InternalFrame.maximizeIcon",
  744. WindowsIconFactory.createFrameMaximizeIcon(),
  745. "InternalFrame.minimizeIcon",
  746. WindowsIconFactory.createFrameMinimizeIcon(),
  747. "InternalFrame.iconifyIcon",
  748. WindowsIconFactory.createFrameIconifyIcon(),
  749. "InternalFrame.closeIcon",
  750. WindowsIconFactory.createFrameCloseIcon(),
  751. "InternalFrame.icon",
  752. new SwingLazyValue(
  753. "com.sun.java.swing.plaf.windows.WindowsInternalFrameTitlePane$ScalableIconUIResource",
  754. // The constructor takes one arg: an array of UIDefaults.LazyValue
  755. // representing the icons
  756. new Object[][] { {
  757. LookAndFeel.makeIcon(BasicLookAndFeel.class, "icons/JavaCup16.png"),
  758. LookAndFeel.makeIcon(getClass(), "icons/JavaCup32.png")
  759. } }),
  760. // Internal Frame Auditory Cue Mappings
  761. "InternalFrame.closeSound", "win.sound.close",
  762. "InternalFrame.maximizeSound", "win.sound.maximize",
  763. "InternalFrame.minimizeSound", "win.sound.minimize",
  764. "InternalFrame.restoreDownSound", "win.sound.restoreDown",
  765. "InternalFrame.restoreUpSound", "win.sound.restoreUp",
  766. "InternalFrame.windowBindings", new Object[] {
  767. "shift ESCAPE", "showSystemMenu",
  768. "ctrl SPACE", "showSystemMenu",
  769. "ESCAPE", "hideSystemMenu"},
  770. // Label
  771. "Label.font", ControlFont,
  772. "Label.background", ControlBackgroundColor,
  773. "Label.foreground", ControlTextColor,
  774. "Label.disabledForeground", InactiveTextColor,
  775. "Label.disabledShadow", ControlHighlightColor,
  776. // List.
  777. "List.font", ControlFont,
  778. "List.background", WindowBackgroundColor,
  779. "List.foreground", WindowTextColor,
  780. "List.selectionBackground", SelectionBackgroundColor,
  781. "List.selectionForeground", SelectionTextColor,
  782. "List.lockToPositionOnScroll", Boolean.TRUE,
  783. "List.focusInputMap",
  784. new UIDefaults.LazyInputMap(new Object[] {
  785. "ctrl C", "copy",
  786. "ctrl V", "paste",
  787. "ctrl X", "cut",
  788. "COPY", "copy",
  789. "PASTE", "paste",
  790. "CUT", "cut",
  791. "UP", "selectPreviousRow",
  792. "KP_UP", "selectPreviousRow",
  793. "shift UP", "selectPreviousRowExtendSelection",
  794. "shift KP_UP", "selectPreviousRowExtendSelection",
  795. "ctrl shift UP", "selectPreviousRowExtendSelection",
  796. "ctrl shift KP_UP", "selectPreviousRowExtendSelection",
  797. "ctrl UP", "selectPreviousRowChangeLead",
  798. "ctrl KP_UP", "selectPreviousRowChangeLead",
  799. "DOWN", "selectNextRow",
  800. "KP_DOWN", "selectNextRow",
  801. "shift DOWN", "selectNextRowExtendSelection",
  802. "shift KP_DOWN", "selectNextRowExtendSelection",
  803. "ctrl shift DOWN", "selectNextRowExtendSelection",
  804. "ctrl shift KP_DOWN", "selectNextRowExtendSelection",
  805. "ctrl DOWN", "selectNextRowChangeLead",
  806. "ctrl KP_DOWN", "selectNextRowChangeLead",
  807. "LEFT", "selectPreviousColumn",
  808. "KP_LEFT", "selectPreviousColumn",
  809. "shift LEFT", "selectPreviousColumnExtendSelection",
  810. "shift KP_LEFT", "selectPreviousColumnExtendSelection",
  811. "ctrl shift LEFT", "selectPreviousColumnExtendSelection",
  812. "ctrl shift KP_LEFT", "selectPreviousColumnExtendSelection",
  813. "ctrl LEFT", "selectPreviousColumnChangeLead",
  814. "ctrl KP_LEFT", "selectPreviousColumnChangeLead",
  815. "RIGHT", "selectNextColumn",
  816. "KP_RIGHT", "selectNextColumn",
  817. "shift RIGHT", "selectNextColumnExtendSelection",
  818. "shift KP_RIGHT", "selectNextColumnExtendSelection",
  819. "ctrl shift RIGHT", "selectNextColumnExtendSelection",
  820. "ctrl shift KP_RIGHT", "selectNextColumnExtendSelection",
  821. "ctrl RIGHT", "selectNextColumnChangeLead",
  822. "ctrl KP_RIGHT", "selectNextColumnChangeLead",
  823. "HOME", "selectFirstRow",
  824. "shift HOME", "selectFirstRowExtendSelection",
  825. "ctrl shift HOME", "selectFirstRowExtendSelection",
  826. "ctrl HOME", "selectFirstRowChangeLead",
  827. "END", "selectLastRow",
  828. "shift END", "selectLastRowExtendSelection",
  829. "ctrl shift END", "selectLastRowExtendSelection",
  830. "ctrl END", "selectLastRowChangeLead",
  831. "PAGE_UP", "scrollUp",
  832. "shift PAGE_UP", "scrollUpExtendSelection",
  833. "ctrl shift PAGE_UP", "scrollUpExtendSelection",
  834. "ctrl PAGE_UP", "scrollUpChangeLead",
  835. "PAGE_DOWN", "scrollDown",
  836. "shift PAGE_DOWN", "scrollDownExtendSelection",
  837. "ctrl shift PAGE_DOWN", "scrollDownExtendSelection",
  838. "ctrl PAGE_DOWN", "scrollDownChangeLead",
  839. "ctrl A", "selectAll",
  840. "ctrl SLASH", "selectAll",
  841. "ctrl BACK_SLASH", "clearSelection",
  842. "SPACE", "addToSelection",
  843. "ctrl SPACE", "toggleAndAnchor",
  844. "shift SPACE", "extendTo",
  845. "ctrl shift SPACE", "moveSelectionTo"
  846. }),
  847. // PopupMenu
  848. "PopupMenu.font", MenuFont,
  849. "PopupMenu.background", MenuBackgroundColor,
  850. "PopupMenu.foreground", MenuTextColor,
  851. "PopupMenu.popupSound", "win.sound.menuPopup",
  852. // Menus
  853. "Menu.font", MenuFont,
  854. "Menu.foreground", MenuTextColor,
  855. "Menu.background", MenuBackgroundColor,
  856. "Menu.useMenuBarBackgroundForTopLevel", Boolean.TRUE,
  857. "Menu.selectionForeground", SelectionTextColor,
  858. "Menu.selectionBackground", SelectionBackgroundColor,
  859. "Menu.acceleratorForeground", MenuTextColor,
  860. "Menu.acceleratorSelectionForeground", SelectionTextColor,
  861. "Menu.menuPopupOffsetX", new Integer(0),
  862. "Menu.menuPopupOffsetY", new Integer(0),
  863. "Menu.submenuPopupOffsetX", new Integer(-4),
  864. "Menu.submenuPopupOffsetY", new Integer(-3),
  865. "Menu.crossMenuMnemonic", Boolean.FALSE,
  866. // MenuBar.
  867. "MenuBar.font", MenuFont,
  868. "MenuBar.background", new XPValue(MenuBarBackgroundColor,
  869. MenuBackgroundColor),
  870. "MenuBar.foreground", MenuTextColor,
  871. "MenuBar.shadow", ControlShadowColor,
  872. "MenuBar.highlight", ControlHighlightColor,
  873. "MenuBar.windowBindings", new Object[] {
  874. "F10", "takeFocus" },
  875. "MenuItem.font", MenuFont,
  876. "MenuItem.acceleratorFont", MenuFont,
  877. "MenuItem.foreground", MenuTextColor,
  878. "MenuItem.background", MenuBackgroundColor,
  879. "MenuItem.selectionForeground", SelectionTextColor,
  880. "MenuItem.selectionBackground", SelectionBackgroundColor,
  881. "MenuItem.disabledForeground", InactiveTextColor,
  882. "MenuItem.acceleratorForeground", MenuTextColor,
  883. "MenuItem.acceleratorSelectionForeground", SelectionTextColor,
  884. "MenuItem.acceleratorDelimiter", menuItemAcceleratorDelimiter,
  885. // Menu Item Auditory Cue Mapping
  886. "MenuItem.commandSound", "win.sound.menuCommand",
  887. "RadioButton.font", ControlFont,
  888. "RadioButton.interiorBackground", WindowBackgroundColor,
  889. "RadioButton.background", ControlBackgroundColor,
  890. "RadioButton.foreground", ControlTextColor,
  891. "RadioButton.shadow", ControlShadowColor,
  892. "RadioButton.darkShadow", ControlDarkShadowColor,
  893. "RadioButton.light", ControlLightColor,
  894. "RadioButton.highlight", ControlHighlightColor,
  895. "RadioButton.focus", black,
  896. "RadioButton.focusInputMap",
  897. new UIDefaults.LazyInputMap(new Object[] {
  898. "SPACE", "pressed",
  899. "released SPACE", "released"
  900. }),
  901. "RadioButtonMenuItem.font", MenuFont,
  902. "RadioButtonMenuItem.foreground", MenuTextColor,
  903. "RadioButtonMenuItem.background", MenuBackgroundColor,
  904. "RadioButtonMenuItem.selectionForeground", SelectionTextColor,
  905. "RadioButtonMenuItem.selectionBackground", SelectionBackgroundColor,
  906. "RadioButtonMenuItem.disabledForeground", InactiveTextColor,
  907. "RadioButtonMenuItem.acceleratorForeground", MenuTextColor,
  908. "RadioButtonMenuItem.acceleratorSelectionForeground", SelectionTextColor,
  909. "RadioButtonMenuItem.commandSound", "win.sound.menuCommand",
  910. // OptionPane.
  911. "OptionPane.font", MessageFont,
  912. "OptionPane.messageFont", MessageFont,
  913. "OptionPane.buttonFont", MessageFont,
  914. "OptionPane.background", ControlBackgroundColor,
  915. "OptionPane.foreground", ControlTextColor,
  916. "OptionPane.messageForeground", ControlTextColor,
  917. "OptionPane.errorIcon", new LazyWindowsIcon("optionPaneIcon Error",
  918. "icons/Error.gif"),
  919. "OptionPane.informationIcon", new LazyWindowsIcon("optionPaneIcon Information",
  920. "icons/Inform.gif"),
  921. "OptionPane.questionIcon", new LazyWindowsIcon("optionPaneIcon Question",
  922. "icons/Question.gif"),
  923. "OptionPane.warningIcon", new LazyWindowsIcon("optionPaneIcon Warning",
  924. "icons/Warn.gif"),
  925. "OptionPane.windowBindings", new Object[] {
  926. "ESCAPE", "close" },
  927. // Option Pane Auditory Cue Mappings
  928. "OptionPane.errorSound", "win.sound.hand", // Error
  929. "OptionPane.informationSound", "win.sound.asterisk", // Info Plain
  930. "OptionPane.questionSound", "win.sound.question", // Question
  931. "OptionPane.warningSound", "win.sound.exclamation", // Warning
  932. "FormattedTextField.focusInputMap",
  933. new UIDefaults.LazyInputMap(new Object[] {
  934. "ctrl C", DefaultEditorKit.copyAction,
  935. "ctrl V", DefaultEditorKit.pasteAction,
  936. "ctrl X", DefaultEditorKit.cutAction,
  937. "COPY", DefaultEditorKit.copyAction,
  938. "PASTE", DefaultEditorKit.pasteAction,
  939. "CUT", DefaultEditorKit.cutAction,
  940. "shift LEFT", DefaultEditorKit.selectionBackwardAction,
  941. "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction,
  942. "shift RIGHT", DefaultEditorKit.selectionForwardAction,
  943. "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction,
  944. "ctrl LEFT", DefaultEditorKit.previousWordAction,
  945. "ctrl KP_LEFT", DefaultEditorKit.previousWordAction,
  946. "ctrl RIGHT", DefaultEditorKit.nextWordAction,
  947. "ctrl KP_RIGHT", DefaultEditorKit.nextWordAction,
  948. "ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
  949. "ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction,
  950. "ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction,
  951. "ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction,
  952. "ctrl A", DefaultEditorKit.selectAllAction,
  953. "HOME", DefaultEditorKit.beginLineAction,
  954. "END", DefaultEditorKit.endLineAction,
  955. "shift HOME", DefaultEditorKit.selectionBeginLineAction,
  956. "shift END", DefaultEditorKit.selectionEndLineAction,
  957. "BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
  958. "ctrl H", DefaultEditorKit.deletePrevCharAction,
  959. "DELETE", DefaultEditorKit.deleteNextCharAction,
  960. "RIGHT", DefaultEditorKit.forwardAction,
  961. "LEFT", DefaultEditorKit.backwardAction,
  962. "KP_RIGHT", DefaultEditorKit.forwardAction,
  963. "KP_LEFT", DefaultEditorKit.backwardAction,
  964. "ENTER", JTextField.notifyAction,
  965. "ctrl BACK_SLASH", "unselect",
  966. "control shift O", "toggle-componentOrientation",
  967. "ESCAPE", "reset-field-edit",
  968. "UP", "increment",
  969. "KP_UP", "increment",
  970. "DOWN", "decrement",
  971. "KP_DOWN", "decrement",
  972. }),
  973. // *** Panel
  974. "Panel.font", ControlFont,
  975. "Panel.background", ControlBackgroundColor,
  976. "Panel.foreground", WindowTextColor,
  977. // *** PasswordField
  978. "PasswordField.font", FixedControlFont,
  979. "PasswordField.background", TextBackground,
  980. "PasswordField.foreground", WindowTextColor,
  981. "PasswordField.inactiveForeground", InactiveTextColor, // for disabled
  982. "PasswordField.inactiveBackground", ReadOnlyTextBackground, // for readonly
  983. "PasswordField.disabledBackground", DisabledTextBackground, // for disabled
  984. "PasswordField.selectionBackground", SelectionBackgroundColor,
  985. "PasswordField.selectionForeground", SelectionTextColor,
  986. "PasswordField.caretForeground",WindowTextColor,
  987. // *** ProgressBar
  988. "ProgressBar.font", ControlFont,
  989. "ProgressBar.foreground", SelectionBackgroundColor,
  990. "ProgressBar.background", ControlBackgroundColor,
  991. "ProgressBar.shadow", ControlShadowColor,
  992. "ProgressBar.highlight", ControlHighlightColor,
  993. "ProgressBar.selectionForeground", ControlBackgroundColor,
  994. "ProgressBar.selectionBackground", SelectionBackgroundColor,
  995. "ProgressBar.cellLength", new Integer(7),
  996. "ProgressBar.cellSpacing", new Integer(2),
  997. // *** RootPane.
  998. // These bindings are only enabled when there is a default
  999. // button set on the rootpane.
  1000. "RootPane.defaultButtonWindowKeyBindings", new Object[] {
  1001. "ENTER", "press",
  1002. "released ENTER", "release",
  1003. "ctrl ENTER", "press",
  1004. "ctrl released ENTER", "release"
  1005. },
  1006. // *** ScrollBar.
  1007. "ScrollBar.background", ScrollbarBackgroundColor,
  1008. "ScrollBar.foreground", ControlBackgroundColor,
  1009. "ScrollBar.track", white,
  1010. "ScrollBar.trackForeground", ScrollbarBackgroundColor,
  1011. "ScrollBar.trackHighlight", black,
  1012. "ScrollBar.trackHighlightForeground", scrollBarTrackHighlight,
  1013. "ScrollBar.thumb", ControlBackgroundColor,
  1014. "ScrollBar.thumbHighlight", ControlHighlightColor,
  1015. "ScrollBar.thumbDarkShadow", ControlDarkShadowColor,
  1016. "ScrollBar.thumbShadow", ControlShadowColor,
  1017. "ScrollBar.width", scrollBarWidth,
  1018. "ScrollBar.ancestorInputMap",
  1019. new UIDefaults.LazyInputMap(new Object[] {
  1020. "RIGHT", "positiveUnitIncrement",
  1021. "KP_RIGHT", "positiveUnitIncrement",
  1022. "DOWN", "positiveUnitIncrement",
  1023. "KP_DOWN", "positiveUnitIncrement",
  1024. "PAGE_DOWN", "positiveBlockIncrement",
  1025. "ctrl PAGE_DOWN", "positiveBlockIncrement",
  1026. "LEFT", "negativeUnitIncrement",
  1027. "KP_LEFT", "negativeUnitIncrement",
  1028. "UP", "negativeUnitIncrement",
  1029. "KP_UP", "negativeUnitIncrement",
  1030. "PAGE_UP", "negativeBlockIncrement",
  1031. "ctrl PAGE_UP", "negativeBlockIncrement",
  1032. "HOME", "minScroll",
  1033. "END", "maxScroll"
  1034. }),
  1035. // *** ScrollPane.
  1036. "ScrollPane.font", ControlFont,
  1037. "ScrollPane.background", ControlBackgroundColor,
  1038. "ScrollPane.foreground", ControlTextColor,
  1039. "ScrollPane.ancestorInputMap",
  1040. new UIDefaults.LazyInputMap(new Object[] {
  1041. "RIGHT", "unitScrollRight",
  1042. "KP_RIGHT", "unitScrollRight",
  1043. "DOWN", "unitScrollDown",
  1044. "KP_DOWN", "unitScrollDown",
  1045. "LEFT", "unitScrollLeft",
  1046. "KP_LEFT", "unitScrollLeft",
  1047. "UP", "unitScrollUp",
  1048. "KP_UP", "unitScrollUp",
  1049. "PAGE_UP", "scrollUp",
  1050. "PAGE_DOWN", "scrollDown",
  1051. "ctrl PAGE_UP", "scrollLeft",
  1052. "ctrl PAGE_DOWN", "scrollRight",
  1053. "ctrl HOME", "scrollHome",
  1054. "ctrl END", "scrollEnd"
  1055. }),
  1056. // *** Separator
  1057. "Separator.background", ControlHighlightColor,
  1058. "Separator.foreground", ControlShadowColor,
  1059. // *** Slider.
  1060. "Slider.foreground", ControlBackgroundColor,
  1061. "Slider.background", ControlBackgroundColor,
  1062. "Slider.highlight", ControlHighlightColor,
  1063. "Slider.shadow", ControlShadowColor,
  1064. "Slider.focus", ControlDarkShadowColor,
  1065. "Slider.focusInputMap",
  1066. new UIDefaults.LazyInputMap(new Object[] {
  1067. "RIGHT", "positiveUnitIncrement",
  1068. "KP_RIGHT", "positiveUnitIncrement",
  1069. "DOWN", "negativeUnitIncrement",
  1070. "KP_DOWN", "negativeUnitIncrement",
  1071. "PAGE_DOWN", "negativeBlockIncrement",
  1072. "LEFT", "negativeUnitIncrement",
  1073. "KP_LEFT", "negativeUnitIncrement",
  1074. "UP", "positiveUnitIncrement",
  1075. "KP_UP", "positiveUnitIncrement",
  1076. "PAGE_UP", "positiveBlockIncrement",
  1077. "HOME", "minScroll",
  1078. "END", "maxScroll"
  1079. }),
  1080. // Spinner
  1081. "Spinner.font", FixedControlFont,
  1082. "Spinner.ancestorInputMap",
  1083. new UIDefaults.LazyInputMap(new Object[] {
  1084. "UP", "increment",
  1085. "KP_UP", "increment",
  1086. "DOWN", "decrement",
  1087. "KP_DOWN", "decrement",
  1088. }),
  1089. // *** SplitPane
  1090. "SplitPane.background", ControlBackgroundColor,
  1091. "SplitPane.highlight", ControlHighlightColor,
  1092. "SplitPane.shadow", ControlShadowColor,
  1093. "SplitPane.darkShadow", ControlDarkShadowColor,
  1094. "SplitPane.dividerSize", new Integer(5),
  1095. "SplitPane.ancestorInputMap",
  1096. new UIDefaults.LazyInputMap(new Object[] {
  1097. "UP", "negativeIncrement",
  1098. "DOWN", "positiveIncrement",
  1099. "LEFT", "negativeIncrement",
  1100. "RIGHT", "positiveIncrement",
  1101. "KP_UP", "negativeIncrement",
  1102. "KP_DOWN", "positiveIncrement",
  1103. "KP_LEFT", "negativeIncrement",
  1104. "KP_RIGHT", "positiveIncrement",
  1105. "HOME", "selectMin",
  1106. "END", "selectMax",
  1107. "F8", "startResize",
  1108. "F6", "toggleFocus",
  1109. "ctrl TAB", "focusOutForward",
  1110. "ctrl shift TAB", "focusOutBackward"
  1111. }),
  1112. // *** TabbedPane
  1113. "TabbedPane.tabsOverlapBorder", new XPValue(Boolean.TRUE, Boolean.FALSE),
  1114. "TabbedPane.tabInsets", new XPValue(new InsetsUIResource(1, 4, 1, 4),
  1115. new InsetsUIResource(0, 4, 1, 4)),
  1116. "TabbedPane.tabAreaInsets", new XPValue(new InsetsUIResource(3, 2, 2, 2),
  1117. new InsetsUIResource(3, 2, 0, 2)),
  1118. "TabbedPane.font", ControlFont,
  1119. "TabbedPane.background", ControlBackgroundColor,
  1120. "TabbedPane.foreground", ControlTextColor,
  1121. "TabbedPane.highlight", ControlHighlightColor,
  1122. "TabbedPane.light", ControlLightColor,
  1123. "TabbedPane.shadow", ControlShadowColor,
  1124. "TabbedPane.darkShadow", ControlDarkShadowColor,
  1125. "TabbedPane.focus", ControlTextColor,
  1126. "TabbedPane.focusInputMap",
  1127. new UIDefaults.LazyInputMap(new Object[] {
  1128. "RIGHT", "navigateRight",
  1129. "KP_RIGHT", "navigateRight",
  1130. "LEFT", "navigateLeft",
  1131. "KP_LEFT", "navigateLeft",
  1132. "UP", "navigateUp",
  1133. "KP_UP", "navigateUp",
  1134. "DOWN", "navigateDown",
  1135. "KP_DOWN", "navigateDown",
  1136. "ctrl DOWN", "requestFocusForVisibleComponent",
  1137. "ctrl KP_DOWN", "requestFocusForVisibleComponent",
  1138. }),
  1139. "TabbedPane.ancestorInputMap",
  1140. new UIDefaults.LazyInputMap(new Object[] {
  1141. "ctrl TAB", "navigateNext",
  1142. "ctrl shift TAB", "navigatePrevious",
  1143. "ctrl PAGE_DOWN", "navigatePageDown",
  1144. "ctrl PAGE_UP", "navigatePageUp",
  1145. "ctrl UP", "requestFocus",
  1146. "ctrl KP_UP", "requestFocus",
  1147. }),
  1148. // *** Table
  1149. "Table.font", ControlFont,
  1150. "Table.foreground", ControlTextColor, // cell text color
  1151. "Table.background", WindowBackgroundColor, // cell background color
  1152. "Table.highlight", ControlHighlightColor,
  1153. "Table.light", ControlLightColor,
  1154. "Table.shadow", ControlShadowColor,
  1155. "Table.darkShadow", ControlDarkShadowColor,
  1156. "Table.selectionForeground", SelectionTextColor,
  1157. "Table.selectionBackground", SelectionBackgroundColor,
  1158. "Table.gridColor", gray, // grid line color
  1159. "Table.focusCellBackground", WindowBackgroundColor,
  1160. "Table.focusCellForeground", ControlTextColor,
  1161. "Table.ancestorInputMap",
  1162. new UIDefaults.LazyInputMap(new Object[] {
  1163. "ctrl C", "copy",
  1164. "ctrl V", "paste",
  1165. "ctrl X", "cut",
  1166. "COPY", "copy",
  1167. "PASTE", "paste",
  1168. "CUT", "cut",
  1169. "RIGHT", "selectNextColumn",
  1170. "KP_RIGHT", "selectNextColumn",
  1171. "shift RIGHT", "selectNextColumnExtendSelection",
  1172. "shift KP_RIGHT", "selectNextColumnExtendSelection",
  1173. "ctrl shift RIGHT", "selectNextColumnExtendSelection",
  1174. "ctrl shift KP_RIGHT", "selectNextColumnExtendSelection",
  1175. "ctrl RIGHT", "selectNextColumnChangeLead",
  1176. "ctrl KP_RIGHT", "selectNextColumnChangeLead",
  1177. "LEFT", "selectPreviousColumn",
  1178. "KP_LEFT", "selectPreviousColumn",
  1179. "shift LEFT", "selectPreviousColumnExtendSelection",
  1180. "shift KP_LEFT", "selectPreviousColumnExtendSelection",
  1181. "ctrl shift LEFT", "selectPreviousColumnExtendSelection",
  1182. "ctrl shift KP_LEFT", "selectPreviousColumnExtendSelection",
  1183. "ctrl LEFT", "selectPreviousColumnChangeLead",
  1184. "ctrl KP_LEFT", "selectPreviousColumnChangeLead",
  1185. "DOWN", "selectNextRow",
  1186. "KP_DOWN", "selectNextRow",
  1187. "shift DOWN", "selectNextRowExtendSelection",
  1188. "shift KP_DOWN", "selectNextRowExtendSelection",
  1189. "ctrl shift DOWN", "selectNextRowExtendSelection",
  1190. "ctrl shift KP_DOWN", "selectNextRowExtendSelection",
  1191. "ctrl DOWN", "selectNextRowChangeLead",
  1192. "ctrl KP_DOWN", "selectNextRowChangeLead",
  1193. "UP", "selectPreviousRow",
  1194. "KP_UP", "selectPreviousRow",
  1195. "shift UP", "selectPreviousRowExtendSelection",
  1196. "shift KP_UP", "selectPreviousRowExtendSelection",
  1197. "ctrl shift UP", "selectPreviousRowExtendSelection",
  1198. "ctrl shift KP_UP", "selectPreviousRowExtendSelection",
  1199. "ctrl UP", "selectPreviousRowChangeLead",
  1200. "ctrl KP_UP", "selectPreviousRowChangeLead",
  1201. "HOME", "selectFirstColumn",
  1202. "shift HOME", "selectFirstColumnExtendSelection",
  1203. "ctrl shift HOME", "selectFirstRowExtendSelection",
  1204. "ctrl HOME", "selectFirstRow",
  1205. "END", "selectLastColumn",
  1206. "shift END", "selectLastColumnExtendSelection",
  1207. "ctrl shift END", "selectLastRowExtendSelection",
  1208. "ctrl END", "selectLastRow",
  1209. "PAGE_UP", "scrollUpChangeSelection",
  1210. "shift PAGE_UP", "scrollUpExtendSelection",
  1211. "ctrl shift PAGE_UP", "scrollLeftExtendSelection",
  1212. "ctrl PAGE_UP", "scrollLeftChangeSelection",
  1213. "PAGE_DOWN", "scrollDownChangeSelection",
  1214. "shift PAGE_DOWN", "scrollDownExtendSelection",
  1215. "ctrl shift PAGE_DOWN", "scrollRightExtendSelection",
  1216. "ctrl PAGE_DOWN", "scrollRightChangeSelection",
  1217. "TAB", "selectNextColumnCell",
  1218. "shift TAB", "selectPreviousColumnCell",
  1219. "ENTER", "selectNextRowCell",
  1220. "shift ENTER", "selectPreviousRowCell",
  1221. "ctrl A", "selectAll",
  1222. "ctrl SLASH", "selectAll",
  1223. "ctrl BACK_SLASH", "clearSelection",
  1224. "ESCAPE", "cancel",
  1225. "F2", "startEditing",
  1226. "SPACE", "addToSelection",
  1227. "ctrl SPACE", "toggleAndAnchor",
  1228. "shift SPACE", "extendTo",
  1229. "ctrl shift SPACE", "moveSelectionTo"
  1230. }),
  1231. "TableHeader.font", ControlFont,
  1232. "TableHeader.foreground", ControlTextColor, // header text color
  1233. "TableHeader.background", ControlBackgroundColor, // header background
  1234. // *** TextArea
  1235. "TextArea.font", FixedControlFont,
  1236. "TextArea.background", WindowBackgroundColor,
  1237. "TextArea.foreground", WindowTextColor,
  1238. "TextArea.inactiveForeground", InactiveTextColor,
  1239. "TextArea.selectionBackground", SelectionBackgroundColor,
  1240. "TextArea.selectionForeground", SelectionTextColor,
  1241. "TextArea.caretForeground", WindowTextColor,
  1242. // *** TextField
  1243. "TextField.font", ControlFont,
  1244. "TextField.background", TextBackground,
  1245. "TextField.foreground", WindowTextColor,
  1246. "TextField.shadow", ControlShadowColor,
  1247. "TextField.darkShadow", ControlDarkShadowColor,
  1248. "TextField.light", ControlLightColor,
  1249. "TextField.highlight", ControlHighlightColor,
  1250. "TextField.inactiveForeground", InactiveTextColor, // for disabled
  1251. "TextField.inactiveBackground", ReadOnlyTextBackground, // for readonly
  1252. "TextField.disabledBackground", DisabledTextBackground, // for disabled
  1253. "TextField.selectionBackground", SelectionBackgroundColor,
  1254. "TextField.selectionForeground", SelectionTextColor,
  1255. "TextField.caretForeground", WindowTextColor,
  1256. // *** TextPane
  1257. "TextPane.font", ControlFont,
  1258. "TextPane.background", WindowBackgroundColor,
  1259. "TextPane.foreground", WindowTextColor,
  1260. "TextPane.selectionBackground", SelectionBackgroundColor,
  1261. "TextPane.selectionForeground", SelectionTextColor,
  1262. "TextPane.caretForeground", WindowTextColor,
  1263. // *** TitledBorder
  1264. "TitledBorder.font", ControlFont,
  1265. "TitledBorder.titleColor",
  1266. new XPColorValue("button.groupbox.textcolor",
  1267. ControlTextColor),
  1268. // *** ToggleButton
  1269. "ToggleButton.font", ControlFont,
  1270. "ToggleButton.background", ControlBackgroundColor,
  1271. "ToggleButton.foreground", ControlTextColor,
  1272. "ToggleButton.shadow", ControlShadowColor,
  1273. "ToggleButton.darkShadow", ControlDarkShadowColor,
  1274. "ToggleButton.light", ControlLightColor,
  1275. "ToggleButton.highlight", ControlHighlightColor,
  1276. "ToggleButton.focus", ControlTextColor,
  1277. "ToggleButton.textShiftOffset", new Integer(1),
  1278. "ToggleButton.focusInputMap",
  1279. new UIDefaults.LazyInputMap(new Object[] {
  1280. "SPACE", "pressed",
  1281. "released SPACE", "released"
  1282. }),
  1283. // *** ToolBar
  1284. "ToolBar.font", MenuFont,
  1285. "ToolBar.background", ControlBackgroundColor,
  1286. "ToolBar.foreground", ControlTextColor,
  1287. "ToolBar.shadow", ControlShadowColor,
  1288. "ToolBar.darkShadow", ControlDarkShadowColor,
  1289. "ToolBar.light", ControlLightColor,
  1290. "ToolBar.highlight", ControlHighlightColor,
  1291. "ToolBar.dockingBackground", ControlBackgroundColor,
  1292. "ToolBar.dockingForeground", red,
  1293. "ToolBar.floatingBackground", ControlBackgroundColor,
  1294. "ToolBar.floatingForeground", darkGray,
  1295. "ToolBar.ancestorInputMap",
  1296. new UIDefaults.LazyInputMap(new Object[] {
  1297. "UP", "navigateUp",
  1298. "KP_UP", "navigateUp",
  1299. "DOWN", "navigateDown",
  1300. "KP_DOWN", "navigateDown",
  1301. "LEFT", "navigateLeft",
  1302. "KP_LEFT", "navigateLeft",
  1303. "RIGHT", "navigateRight",
  1304. "KP_RIGHT", "navigateRight"
  1305. }),
  1306. "ToolBar.separatorSize", null,
  1307. // *** ToolTip
  1308. "ToolTip.font", ToolTipFont,
  1309. "ToolTip.background", new DesktopProperty(
  1310. "win.tooltip.backgroundColor",
  1311. table.get("info"), toolkit),
  1312. "ToolTip.foreground", new DesktopProperty(
  1313. "win.tooltip.textColor",
  1314. table.get("infoText"), toolkit),
  1315. // *** Tree
  1316. "Tree.selectionBorderColor", black,
  1317. "Tree.drawDashedFocusIndicator", Boolean.TRUE,
  1318. "Tree.lineTypeDashed", Boolean.TRUE,
  1319. "Tree.font", ControlFont,
  1320. "Tree.background", WindowBackgroundColor,
  1321. "Tree.foreground", WindowTextColor,
  1322. "Tree.hash", gray,
  1323. "Tree.textForeground", WindowTextColor,
  1324. "Tree.textBackground", WindowBackgroundColor,
  1325. "Tree.selectionForeground", SelectionTextColor,
  1326. "Tree.selectionBackground", SelectionBackgroundColor,
  1327. "Tree.expandedIcon", treeExpandedIcon,
  1328. "Tree.collapsedIcon", treeCollapsedIcon,
  1329. "Tree.focusInputMap",
  1330. new UIDefaults.LazyInputMap(new Object[] {
  1331. "ADD", "expand",
  1332. "SUBTRACT", "collapse",
  1333. "ctrl C", "copy",
  1334. "ctrl V", "paste",
  1335. "ctrl X", "cut",
  1336. "COPY", "copy",
  1337. "PASTE", "paste",
  1338. "CUT", "cut",
  1339. "UP", "selectPrevious",
  1340. "KP_UP", "selectPrevious",
  1341. "shift UP", "selectPreviousExtendSelection",
  1342. "shift KP_UP", "selectPreviousExtendSelection",
  1343. "ctrl shift UP", "selectPreviousExtendSelection",
  1344. "ctrl shift KP_UP", "selectPreviousExtendSelection",
  1345. "ctrl UP", "selectPreviousChangeLead",
  1346. "ctrl KP_UP", "selectPreviousChangeLead",
  1347. "DOWN", "selectNext",
  1348. "KP_DOWN", "selectNext",
  1349. "shift DOWN", "selectNextExtendSelection",
  1350. "shift KP_DOWN", "selectNextExtendSelection",
  1351. "ctrl shift DOWN", "selectNextExtendSelection",
  1352. "ctrl shift KP_DOWN", "selectNextExtendSelection",
  1353. "ctrl DOWN", "selectNextChangeLead",
  1354. "ctrl KP_DOWN", "selectNextChangeLead",
  1355. "RIGHT", "selectChild",
  1356. "KP_RIGHT", "selectChild",
  1357. "LEFT", "selectParent",
  1358. "KP_LEFT", "selectParent",
  1359. "PAGE_UP", "scrollUpChangeSelection",
  1360. "shift PAGE_UP", "scrollUpExtendSelection",
  1361. "ctrl shift PAGE_UP", "scrollUpExtendSelection",
  1362. "ctrl PAGE_UP", "scrollUpChangeLead",
  1363. "PAGE_DOWN", "scrollDownChangeSelection",
  1364. "shift PAGE_DOWN", "scrollDownExtendSelection",
  1365. "ctrl shift PAGE_DOWN", "scrollDownExtendSelection",
  1366. "ctrl PAGE_DOWN", "scrollDownChangeLead",
  1367. "HOME", "selectFirst",
  1368. "shift HOME", "selectFirstExtendSelection",
  1369. "ctrl shift HOME", "selectFirstExtendSelection",
  1370. "ctrl HOME", "selectFirstChangeLead",
  1371. "END", "selectLast",
  1372. "shift END", "selectLastExtendSelection",
  1373. "ctrl shift END", "selectLastExtendSelection",
  1374. "ctrl END", "selectLastChangeLead",
  1375. "F2", "startEditing",
  1376. "ctrl A", "selectAll",
  1377. "ctrl SLASH", "selectAll",
  1378. "ctrl BACK_SLASH", "clearSelection",
  1379. "ctrl LEFT", "scrollLeft",
  1380. "ctrl KP_LEFT", "scrollLeft",
  1381. "ctrl RIGHT", "scrollRight",
  1382. "ctrl KP_RIGHT", "scrollRight",
  1383. "SPACE", "addToSelection",
  1384. "ctrl SPACE", "toggleAndAnchor",
  1385. "shift SPACE", "extendTo",
  1386. "ctrl shift SPACE", "moveSelectionTo"
  1387. }),
  1388. "Tree.ancestorInputMap",
  1389. new UIDefaults.LazyInputMap(new Object[] {
  1390. "ESCAPE", "cancel"
  1391. }),
  1392. // *** Viewport
  1393. "Viewport.font", ControlFont,
  1394. "Viewport.background", ControlBackgroundColor,
  1395. "Viewport.foreground", WindowTextColor,
  1396. };
  1397. table.putDefaults(defaults);
  1398. table.putDefaults(getLazyValueDefaults());
  1399. }
  1400. /**
  1401. * If we support loading of fonts from the desktop this will return
  1402. * a DesktopProperty representing the font. If the font can't be
  1403. * represented in the current encoding this will return null and
  1404. * turn off the use of system fonts.
  1405. */
  1406. private Object getDesktopFontValue(String fontName, Object backup,
  1407. Toolkit kit) {
  1408. if (useSystemFontSettings) {
  1409. return new WindowsFontProperty(fontName, backup, kit);
  1410. }
  1411. return null;
  1412. }
  1413. // When a desktop property change is detected, these classes must be
  1414. // reinitialized in the defaults table to ensure the classes reference
  1415. // the updated desktop property values (colors mostly)
  1416. //
  1417. private Object[] getLazyValueDefaults() {
  1418. Object buttonBorder =
  1419. new XPBorderValue("button.pushbutton",
  1420. new SwingLazyValue(
  1421. "javax.swing.plaf.basic.BasicBorders",
  1422. "getButtonBorder"));
  1423. Object textFieldBorder =
  1424. new XPBorderValue("edit",
  1425. new SwingLazyValue(
  1426. "javax.swing.plaf.basic.BasicBorders",
  1427. "getTextFieldBorder"));
  1428. Object textFieldMargin =
  1429. new XPValue(new InsetsUIResource(1, 5, 2, 4),
  1430. new InsetsUIResource(1, 1, 1, 1));
  1431. Object spinnerBorder = textFieldBorder;
  1432. Object comboBoxBorder = new XPBorderValue("combobox", textFieldBorder);
  1433. // For focus rectangle for cells and trees.
  1434. Object focusCellHighlightBorder = new SwingLazyValue(
  1435. "com.sun.java.swing.plaf.windows.WindowsBorders",
  1436. "getFocusCellHighlightBorder");
  1437. Object etchedBorder = new SwingLazyValue(
  1438. "javax.swing.plaf.BorderUIResource",
  1439. "getEtchedBorderUIResource");
  1440. Object internalFrameBorder = new SwingLazyValue(
  1441. "com.sun.java.swing.plaf.windows.WindowsBorders",
  1442. "getInternalFrameBorder");
  1443. Object loweredBevelBorder = new SwingLazyValue(
  1444. "javax.swing.plaf.BorderUIResource",
  1445. "getLoweredBevelBorderUIResource");
  1446. Object marginBorder = new SwingLazyValue(
  1447. "javax.swing.plaf.basic.BasicBorders$MarginBorder");
  1448. Object menuBarBorder = new SwingLazyValue(
  1449. "javax.swing.plaf.basic.BasicBorders",
  1450. "getMenuBarBorder");
  1451. Object popupMenuBorder = new XPBorderValue("menu",
  1452. new SwingLazyValue(
  1453. "javax.swing.plaf.basic.BasicBorders",
  1454. "getInternalFrameBorder"));
  1455. // *** ProgressBar
  1456. Object progressBarBorder = new SwingLazyValue(
  1457. "com.sun.java.swing.plaf.windows.WindowsBorders",
  1458. "getProgressBarBorder");
  1459. Object radioButtonBorder = new SwingLazyValue(
  1460. "javax.swing.plaf.basic.BasicBorders",
  1461. "getRadioButtonBorder");
  1462. Object scrollPaneBorder =
  1463. new XPBorderValue("listbox", textFieldBorder);
  1464. Object tableScrollPaneBorder =
  1465. new XPBorderValue("listbox", loweredBevelBorder);
  1466. Object tableHeaderBorder = new SwingLazyValue(
  1467. "com.sun.java.swing.plaf.windows.WindowsBorders",
  1468. "getTableHeaderBorder");
  1469. // *** ToolBar
  1470. Object toolBarBorder = new SwingLazyValue(
  1471. "com.sun.java.swing.plaf.windows.WindowsBorders",
  1472. "getToolBarBorder");
  1473. // *** ToolTips
  1474. Object toolTipBorder = new SwingLazyValue(
  1475. "javax.swing.plaf.BorderUIResource",
  1476. "getBlackLineBorderUIResource");
  1477. Object checkBoxIcon = new SwingLazyValue(
  1478. "com.sun.java.swing.plaf.windows.WindowsIconFactory",
  1479. "getCheckBoxIcon");
  1480. Object radioButtonIcon = new SwingLazyValue(
  1481. "com.sun.java.swing.plaf.windows.WindowsIconFactory",
  1482. "getRadioButtonIcon");
  1483. Object menuItemCheckIcon = new SwingLazyValue(
  1484. "com.sun.java.swing.plaf.windows.WindowsIconFactory",
  1485. "getMenuItemCheckIcon");
  1486. Object menuItemArrowIcon = new SwingLazyValue(
  1487. "com.sun.java.swing.plaf.windows.WindowsIconFactory",
  1488. "getMenuItemArrowIcon");
  1489. Object menuArrowIcon = new SwingLazyValue(
  1490. "com.sun.java.swing.plaf.windows.WindowsIconFactory",
  1491. "getMenuArrowIcon");
  1492. Object[] lazyDefaults = {
  1493. "Button.border", buttonBorder,
  1494. "CheckBox.border", radioButtonBorder,
  1495. "ComboBox.border", comboBoxBorder,
  1496. "DesktopIcon.border", internalFrameBorder,
  1497. "FormattedTextField.border", textFieldBorder,
  1498. "FormattedTextField.margin", textFieldMargin,
  1499. "InternalFrame.border", internalFrameBorder,
  1500. "List.focusCellHighlightBorder", focusCellHighlightBorder,
  1501. "Table.focusCellHighlightBorder", focusCellHighlightBorder,
  1502. "Menu.border", marginBorder,
  1503. "MenuBar.border", menuBarBorder,
  1504. "MenuItem.border", marginBorder,
  1505. "PasswordField.border", textFieldBorder,
  1506. "PasswordField.margin", textFieldMargin,
  1507. "PopupMenu.border", popupMenuBorder,
  1508. "ProgressBar.border", progressBarBorder,
  1509. "RadioButton.border", radioButtonBorder,
  1510. "ScrollPane.border", scrollPaneBorder,
  1511. "Spinner.border", spinnerBorder,
  1512. "Table.scrollPaneBorder", tableScrollPaneBorder,
  1513. "TableHeader.cellBorder", tableHeaderBorder,
  1514. "TextField.border", textFieldBorder,
  1515. "TextField.margin", textFieldMargin,
  1516. "TitledBorder.border",
  1517. new XPBorderValue("button.groupbox", etchedBorder),
  1518. "ToggleButton.border", radioButtonBorder,
  1519. "ToolBar.border", toolBarBorder,
  1520. "ToolTip.border", toolTipBorder,
  1521. "CheckBox.icon", checkBoxIcon,
  1522. "Menu.arrowIcon", menuArrowIcon,
  1523. "MenuItem.checkIcon", menuItemCheckIcon,
  1524. "MenuItem.arrowIcon", menuItemArrowIcon,
  1525. "RadioButton.icon", radioButtonIcon,
  1526. "InternalFrame.layoutTitlePaneAtOrigin",
  1527. new XPValue(Boolean.TRUE, Boolean.FALSE),
  1528. };
  1529. return lazyDefaults;
  1530. }
  1531. public void uninitialize() {
  1532. super.uninitialize();
  1533. toolkit = null;
  1534. if (WindowsPopupMenuUI.mnemonicListener != null) {
  1535. MenuSelectionManager.defaultManager().
  1536. removeChangeListener(WindowsPopupMenuUI.mnemonicListener);
  1537. }
  1538. KeyboardFocusManager.getCurrentKeyboardFocusManager().
  1539. removeKeyEventPostProcessor(WindowsRootPaneUI.altProcessor);
  1540. DesktopProperty.flushUnreferencedProperties();
  1541. }
  1542. // Toggle flag for drawing the mnemonic state
  1543. private static boolean isMnemonicHidden = true;
  1544. // Flag which indicates that the Win98/Win2k/WinME features
  1545. // should be disabled.
  1546. private static boolean isClassicWindows = false;
  1547. /**
  1548. * Sets the state of the hide mnemonic flag. This flag is used by the
  1549. * component UI delegates to determine if the mnemonic should be rendered.
  1550. * This method is a non operation if the underlying operating system
  1551. * does not support the mnemonic hiding feature.
  1552. *
  1553. * @param hide true if mnemonics should be hidden
  1554. * @since 1.4
  1555. */
  1556. public static void setMnemonicHidden(boolean hide) {
  1557. if (UIManager.getBoolean("Button.showMnemonics") == true) {
  1558. // Do not hide mnemonics if the UI defaults do not support this
  1559. isMnemonicHidden = false;
  1560. } else {
  1561. isMnemonicHidden = hide;
  1562. }
  1563. }
  1564. /**
  1565. * Gets the state of the hide mnemonic flag. This only has meaning
  1566. * if this feature is supported by the underlying OS.
  1567. *
  1568. * @return true if mnemonics are hidden, otherwise, false
  1569. * @see #setMnemonicHidden
  1570. * @since 1.4
  1571. */
  1572. public static boolean isMnemonicHidden() {
  1573. if (UIManager.getBoolean("Button.showMnemonics") == true) {
  1574. // Do not hide mnemonics if the UI defaults do not support this
  1575. isMnemonicHidden = false;
  1576. }
  1577. return isMnemonicHidden;
  1578. }
  1579. /**
  1580. * Gets the state of the flag which indicates if the old Windows
  1581. * look and feel should be rendered. This flag is used by the
  1582. * component UI delegates as a hint to determine which style the component
  1583. * should be rendered.
  1584. *
  1585. * @return true if Windows 95 and Windows NT 4 look and feel should
  1586. * be rendered
  1587. * @since 1.4
  1588. */
  1589. public static boolean isClassicWindows() {
  1590. return isClassicWindows;
  1591. }
  1592. /**
  1593. * <p>
  1594. * Invoked when the user attempts an invalid operation,
  1595. * such as pasting into an uneditable <code>JTextField</code>
  1596. * that has focus.
  1597. * </p>
  1598. * <p>
  1599. * If the user has enabled visual error indication on
  1600. * the desktop, this method will flash the caption bar
  1601. * of the active window. The user can also set the
  1602. * property awt.visualbell=true to achieve the same
  1603. * results.
  1604. * </p>
  1605. *
  1606. * @param component Component the error occured in, may be
  1607. * null indicating the error condition is
  1608. * not directly associated with a
  1609. * <code>Component</code>.
  1610. *
  1611. * @see javax.swing.LookAndFeel#provideErrorFeedback
  1612. */
  1613. public void provideErrorFeedback(Component component) {
  1614. super.provideErrorFeedback(component);
  1615. }
  1616. // ********* Auditory Cue support methods and objects *********
  1617. /**
  1618. * Returns an <code>Action</code>.
  1619. * <P>
  1620. * This Action contains the information and logic to render an
  1621. * auditory cue. The <code>Object</code> that is passed to this
  1622. * method contains the information needed to render the auditory
  1623. * cue. Normally, this <code>Object</code> is a <code>String</code>
  1624. * that points to a <code>Toolkit</code> <code>desktopProperty</code>.
  1625. * This <code>desktopProperty</code> is resolved by AWT and the
  1626. * Windows OS.
  1627. * <P>
  1628. * This <code>Action</code>'s <code>actionPerformed</code> method
  1629. * is fired by the <code>playSound</code> method.
  1630. *
  1631. * @return an Action which knows how to render the auditory
  1632. * cue for one particular system or user activity
  1633. * @see #playSound(Action)
  1634. * @since 1.4
  1635. */
  1636. protected Action createAudioAction(Object key) {
  1637. if (key != null) {
  1638. String audioKey = (String)key;
  1639. String audioValue = (String)UIManager.get(key);
  1640. return new AudioAction(audioKey, audioValue);
  1641. } else {
  1642. return null;
  1643. }
  1644. }
  1645. static void repaintRootPane(Component c) {
  1646. JRootPane root = null;
  1647. for (; c != null; c = c.getParent()) {
  1648. if (c instanceof JRootPane) {
  1649. root = (JRootPane)c;
  1650. }
  1651. }
  1652. if (root != null) {
  1653. root.repaint();
  1654. } else {
  1655. c.repaint();
  1656. }
  1657. }
  1658. /**
  1659. * Pass the name String to the super constructor. This is used
  1660. * later to identify the Action and decide whether to play it or
  1661. * not. Store the resource String. It is used to get the audio
  1662. * resource. In this case, the resource is a <code>Runnable</code>
  1663. * supplied by <code>Toolkit</code>. This <code>Runnable</code> is
  1664. * effectively a pointer down into the Win32 OS that knows how to
  1665. * play the right sound.
  1666. *
  1667. * @since 1.4
  1668. */
  1669. private static class AudioAction extends AbstractAction {
  1670. private Runnable audioRunnable;
  1671. private String audioResource;
  1672. /**
  1673. * We use the String as the name of the Action and as a pointer to
  1674. * the underlying OSes audio resource.
  1675. */
  1676. public AudioAction(String name, String resource) {
  1677. super(name);
  1678. audioResource = resource;
  1679. }
  1680. public void actionPerformed(ActionEvent e) {
  1681. if (audioRunnable == null) {
  1682. audioRunnable = (Runnable)Toolkit.getDefaultToolkit().getDesktopProperty(audioResource);
  1683. }
  1684. if (audioRunnable != null) {
  1685. // Runnable appears to block until completed playing, hence
  1686. // start up another thread to handle playing.
  1687. new Thread(audioRunnable).start();
  1688. }
  1689. }
  1690. }
  1691. /**
  1692. * Gets an <code>Icon</code> from the native libraries if available,
  1693. * otherwise gets it from an image resource file.
  1694. */
  1695. private static class LazyWindowsIcon implements UIDefaults.LazyValue {
  1696. private String nativeImage;
  1697. private String resource;
  1698. LazyWindowsIcon(String nativeImage, String resource) {
  1699. this.nativeImage = nativeImage;
  1700. this.resource = resource;
  1701. }
  1702. public Object createValue(UIDefaults table) {
  1703. if (nativeImage != null) {
  1704. Image image = (Image)ShellFolder.get(nativeImage);
  1705. if (image != null) {
  1706. return new ImageIcon(image);
  1707. }
  1708. }
  1709. return LookAndFeel.makeIcon(getClass(), resource);
  1710. }
  1711. }
  1712. /**
  1713. * DesktopProperty for fonts. If a font with the name 'MS Sans Serif'
  1714. * is returned, it is mapped to 'Microsoft Sans Serif'.
  1715. */
  1716. private static class WindowsFontProperty extends DesktopProperty {
  1717. WindowsFontProperty(String key, Object backup, Toolkit kit) {
  1718. super(key, backup, kit);
  1719. }
  1720. protected Object configureValue(Object value) {
  1721. if (value instanceof Font) {
  1722. Font font = (Font)value;
  1723. if ("MS Sans Serif".equals(font.getName())) {
  1724. int size = font.getSize();
  1725. // 4950968: Workaround to mimic the way Windows maps the default
  1726. // font size of 6 pts to the smallest available bitmap font size.
  1727. // This happens mostly on Win 98/Me & NT.
  1728. int dpi;
  1729. try {
  1730. dpi = Toolkit.getDefaultToolkit().getScreenResolution();
  1731. } catch (HeadlessException ex) {
  1732. dpi = 96;
  1733. }
  1734. if (Math.round(size * 72F / dpi) < 8) {
  1735. size = Math.round(8 * dpi / 72F);
  1736. }
  1737. Font msFont = new FontUIResource("Microsoft Sans Serif",
  1738. font.getStyle(), size);
  1739. if (msFont.getName() != null &&
  1740. msFont.getName().equals(msFont.getFamily())) {
  1741. font = msFont;
  1742. } else if (size != font.getSize()) {
  1743. font = new FontUIResource("MS Sans Serif",
  1744. font.getStyle(), size);
  1745. }
  1746. }
  1747. if (FontManager.fontSupportsDefaultEncoding(font)) {
  1748. if (!(font instanceof UIResource)) {
  1749. font = new FontUIResource(font);
  1750. }
  1751. }
  1752. else {
  1753. font = FontManager.getCompositeFontUIResource(font);
  1754. }
  1755. return font;
  1756. }
  1757. return super.configureValue(value);
  1758. }
  1759. }
  1760. /**
  1761. * DesktopProperty for fonts that only gets sizes from the desktop,
  1762. * font name and style are passed into the constructor
  1763. */
  1764. private static class WindowsFontSizeProperty extends DesktopProperty {
  1765. private String fontName;
  1766. private int fontSize;
  1767. private int fontStyle;
  1768. WindowsFontSizeProperty(String key, Toolkit toolkit, String fontName,
  1769. int fontStyle, int fontSize) {
  1770. super(key, null, toolkit);
  1771. this.fontName = fontName;
  1772. this.fontSize = fontSize;
  1773. this.fontStyle = fontStyle;
  1774. }
  1775. protected Object configureValue(Object value) {
  1776. if (value == null) {
  1777. value = new FontUIResource(fontName, fontStyle, fontSize);
  1778. }
  1779. else if (value instanceof Integer) {
  1780. value = new FontUIResource(fontName, fontStyle,
  1781. ((Integer)value).intValue());
  1782. }
  1783. return value;
  1784. }
  1785. }
  1786. /**
  1787. * A value wrapper that actively retrieves values from xp or falls back
  1788. * to the classic value if not running XP styles.
  1789. */
  1790. private static class XPValue implements UIDefaults.ActiveValue {
  1791. protected Object classicValue, xpValue;
  1792. XPValue(Object xpValue, Object classicValue) {
  1793. this.xpValue = xpValue;
  1794. this.classicValue = classicValue;
  1795. }
  1796. public Object createValue(UIDefaults table) {
  1797. Object value = null;
  1798. if (XPStyle.getXP() != null) {
  1799. value = getXPValue(table);
  1800. }
  1801. return (value != null) ? value : getClassicValue(table);
  1802. }
  1803. protected Object getXPValue(UIDefaults table) {
  1804. return recursiveCreateValue(xpValue, table);
  1805. }
  1806. protected Object getClassicValue(UIDefaults table) {
  1807. return recursiveCreateValue(classicValue, table);
  1808. }
  1809. private Object recursiveCreateValue(Object value, UIDefaults table) {
  1810. if (value instanceof UIDefaults.LazyValue) {
  1811. value = ((UIDefaults.LazyValue)value).createValue(table);
  1812. }
  1813. if (value instanceof UIDefaults.ActiveValue) {
  1814. return ((UIDefaults.ActiveValue)value).createValue(table);
  1815. } else {
  1816. return value;
  1817. }
  1818. }
  1819. }
  1820. private static class XPBorderValue extends XPValue {
  1821. XPBorderValue(String xpValue, Object classicValue) {
  1822. super(xpValue, classicValue);
  1823. }
  1824. public Object getXPValue(UIDefaults table) {
  1825. return XPStyle.getXP().getBorder((String)xpValue);
  1826. }
  1827. }
  1828. private static class XPColorValue extends XPValue {
  1829. XPColorValue(String xpValue, Object classicValue) {
  1830. super(xpValue, classicValue);
  1831. }
  1832. public Object getXPValue(UIDefaults table) {
  1833. return XPStyle.getXP().getColor((String)xpValue, null);
  1834. }
  1835. }
  1836. }