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