1. /*
  2. * @(#)MetalLookAndFeel.java 1.161 03/01/23
  3. *
  4. * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.swing.plaf.metal;
  8. import java.awt.*;
  9. import javax.swing.plaf.*;
  10. import javax.swing.*;
  11. import javax.swing.plaf.basic.*;
  12. import javax.swing.border.*;
  13. import javax.swing.text.JTextComponent;
  14. import javax.swing.text.DefaultEditorKit;
  15. import java.util.*;
  16. import java.awt.Font;
  17. import java.awt.Color;
  18. import java.awt.SystemColor;
  19. import java.awt.event.KeyEvent;
  20. import java.awt.event.InputEvent;
  21. import java.net.URL;
  22. import java.io.Serializable;
  23. import java.security.AccessController;
  24. import sun.awt.AppContext;
  25. import sun.security.action.GetPropertyAction;
  26. /**
  27. * Implements the Java look and feel (codename: Metal).
  28. * <p>
  29. * For the keyboard keys defined for each component in this look and
  30. * feel, see
  31. * <a href="../../doc-files/Key-Metal.html">Component Keystroke Actions for the Java Look and Feel.</a>
  32. * <p>
  33. * <strong>Warning:</strong>
  34. * Serialized objects of this class will not be compatible with
  35. * future Swing releases. The current serialization support is
  36. * appropriate for short term storage or RMI between applications running
  37. * the same version of Swing. As of 1.4, support for long term storage
  38. * of all JavaBeans<sup><font size="-2">TM</font></sup>
  39. * has been added to the <code>java.beans</code> package.
  40. * Please see {@link java.beans.XMLEncoder}.
  41. *
  42. * @version @(#)MetalLookAndFeel.java 1.161 03/01/23
  43. * @author Steve Wilson
  44. */
  45. public class MetalLookAndFeel extends BasicLookAndFeel
  46. {
  47. private static boolean METAL_LOOK_AND_FEEL_INITED = false;
  48. private static MetalTheme currentTheme;
  49. private static boolean isOnlyOneContext = true;
  50. private static AppContext cachedAppContext;
  51. /**
  52. * True if checked for windows yet.
  53. */
  54. private static boolean checkedWindows;
  55. /**
  56. * True if running on Windows.
  57. */
  58. private static boolean isWindows;
  59. /**
  60. * Set to true first time we've checked swing.useSystemFontSettings.
  61. */
  62. private static boolean checkedSystemFontSettings;
  63. /**
  64. * True indicates we should use system fonts, unless the developer has
  65. * specified otherwise with Application.useSystemFontSettings.
  66. */
  67. private static boolean useSystemFonts;
  68. /**
  69. * Returns true if running on Windows.
  70. */
  71. static boolean isWindows() {
  72. if (!checkedWindows) {
  73. String osName = (String)AccessController.doPrivileged(
  74. new GetPropertyAction("os.name"));
  75. if (osName != null && osName.indexOf("Windows") != -1) {
  76. isWindows = true;
  77. String systemFonts = (String)AccessController.doPrivileged(
  78. new GetPropertyAction("swing.useSystemFontSettings"));
  79. useSystemFonts = (systemFonts != null &&
  80. (Boolean.valueOf(systemFonts).booleanValue()));
  81. }
  82. checkedWindows = true;
  83. }
  84. return isWindows;
  85. }
  86. /**
  87. * Returns true if system fonts should be used, this is only useful
  88. * for windows.
  89. */
  90. static boolean useSystemFonts() {
  91. if (isWindows() && useSystemFonts) {
  92. if (METAL_LOOK_AND_FEEL_INITED) {
  93. Object value = UIManager.get(
  94. "Application.useSystemFontSettings");
  95. return (value == null || Boolean.TRUE.equals(value));
  96. }
  97. // If an instanceof MetalLookAndFeel hasn't been inited yet, we
  98. // don't want to trigger loading of a UI by asking the UIManager
  99. // for a property, assume the user wants system fonts. This will
  100. // be properly adjusted when install is invoked on the
  101. // MetalTheme
  102. return true;
  103. }
  104. return false;
  105. }
  106. /**
  107. * Returns true if the high contrast theme should be used as the default
  108. * theme.
  109. */
  110. private static boolean useHighContrastTheme() {
  111. if (isWindows() && useSystemFonts()) {
  112. Boolean highContrast = (Boolean)Toolkit.getDefaultToolkit().
  113. getDesktopProperty("win.highContrast.on");
  114. return (highContrast == null) ? false : highContrast.
  115. booleanValue();
  116. }
  117. return false;
  118. }
  119. public String getName() {
  120. return "Metal";
  121. }
  122. public String getID() {
  123. return "Metal";
  124. }
  125. public String getDescription() {
  126. return "The Java(tm) Look and Feel";
  127. }
  128. public boolean isNativeLookAndFeel() {
  129. return false;
  130. }
  131. public boolean isSupportedLookAndFeel() {
  132. return true;
  133. }
  134. /**
  135. * Returns true if the <code>LookAndFeel</code> returned
  136. * <code>RootPaneUI</code> instances support providing Window decorations
  137. * in a <code>JRootPane</code>.
  138. * <p>
  139. * This implementation returns true, since it does support providing
  140. * these border and window title pane decorations.
  141. *
  142. * @return True if the RootPaneUI instances created support client side
  143. * decorations
  144. * @see JDialog#setDefaultLookAndFeelDecorated
  145. * @see JFrame#setDefaultLookAndFeelDecorated
  146. * @see JRootPane#setWindowDecorationStyle
  147. * @since 1.4
  148. */
  149. public boolean getSupportsWindowDecorations() {
  150. return true;
  151. }
  152. /**
  153. * Creates the mapping from
  154. * UI class IDs to <code>ComponentUI</code> classes,
  155. * putting the ID-<code>ComponentUI</code> pairs
  156. * in the passed-in defaults table.
  157. * Each <code>JComponent</code> class
  158. * specifies its own UI class ID string.
  159. * For example,
  160. * <code>JButton</code> has the UI class ID "ButtonUI",
  161. * which this method maps to "javax.swing.plaf.metal.MetalButtonUI".
  162. *
  163. * @see BasicLookAndFeel#getDefaults
  164. * @see javax.swing.JComponent#getUIClassID
  165. */
  166. protected void initClassDefaults(UIDefaults table)
  167. {
  168. super.initClassDefaults(table);
  169. String metalPackageName = "javax.swing.plaf.metal.";
  170. Object[] uiDefaults = {
  171. "ButtonUI", metalPackageName + "MetalButtonUI",
  172. "CheckBoxUI", metalPackageName + "MetalCheckBoxUI",
  173. "ComboBoxUI", metalPackageName + "MetalComboBoxUI",
  174. "DesktopIconUI", metalPackageName + "MetalDesktopIconUI",
  175. "FileChooserUI", metalPackageName + "MetalFileChooserUI",
  176. "InternalFrameUI", metalPackageName + "MetalInternalFrameUI",
  177. "LabelUI", metalPackageName + "MetalLabelUI",
  178. "PopupMenuSeparatorUI", metalPackageName + "MetalPopupMenuSeparatorUI",
  179. "ProgressBarUI", metalPackageName + "MetalProgressBarUI",
  180. "RadioButtonUI", metalPackageName + "MetalRadioButtonUI",
  181. "ScrollBarUI", metalPackageName + "MetalScrollBarUI",
  182. "ScrollPaneUI", metalPackageName + "MetalScrollPaneUI",
  183. "SeparatorUI", metalPackageName + "MetalSeparatorUI",
  184. "SliderUI", metalPackageName + "MetalSliderUI",
  185. "SplitPaneUI", metalPackageName + "MetalSplitPaneUI",
  186. "TabbedPaneUI", metalPackageName + "MetalTabbedPaneUI",
  187. "TextFieldUI", metalPackageName + "MetalTextFieldUI",
  188. "ToggleButtonUI", metalPackageName + "MetalToggleButtonUI",
  189. "ToolBarUI", metalPackageName + "MetalToolBarUI",
  190. "ToolTipUI", metalPackageName + "MetalToolTipUI",
  191. "TreeUI", metalPackageName + "MetalTreeUI",
  192. "RootPaneUI", metalPackageName + "MetalRootPaneUI",
  193. };
  194. table.putDefaults(uiDefaults);
  195. }
  196. /**
  197. * Load the SystemColors into the defaults table. The keys
  198. * for SystemColor defaults are the same as the names of
  199. * the public fields in SystemColor.
  200. */
  201. protected void initSystemColorDefaults(UIDefaults table)
  202. {
  203. Object[] systemColors = {
  204. "desktop", getDesktopColor(), /* Color of the desktop background */
  205. "activeCaption", getWindowTitleBackground(), /* Color for captions (title bars) when they are active. */
  206. "activeCaptionText", getWindowTitleForeground(), /* Text color for text in captions (title bars). */
  207. "activeCaptionBorder", getPrimaryControlShadow(), /* Border color for caption (title bar) window borders. */
  208. "inactiveCaption", getWindowTitleInactiveBackground(), /* Color for captions (title bars) when not active. */
  209. "inactiveCaptionText", getWindowTitleInactiveForeground(), /* Text color for text in inactive captions (title bars). */
  210. "inactiveCaptionBorder", getControlShadow(), /* Border color for inactive caption (title bar) window borders. */
  211. "window", getWindowBackground(), /* Default color for the interior of windows */
  212. "windowBorder", getControl(), /* ??? */
  213. "windowText", getUserTextColor(), /* ??? */
  214. "menu", getMenuBackground(), /* Background color for menus */
  215. "menuText", getMenuForeground(), /* Text color for menus */
  216. "text", getWindowBackground(), /* Text background color */
  217. "textText", getUserTextColor(), /* Text foreground color */
  218. "textHighlight", getTextHighlightColor(), /* Text background color when selected */
  219. "textHighlightText", getHighlightedTextColor(), /* Text color when selected */
  220. "textInactiveText", getInactiveSystemTextColor(), /* Text color when disabled */
  221. "control", getControl(), /* Default color for controls (buttons, sliders, etc) */
  222. "controlText", getControlTextColor(), /* Default color for text in controls */
  223. "controlHighlight", getControlHighlight(), /* Specular highlight (opposite of the shadow) */
  224. "controlLtHighlight", getControlHighlight(), /* Highlight color for controls */
  225. "controlShadow", getControlShadow(), /* Shadow color for controls */
  226. "controlDkShadow", getControlDarkShadow(), /* Dark shadow color for controls */
  227. "scrollbar", getControl(), /* Scrollbar background (usually the "track") */
  228. "info", getPrimaryControl(), /* ToolTip Background */
  229. "infoText", getPrimaryControlInfo() /* ToolTip Text */
  230. };
  231. for(int i = 0; i < systemColors.length; i += 2) {
  232. table.put((String)systemColors[i], systemColors[i + 1]);
  233. }
  234. }
  235. /**
  236. * Initialize the defaults table with the name of the ResourceBundle
  237. * used for getting localized defaults.
  238. */
  239. private void initResourceBundle(UIDefaults table) {
  240. table.addResourceBundle( "com.sun.swing.internal.plaf.metal.resources.metal" );
  241. }
  242. protected void initComponentDefaults(UIDefaults table) {
  243. super.initComponentDefaults( table );
  244. initResourceBundle(table);
  245. Object textFieldBorder =
  246. new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalBorders",
  247. "getTextFieldBorder");
  248. Object textBorder =
  249. new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalBorders",
  250. "getTextBorder");
  251. Object dialogBorder = new MetalLazyValue(
  252. "javax.swing.plaf.metal.MetalBorders$DialogBorder");
  253. Object questionDialogBorder = new MetalLazyValue(
  254. "javax.swing.plaf.metal.MetalBorders$QuestionDialogBorder");
  255. Object fieldInputMap = new UIDefaults.LazyInputMap(new Object[] {
  256. "ctrl C", DefaultEditorKit.copyAction,
  257. "ctrl V", DefaultEditorKit.pasteAction,
  258. "ctrl X", DefaultEditorKit.cutAction,
  259. "COPY", DefaultEditorKit.copyAction,
  260. "PASTE", DefaultEditorKit.pasteAction,
  261. "CUT", DefaultEditorKit.cutAction,
  262. "shift LEFT", DefaultEditorKit.selectionBackwardAction,
  263. "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction,
  264. "shift RIGHT", DefaultEditorKit.selectionForwardAction,
  265. "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction,
  266. "ctrl LEFT", DefaultEditorKit.previousWordAction,
  267. "ctrl KP_LEFT", DefaultEditorKit.previousWordAction,
  268. "ctrl RIGHT", DefaultEditorKit.nextWordAction,
  269. "ctrl KP_RIGHT", DefaultEditorKit.nextWordAction,
  270. "ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
  271. "ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction,
  272. "ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction,
  273. "ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction,
  274. "ctrl A", DefaultEditorKit.selectAllAction,
  275. "HOME", DefaultEditorKit.beginLineAction,
  276. "END", DefaultEditorKit.endLineAction,
  277. "shift HOME", DefaultEditorKit.selectionBeginLineAction,
  278. "shift END", DefaultEditorKit.selectionEndLineAction,
  279. "typed \010", DefaultEditorKit.deletePrevCharAction,
  280. "DELETE", DefaultEditorKit.deleteNextCharAction,
  281. "RIGHT", DefaultEditorKit.forwardAction,
  282. "LEFT", DefaultEditorKit.backwardAction,
  283. "KP_RIGHT", DefaultEditorKit.forwardAction,
  284. "KP_LEFT", DefaultEditorKit.backwardAction,
  285. "ENTER", JTextField.notifyAction,
  286. "ctrl BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/,
  287. "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
  288. });
  289. Object multilineInputMap = new UIDefaults.LazyInputMap(new Object[] {
  290. "ctrl C", DefaultEditorKit.copyAction,
  291. "ctrl V", DefaultEditorKit.pasteAction,
  292. "ctrl X", DefaultEditorKit.cutAction,
  293. "COPY", DefaultEditorKit.copyAction,
  294. "PASTE", DefaultEditorKit.pasteAction,
  295. "CUT", DefaultEditorKit.cutAction,
  296. "shift LEFT", DefaultEditorKit.selectionBackwardAction,
  297. "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction,
  298. "shift RIGHT", DefaultEditorKit.selectionForwardAction,
  299. "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction,
  300. "ctrl LEFT", DefaultEditorKit.previousWordAction,
  301. "ctrl KP_LEFT", DefaultEditorKit.previousWordAction,
  302. "ctrl RIGHT", DefaultEditorKit.nextWordAction,
  303. "ctrl KP_RIGHT", DefaultEditorKit.nextWordAction,
  304. "ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
  305. "ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction,
  306. "ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction,
  307. "ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction,
  308. "ctrl A", DefaultEditorKit.selectAllAction,
  309. "HOME", DefaultEditorKit.beginLineAction,
  310. "END", DefaultEditorKit.endLineAction,
  311. "shift HOME", DefaultEditorKit.selectionBeginLineAction,
  312. "shift END", DefaultEditorKit.selectionEndLineAction,
  313. "UP", DefaultEditorKit.upAction,
  314. "KP_UP", DefaultEditorKit.upAction,
  315. "DOWN", DefaultEditorKit.downAction,
  316. "KP_DOWN", DefaultEditorKit.downAction,
  317. "PAGE_UP", DefaultEditorKit.pageUpAction,
  318. "PAGE_DOWN", DefaultEditorKit.pageDownAction,
  319. "shift PAGE_UP", "selection-page-up",
  320. "shift PAGE_DOWN", "selection-page-down",
  321. "ctrl shift PAGE_UP", "selection-page-left",
  322. "ctrl shift PAGE_DOWN", "selection-page-right",
  323. "shift UP", DefaultEditorKit.selectionUpAction,
  324. "shift KP_UP", DefaultEditorKit.selectionUpAction,
  325. "shift DOWN", DefaultEditorKit.selectionDownAction,
  326. "shift KP_DOWN", DefaultEditorKit.selectionDownAction,
  327. "ENTER", DefaultEditorKit.insertBreakAction,
  328. "typed \010", DefaultEditorKit.deletePrevCharAction,
  329. "DELETE", DefaultEditorKit.deleteNextCharAction,
  330. "RIGHT", DefaultEditorKit.forwardAction,
  331. "LEFT", DefaultEditorKit.backwardAction,
  332. "KP_RIGHT", DefaultEditorKit.forwardAction,
  333. "KP_LEFT", DefaultEditorKit.backwardAction,
  334. "TAB", DefaultEditorKit.insertTabAction,
  335. "ctrl BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/,
  336. "ctrl HOME", DefaultEditorKit.beginAction,
  337. "ctrl END", DefaultEditorKit.endAction,
  338. "ctrl shift HOME", DefaultEditorKit.selectionBeginAction,
  339. "ctrl shift END", DefaultEditorKit.selectionEndAction,
  340. "ctrl T", "next-link-action",
  341. "ctrl shift T", "previous-link-action",
  342. "ctrl SPACE", "activate-link-action",
  343. "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
  344. });
  345. Object scrollPaneBorder = new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalBorders$ScrollPaneBorder");
  346. Object buttonBorder =
  347. new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalBorders",
  348. "getButtonBorder");
  349. Object toggleButtonBorder =
  350. new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalBorders",
  351. "getToggleButtonBorder");
  352. Object titledBorderBorder =
  353. new UIDefaults.ProxyLazyValue(
  354. "javax.swing.plaf.BorderUIResource$LineBorderUIResource",
  355. new Object[] {table.getColor("controlShadow")});
  356. Object desktopIconBorder =
  357. new UIDefaults.ProxyLazyValue(
  358. "javax.swing.plaf.metal.MetalBorders",
  359. "getDesktopIconBorder");
  360. Object menuBarBorder =
  361. new UIDefaults.ProxyLazyValue(
  362. "javax.swing.plaf.metal.MetalBorders$MenuBarBorder");
  363. Object popupMenuBorder =
  364. new UIDefaults.ProxyLazyValue(
  365. "javax.swing.plaf.metal.MetalBorders$PopupMenuBorder");
  366. Object menuItemBorder =
  367. new UIDefaults.ProxyLazyValue(
  368. "javax.swing.plaf.metal.MetalBorders$MenuItemBorder");
  369. Object menuItemAcceleratorDelimiter = new String("-");
  370. Object toolBarBorder = new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalBorders$ToolBarBorder");
  371. Object progressBarBorder = new UIDefaults.ProxyLazyValue(
  372. "javax.swing.plaf.BorderUIResource$LineBorderUIResource",
  373. new Object[] {getControlDarkShadow(), new Integer(1)});
  374. Object toolTipBorder = new UIDefaults.ProxyLazyValue(
  375. "javax.swing.plaf.BorderUIResource$LineBorderUIResource",
  376. new Object[] {getPrimaryControlDarkShadow()});
  377. Object toolTipBorderInactive = new UIDefaults.ProxyLazyValue(
  378. "javax.swing.plaf.BorderUIResource$LineBorderUIResource",
  379. new Object[] {getControlDarkShadow()});
  380. Object focusCellHighlightBorder = new UIDefaults.ProxyLazyValue(
  381. "javax.swing.plaf.BorderUIResource$LineBorderUIResource",
  382. new Object[] {getFocusColor()});
  383. Object tabbedPaneTabAreaInsets = new InsetsUIResource(4, 2, 0, 6);
  384. Object tabbedPaneTabInsets = new InsetsUIResource(0, 9, 1, 9);
  385. Object sliderFocusInsets = new InsetsUIResource( 0, 0, 0, 0 );
  386. final Object[] internalFrameIconArgs = new Object[1];
  387. internalFrameIconArgs[0] = new Integer(16);
  388. Object[] defaultCueList = new Object[] {
  389. "OptionPane.errorSound",
  390. "OptionPane.informationSound",
  391. "OptionPane.questionSound",
  392. "OptionPane.warningSound" };
  393. MetalTheme theme = getCurrentTheme();
  394. Object menuTextValue = new FontActiveValue(theme,
  395. MetalTheme.MENU_TEXT_FONT);
  396. Object controlTextValue = new FontActiveValue(theme,
  397. MetalTheme.CONTROL_TEXT_FONT);
  398. Object userTextValue = new FontActiveValue(theme,
  399. MetalTheme.USER_TEXT_FONT);
  400. Object windowTitleValue = new FontActiveValue(theme,
  401. MetalTheme.WINDOW_TITLE_FONT);
  402. Object subTextValue = new FontActiveValue(theme,
  403. MetalTheme.SUB_TEXT_FONT);
  404. Object systemTextValue = new FontActiveValue(theme,
  405. MetalTheme.SYSTEM_TEXT_FONT);
  406. //
  407. // DEFAULTS TABLE
  408. //
  409. Object[] defaults = {
  410. // *** Auditory Feedback
  411. "AuditoryCues.defaultCueList", defaultCueList,
  412. // this key defines which of the various cues to render
  413. // This is disabled until sound bugs can be resolved.
  414. "AuditoryCues.playList", null, // defaultCueList,
  415. // Text (Note: many are inherited)
  416. "TextField.border", textFieldBorder,
  417. "TextField.font", userTextValue,
  418. "PasswordField.border", textBorder,
  419. // passwordField.font should actually map to
  420. // win.ansiFixed.font.height on windows.
  421. "PasswordField.font", userTextValue,
  422. // TextArea.font should actually map to win.ansiFixed.font.height
  423. // on windows.
  424. "TextArea.font", userTextValue,
  425. "TextPane.background", table.get("window"),
  426. "TextPane.font", userTextValue,
  427. "EditorPane.background", table.get("window"),
  428. "EditorPane.font", userTextValue,
  429. "TextField.focusInputMap", fieldInputMap,
  430. "PasswordField.focusInputMap", fieldInputMap,
  431. "TextArea.focusInputMap", multilineInputMap,
  432. "TextPane.focusInputMap", multilineInputMap,
  433. "EditorPane.focusInputMap", multilineInputMap,
  434. // FormattedTextFields
  435. "FormattedTextField.border", textFieldBorder,
  436. "FormattedTextField.font", userTextValue,
  437. "FormattedTextField.focusInputMap",
  438. new UIDefaults.LazyInputMap(new Object[] {
  439. "ctrl C", DefaultEditorKit.copyAction,
  440. "ctrl V", DefaultEditorKit.pasteAction,
  441. "ctrl X", DefaultEditorKit.cutAction,
  442. "COPY", DefaultEditorKit.copyAction,
  443. "PASTE", DefaultEditorKit.pasteAction,
  444. "CUT", DefaultEditorKit.cutAction,
  445. "shift LEFT", DefaultEditorKit.selectionBackwardAction,
  446. "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction,
  447. "shift RIGHT", DefaultEditorKit.selectionForwardAction,
  448. "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction,
  449. "ctrl LEFT", DefaultEditorKit.previousWordAction,
  450. "ctrl KP_LEFT", DefaultEditorKit.previousWordAction,
  451. "ctrl RIGHT", DefaultEditorKit.nextWordAction,
  452. "ctrl KP_RIGHT", DefaultEditorKit.nextWordAction,
  453. "ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
  454. "ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction,
  455. "ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction,
  456. "ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction,
  457. "ctrl A", DefaultEditorKit.selectAllAction,
  458. "HOME", DefaultEditorKit.beginLineAction,
  459. "END", DefaultEditorKit.endLineAction,
  460. "shift HOME", DefaultEditorKit.selectionBeginLineAction,
  461. "shift END", DefaultEditorKit.selectionEndLineAction,
  462. "typed \010", DefaultEditorKit.deletePrevCharAction,
  463. "DELETE", DefaultEditorKit.deleteNextCharAction,
  464. "RIGHT", DefaultEditorKit.forwardAction,
  465. "LEFT", DefaultEditorKit.backwardAction,
  466. "KP_RIGHT", DefaultEditorKit.forwardAction,
  467. "KP_LEFT", DefaultEditorKit.backwardAction,
  468. "ENTER", JTextField.notifyAction,
  469. "ctrl BACK_SLASH", "unselect",
  470. "control shift O", "toggle-componentOrientation",
  471. "ESCAPE", "reset-field-edit",
  472. "UP", "increment",
  473. "KP_UP", "increment",
  474. "DOWN", "decrement",
  475. "KP_DOWN", "decrement",
  476. }),
  477. // Buttons
  478. "Button.disabledText", getInactiveControlTextColor(),
  479. "Button.select", getControlShadow(),
  480. "Button.border", buttonBorder,
  481. "Button.font", controlTextValue,
  482. "Button.focus", getFocusColor(),
  483. "Button.focusInputMap", new UIDefaults.LazyInputMap(new Object[] {
  484. "SPACE", "pressed",
  485. "released SPACE", "released"
  486. }),
  487. "CheckBox.disabledText", getInactiveControlTextColor(),
  488. "Checkbox.select", getControlShadow(),
  489. "CheckBox.font", controlTextValue,
  490. "CheckBox.focus", getFocusColor(),
  491. "CheckBox.icon", new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getCheckBoxIcon"),
  492. "CheckBox.focusInputMap",
  493. new UIDefaults.LazyInputMap(new Object[] {
  494. "SPACE", "pressed",
  495. "released SPACE", "released"
  496. }),
  497. "RadioButton.disabledText", getInactiveControlTextColor(),
  498. "RadioButton.select", getControlShadow(),
  499. "RadioButton.icon", new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getRadioButtonIcon"),
  500. "RadioButton.font", controlTextValue,
  501. "RadioButton.focus", getFocusColor(),
  502. "RadioButton.focusInputMap",
  503. new UIDefaults.LazyInputMap(new Object[] {
  504. "SPACE", "pressed",
  505. "released SPACE", "released"
  506. }),
  507. "ToggleButton.select", getControlShadow(),
  508. "ToggleButton.disabledText", getInactiveControlTextColor(),
  509. "ToggleButton.focus", getFocusColor(),
  510. "ToggleButton.border", toggleButtonBorder,
  511. "ToggleButton.font", controlTextValue,
  512. "ToggleButton.focusInputMap",
  513. new UIDefaults.LazyInputMap(new Object[] {
  514. "SPACE", "pressed",
  515. "released SPACE", "released"
  516. }),
  517. // File View
  518. "FileView.directoryIcon", new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getTreeFolderIcon"),
  519. "FileView.fileIcon", new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getTreeLeafIcon"),
  520. "FileView.computerIcon", new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getTreeComputerIcon"),
  521. "FileView.hardDriveIcon", new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getTreeHardDriveIcon"),
  522. "FileView.floppyDriveIcon", new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getTreeFloppyDriveIcon"),
  523. // File Chooser
  524. "FileChooser.detailsViewIcon", new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getFileChooserDetailViewIcon"),
  525. "FileChooser.homeFolderIcon", new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getFileChooserHomeFolderIcon"),
  526. "FileChooser.listViewIcon", new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getFileChooserListViewIcon"),
  527. "FileChooser.newFolderIcon", new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getFileChooserNewFolderIcon"),
  528. "FileChooser.upFolderIcon", new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getFileChooserUpFolderIcon"),
  529. "FileChooser.lookInLabelMnemonic", new Integer(KeyEvent.VK_I),
  530. "FileChooser.fileNameLabelMnemonic", new Integer(KeyEvent.VK_N),
  531. "FileChooser.filesOfTypeLabelMnemonic", new Integer(KeyEvent.VK_T),
  532. "FileChooser.ancestorInputMap",
  533. new UIDefaults.LazyInputMap(new Object[] {
  534. "ESCAPE", "cancelSelection",
  535. "BACK_SPACE", "Go Up",
  536. "ENTER", "approveSelection"
  537. }),
  538. // ToolTip
  539. "ToolTip.font", systemTextValue,
  540. "ToolTip.border", toolTipBorder,
  541. "ToolTip.borderInactive", toolTipBorderInactive,
  542. "ToolTip.backgroundInactive", table.get("control"),
  543. "ToolTip.foregroundInactive", table.get("controlDkShadow"),
  544. "ToolTip.hideAccelerator", Boolean.FALSE,
  545. // Slider Defaults
  546. "Slider.border", null,
  547. "Slider.foreground", getPrimaryControlShadow(),
  548. "Slider.focus", getFocusColor(),
  549. "Slider.focusInsets", sliderFocusInsets,
  550. "Slider.trackWidth", new Integer( 7 ),
  551. "Slider.majorTickLength", new Integer( 6 ),
  552. "Slider.horizontalThumbIcon", new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getHorizontalSliderThumbIcon"),
  553. "Slider.verticalThumbIcon", new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getVerticalSliderThumbIcon"),
  554. "Slider.focusInputMap",
  555. new UIDefaults.LazyInputMap(new Object[] {
  556. "RIGHT", "positiveUnitIncrement",
  557. "KP_RIGHT", "positiveUnitIncrement",
  558. "DOWN", "negativeUnitIncrement",
  559. "KP_DOWN", "negativeUnitIncrement",
  560. "PAGE_DOWN", "negativeBlockIncrement",
  561. "ctrl PAGE_DOWN", "negativeBlockIncrement",
  562. "LEFT", "negativeUnitIncrement",
  563. "KP_LEFT", "negativeUnitIncrement",
  564. "UP", "positiveUnitIncrement",
  565. "KP_UP", "positiveUnitIncrement",
  566. "PAGE_UP", "positiveBlockIncrement",
  567. "ctrl PAGE_UP", "positiveBlockIncrement",
  568. "HOME", "minScroll",
  569. "END", "maxScroll"
  570. }),
  571. // Progress Bar
  572. "ProgressBar.font", controlTextValue,
  573. "ProgressBar.foreground", getPrimaryControlShadow(),
  574. "ProgressBar.selectionBackground", getPrimaryControlDarkShadow(),
  575. "ProgressBar.border", progressBarBorder,
  576. "ProgressBar.cellSpacing", new Integer(0),
  577. "ProgressBar.cellLength", new Integer(1),
  578. // Combo Box
  579. "ComboBox.background", table.get("control"),
  580. "ComboBox.foreground", table.get("controlText"),
  581. "ComboBox.selectionBackground", getPrimaryControlShadow(),
  582. "ComboBox.selectionForeground", getControlTextColor(),
  583. "ComboBox.font", controlTextValue,
  584. "ComboBox.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[] {
  585. "ESCAPE", "hidePopup",
  586. "PAGE_UP", "pageUpPassThrough",
  587. "PAGE_DOWN", "pageDownPassThrough",
  588. "HOME", "homePassThrough",
  589. "END", "endPassThrough",
  590. "DOWN", "selectNext",
  591. "KP_DOWN", "selectNext",
  592. "alt DOWN", "togglePopup",
  593. "alt KP_DOWN", "togglePopup",
  594. "alt UP", "togglePopup",
  595. "alt KP_UP", "togglePopup",
  596. "SPACE", "spacePopup",
  597. "ENTER", "enterPressed",
  598. "UP", "selectPrevious",
  599. "KP_UP", "selectPrevious"
  600. }),
  601. // Internal Frame Defaults
  602. "InternalFrame.icon", new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getInternalFrameDefaultMenuIcon"),
  603. "InternalFrame.border", new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalBorders$InternalFrameBorder"),
  604. "InternalFrame.optionDialogBorder", new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalBorders$OptionDialogBorder"),
  605. "InternalFrame.paletteBorder", new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalBorders$PaletteBorder"),
  606. "InternalFrame.paletteTitleHeight", new Integer(11),
  607. "InternalFrame.paletteCloseIcon", new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalIconFactory$PaletteCloseIcon"),
  608. "InternalFrame.closeIcon",
  609. new UIDefaults.ProxyLazyValue(
  610. "javax.swing.plaf.metal.MetalIconFactory",
  611. "getInternalFrameCloseIcon",
  612. internalFrameIconArgs),
  613. "InternalFrame.maximizeIcon",
  614. new UIDefaults.ProxyLazyValue(
  615. "javax.swing.plaf.metal.MetalIconFactory",
  616. "getInternalFrameMaximizeIcon",
  617. internalFrameIconArgs),
  618. "InternalFrame.iconifyIcon",
  619. new UIDefaults.ProxyLazyValue(
  620. "javax.swing.plaf.metal.MetalIconFactory",
  621. "getInternalFrameMinimizeIcon",
  622. internalFrameIconArgs),
  623. "InternalFrame.minimizeIcon",
  624. new UIDefaults.ProxyLazyValue(
  625. "javax.swing.plaf.metal.MetalIconFactory",
  626. "getInternalFrameAltMaximizeIcon",
  627. internalFrameIconArgs),
  628. "InternalFrame.titleFont", windowTitleValue,
  629. "InternalFrame.windowBindings", null,
  630. // Internal Frame Auditory Cue Mappings
  631. "InternalFrame.closeSound", "sounds/FrameClose.wav",
  632. "InternalFrame.maximizeSound", "sounds/FrameMaximize.wav",
  633. "InternalFrame.minimizeSound", "sounds/FrameMinimize.wav",
  634. "InternalFrame.restoreDownSound", "sounds/FrameRestoreDown.wav",
  635. "InternalFrame.restoreUpSound", "sounds/FrameRestoreUp.wav",
  636. // Desktop Icon
  637. "DesktopIcon.border", desktopIconBorder,
  638. "DesktopIcon.font", controlTextValue,
  639. "DesktopIcon.foreground", getControlTextColor(),
  640. "DesktopIcon.background", getControl(),
  641. "DesktopIcon.width", new Integer(160),
  642. "Desktop.ancestorInputMap",
  643. new UIDefaults.LazyInputMap(new Object[] {
  644. "ctrl F5", "restore",
  645. "ctrl F4", "close",
  646. "ctrl F7", "move",
  647. "ctrl F8", "resize",
  648. "RIGHT", "right",
  649. "KP_RIGHT", "right",
  650. "shift RIGHT", "shrinkRight",
  651. "shift KP_RIGHT", "shrinkRight",
  652. "LEFT", "left",
  653. "KP_LEFT", "left",
  654. "shift LEFT", "shrinkLeft",
  655. "shift KP_LEFT", "shrinkLeft",
  656. "UP", "up",
  657. "KP_UP", "up",
  658. "shift UP", "shrinkUp",
  659. "shift KP_UP", "shrinkUp",
  660. "DOWN", "down",
  661. "KP_DOWN", "down",
  662. "shift DOWN", "shrinkDown",
  663. "shift KP_DOWN", "shrinkDown",
  664. "ESCAPE", "escape",
  665. "ctrl F9", "minimize",
  666. "ctrl F10", "maximize",
  667. "ctrl F6", "selectNextFrame",
  668. "ctrl TAB", "selectNextFrame",
  669. "ctrl alt F6", "selectNextFrame",
  670. "shift ctrl alt F6", "selectPreviousFrame",
  671. "ctrl F12", "navigateNext",
  672. "shift ctrl F12", "navigatePrevious"
  673. }),
  674. // Titled Border
  675. "TitledBorder.font", controlTextValue,
  676. "TitledBorder.titleColor", getSystemTextColor(),
  677. "TitledBorder.border", titledBorderBorder,
  678. // Label
  679. "Label.font", controlTextValue,
  680. "Label.foreground", getSystemTextColor(),
  681. "Label.disabledForeground", getInactiveSystemTextColor(),
  682. // List
  683. "List.font", controlTextValue,
  684. "List.focusCellHighlightBorder", focusCellHighlightBorder,
  685. "List.focusInputMap",
  686. new UIDefaults.LazyInputMap(new Object[] {
  687. "ctrl C", "copy",
  688. "ctrl V", "paste",
  689. "ctrl X", "cut",
  690. "COPY", "copy",
  691. "PASTE", "paste",
  692. "CUT", "cut",
  693. "UP", "selectPreviousRow",
  694. "KP_UP", "selectPreviousRow",
  695. "shift UP", "selectPreviousRowExtendSelection",
  696. "shift KP_UP", "selectPreviousRowExtendSelection",
  697. "DOWN", "selectNextRow",
  698. "KP_DOWN", "selectNextRow",
  699. "shift DOWN", "selectNextRowExtendSelection",
  700. "shift KP_DOWN", "selectNextRowExtendSelection",
  701. "LEFT", "selectPreviousColumn",
  702. "KP_LEFT", "selectPreviousColumn",
  703. "shift LEFT", "selectPreviousColumnExtendSelection",
  704. "shift KP_LEFT", "selectPreviousColumnExtendSelection",
  705. "RIGHT", "selectNextColumn",
  706. "KP_RIGHT", "selectNextColumn",
  707. "shift RIGHT", "selectNextColumnExtendSelection",
  708. "shift KP_RIGHT", "selectNextColumnExtendSelection",
  709. "HOME", "selectFirstRow",
  710. "shift HOME", "selectFirstRowExtendSelection",
  711. "END", "selectLastRow",
  712. "shift END", "selectLastRowExtendSelection",
  713. "PAGE_UP", "scrollUp",
  714. "shift PAGE_UP", "scrollUpExtendSelection",
  715. "PAGE_DOWN", "scrollDown",
  716. "shift PAGE_DOWN", "scrollDownExtendSelection",
  717. "ctrl A", "selectAll",
  718. "ctrl SLASH", "selectAll",
  719. "ctrl BACK_SLASH", "clearSelection"
  720. }),
  721. // ScrollBar
  722. "ScrollBar.background", getControl(),
  723. "ScrollBar.highlight", getControlHighlight(),
  724. "ScrollBar.shadow", getControlShadow(),
  725. "ScrollBar.darkShadow", getControlDarkShadow(),
  726. "ScrollBar.thumb", getPrimaryControlShadow(),
  727. "ScrollBar.thumbShadow", getPrimaryControlDarkShadow(),
  728. "ScrollBar.thumbHighlight", getPrimaryControl(),
  729. "ScrollBar.width", new Integer( 17 ),
  730. "ScrollBar.allowsAbsolutePositioning", Boolean.TRUE,
  731. "ScrollBar.focusInputMap",
  732. new UIDefaults.LazyInputMap(new Object[] {
  733. "RIGHT", "positiveUnitIncrement",
  734. "KP_RIGHT", "positiveUnitIncrement",
  735. "DOWN", "positiveUnitIncrement",
  736. "KP_DOWN", "positiveUnitIncrement",
  737. "PAGE_DOWN", "positiveBlockIncrement",
  738. "LEFT", "negativeUnitIncrement",
  739. "KP_LEFT", "negativeUnitIncrement",
  740. "UP", "negativeUnitIncrement",
  741. "KP_UP", "negativeUnitIncrement",
  742. "PAGE_UP", "negativeBlockIncrement",
  743. "HOME", "minScroll",
  744. "END", "maxScroll"
  745. }),
  746. // ScrollPane
  747. "ScrollPane.border", scrollPaneBorder,
  748. "ScrollPane.ancestorInputMap",
  749. new UIDefaults.LazyInputMap(new Object[] {
  750. "RIGHT", "unitScrollRight",
  751. "KP_RIGHT", "unitScrollRight",
  752. "DOWN", "unitScrollDown",
  753. "KP_DOWN", "unitScrollDown",
  754. "LEFT", "unitScrollLeft",
  755. "KP_LEFT", "unitScrollLeft",
  756. "UP", "unitScrollUp",
  757. "KP_UP", "unitScrollUp",
  758. "PAGE_UP", "scrollUp",
  759. "PAGE_DOWN", "scrollDown",
  760. "ctrl PAGE_UP", "scrollLeft",
  761. "ctrl PAGE_DOWN", "scrollRight",
  762. "ctrl HOME", "scrollHome",
  763. "ctrl END", "scrollEnd"
  764. }),
  765. // Tabbed Pane
  766. "TabbedPane.font", controlTextValue,
  767. "TabbedPane.tabAreaBackground", getControl(),
  768. "TabbedPane.background", getControlShadow(),
  769. "TabbedPane.light", getControl(),
  770. "TabbedPane.focus", getPrimaryControlDarkShadow(),
  771. "TabbedPane.selected", getControl(),
  772. "TabbedPane.selectHighlight", getControlHighlight(),
  773. "TabbedPane.tabAreaInsets", tabbedPaneTabAreaInsets,
  774. "TabbedPane.tabInsets", tabbedPaneTabInsets,
  775. "TabbedPane.focusInputMap",
  776. new UIDefaults.LazyInputMap(new Object[] {
  777. "RIGHT", "navigateRight",
  778. "KP_RIGHT", "navigateRight",
  779. "LEFT", "navigateLeft",
  780. "KP_LEFT", "navigateLeft",
  781. "UP", "navigateUp",
  782. "KP_UP", "navigateUp",
  783. "DOWN", "navigateDown",
  784. "KP_DOWN", "navigateDown",
  785. "ctrl DOWN", "requestFocusForVisibleComponent",
  786. "ctrl KP_DOWN", "requestFocusForVisibleComponent",
  787. }),
  788. "TabbedPane.ancestorInputMap",
  789. new UIDefaults.LazyInputMap(new Object[] {
  790. "ctrl PAGE_DOWN", "navigatePageDown",
  791. "ctrl PAGE_UP", "navigatePageUp",
  792. "ctrl UP", "requestFocus",
  793. "ctrl KP_UP", "requestFocus",
  794. }),
  795. // Table
  796. "Table.font", userTextValue,
  797. "Table.focusCellHighlightBorder", focusCellHighlightBorder,
  798. "Table.scrollPaneBorder", scrollPaneBorder,
  799. "Table.gridColor", getControlShadow(), // grid line color
  800. "Table.ancestorInputMap",
  801. new UIDefaults.LazyInputMap(new Object[] {
  802. "ctrl C", "copy",
  803. "ctrl V", "paste",
  804. "ctrl X", "cut",
  805. "COPY", "copy",
  806. "PASTE", "paste",
  807. "CUT", "cut",
  808. "RIGHT", "selectNextColumn",
  809. "KP_RIGHT", "selectNextColumn",
  810. "LEFT", "selectPreviousColumn",
  811. "KP_LEFT", "selectPreviousColumn",
  812. "DOWN", "selectNextRow",
  813. "KP_DOWN", "selectNextRow",
  814. "UP", "selectPreviousRow",
  815. "KP_UP", "selectPreviousRow",
  816. "shift RIGHT", "selectNextColumnExtendSelection",
  817. "shift KP_RIGHT", "selectNextColumnExtendSelection",
  818. "shift LEFT", "selectPreviousColumnExtendSelection",
  819. "shift KP_LEFT", "selectPreviousColumnExtendSelection",
  820. "shift DOWN", "selectNextRowExtendSelection",
  821. "shift KP_DOWN", "selectNextRowExtendSelection",
  822. "shift UP", "selectPreviousRowExtendSelection",
  823. "shift KP_UP", "selectPreviousRowExtendSelection",
  824. "PAGE_UP", "scrollUpChangeSelection",
  825. "PAGE_DOWN", "scrollDownChangeSelection",
  826. "HOME", "selectFirstColumn",
  827. "END", "selectLastColumn",
  828. "shift PAGE_UP", "scrollUpExtendSelection",
  829. "shift PAGE_DOWN", "scrollDownExtendSelection",
  830. "shift HOME", "selectFirstColumnExtendSelection",
  831. "shift END", "selectLastColumnExtendSelection",
  832. "ctrl PAGE_UP", "scrollLeftChangeSelection",
  833. "ctrl PAGE_DOWN", "scrollRightChangeSelection",
  834. "ctrl HOME", "selectFirstRow",
  835. "ctrl END", "selectLastRow",
  836. "ctrl shift PAGE_UP", "scrollRightExtendSelection",
  837. "ctrl shift PAGE_DOWN", "scrollLeftExtendSelection",
  838. "ctrl shift HOME", "selectFirstRowExtendSelection",
  839. "ctrl shift END", "selectLastRowExtendSelection",
  840. "TAB", "selectNextColumnCell",
  841. "shift TAB", "selectPreviousColumnCell",
  842. "ENTER", "selectNextRowCell",
  843. "shift ENTER", "selectPreviousRowCell",
  844. "ctrl A", "selectAll",
  845. "ESCAPE", "cancel",
  846. "F2", "startEditing"
  847. }),
  848. "TableHeader.font", userTextValue,
  849. "TableHeader.cellBorder", new UIDefaults.ProxyLazyValue(
  850. "javax.swing.plaf.metal.MetalBorders$TableHeaderBorder"),
  851. // MenuBar
  852. "MenuBar.border", menuBarBorder,
  853. "MenuBar.font", menuTextValue,
  854. "MenuBar.windowBindings", new Object[] {
  855. "F10", "takeFocus" },
  856. // Menu
  857. "Menu.border", menuItemBorder,
  858. "Menu.borderPainted", Boolean.TRUE,
  859. "Menu.menuPopupOffsetX", new Integer(0),
  860. "Menu.menuPopupOffsetY", new Integer(0),
  861. "Menu.submenuPopupOffsetX", new Integer(-4),
  862. "Menu.submenuPopupOffsetY", new Integer(-3),
  863. "Menu.font", menuTextValue,
  864. "Menu.selectionForeground", getMenuSelectedForeground(),
  865. "Menu.selectionBackground", getMenuSelectedBackground(),
  866. "Menu.disabledForeground", getMenuDisabledForeground(),
  867. "Menu.acceleratorFont", subTextValue,
  868. "Menu.acceleratorForeground", getAcceleratorForeground(),
  869. "Menu.acceleratorSelectionForeground", getAcceleratorSelectedForeground(),
  870. "Menu.checkIcon", new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getMenuItemCheckIcon"),
  871. "Menu.arrowIcon", new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getMenuArrowIcon"),
  872. // Menu Item
  873. "MenuItem.border", menuItemBorder,
  874. "MenuItem.borderPainted", Boolean.TRUE,
  875. "MenuItem.font", menuTextValue,
  876. "MenuItem.selectionForeground", getMenuSelectedForeground(),
  877. "MenuItem.selectionBackground", getMenuSelectedBackground(),
  878. "MenuItem.disabledForeground", getMenuDisabledForeground(),
  879. "MenuItem.acceleratorFont", subTextValue,
  880. "MenuItem.acceleratorForeground", getAcceleratorForeground(),
  881. "MenuItem.acceleratorSelectionForeground", getAcceleratorSelectedForeground(),
  882. "MenuItem.acceleratorDelimiter", menuItemAcceleratorDelimiter,
  883. "MenuItem.checkIcon", new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getMenuItemCheckIcon"),
  884. "MenuItem.arrowIcon", new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getMenuItemArrowIcon"),
  885. // Menu Item Auditory Cue Mapping
  886. "MenuItem.commandSound", "sounds/MenuItemCommand.wav",
  887. // OptionPane.
  888. "OptionPane.windowBindings", new Object[] {
  889. "ESCAPE", "close" },
  890. // Option Pane Auditory Cue Mappings
  891. "OptionPane.informationSound", "sounds/OptionPaneInformation.wav",
  892. "OptionPane.warningSound", "sounds/OptionPaneWarning.wav",
  893. "OptionPane.errorSound", "sounds/OptionPaneError.wav",
  894. "OptionPane.questionSound", "sounds/OptionPaneQuestion.wav",
  895. // Option Pane Special Dialog Colors, used when MetalRootPaneUI
  896. // is providing window manipulation widgets.
  897. "OptionPane.errorDialog.border.background",
  898. new ColorUIResource(153, 51, 51),
  899. "OptionPane.errorDialog.titlePane.foreground",
  900. new ColorUIResource(51, 0, 0),
  901. "OptionPane.errorDialog.titlePane.background",
  902. new ColorUIResource(255, 153, 153),
  903. "OptionPane.errorDialog.titlePane.shadow",
  904. new ColorUIResource(204, 102, 102),
  905. "OptionPane.questionDialog.border.background",
  906. new ColorUIResource(51, 102, 51),
  907. "OptionPane.questionDialog.titlePane.foreground",
  908. new ColorUIResource(0, 51, 0),
  909. "OptionPane.questionDialog.titlePane.background",
  910. new ColorUIResource(153, 204, 153),
  911. "OptionPane.questionDialog.titlePane.shadow",
  912. new ColorUIResource(102, 153, 102),
  913. "OptionPane.warningDialog.border.background",
  914. new ColorUIResource(153, 102, 51),
  915. "OptionPane.warningDialog.titlePane.foreground",
  916. new ColorUIResource(102, 51, 0),
  917. "OptionPane.warningDialog.titlePane.background",
  918. new ColorUIResource(255, 204, 153),
  919. "OptionPane.warningDialog.titlePane.shadow",
  920. new ColorUIResource(204, 153, 102),
  921. // OptionPane fonts are defined below
  922. // Separator
  923. "Separator.background", getSeparatorBackground(),
  924. "Separator.foreground", getSeparatorForeground(),
  925. // Popup Menu
  926. "PopupMenu.border", popupMenuBorder,
  927. // Popup Menu Auditory Cue Mappings
  928. "PopupMenu.popupSound", "sounds/PopupMenuPopup.wav",
  929. "PopupMenu.font", menuTextValue,
  930. // CB & RB Menu Item
  931. "CheckBoxMenuItem.border", menuItemBorder,
  932. "CheckBoxMenuItem.borderPainted", Boolean.TRUE,
  933. "CheckBoxMenuItem.font", menuTextValue,
  934. "CheckBoxMenuItem.selectionForeground", getMenuSelectedForeground(),
  935. "CheckBoxMenuItem.selectionBackground", getMenuSelectedBackground(),
  936. "CheckBoxMenuItem.disabledForeground", getMenuDisabledForeground(),
  937. "CheckBoxMenuItem.acceleratorFont", subTextValue,
  938. "CheckBoxMenuItem.acceleratorForeground", getAcceleratorForeground(),
  939. "CheckBoxMenuItem.acceleratorSelectionForeground", getAcceleratorSelectedForeground(),
  940. "CheckBoxMenuItem.checkIcon", new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getCheckBoxMenuItemIcon"),
  941. "CheckBoxMenuItem.arrowIcon", new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getMenuItemArrowIcon"),
  942. "CheckBoxMenuItem.commandSound", "sounds/MenuItemCommand.wav",
  943. "RadioButtonMenuItem.border", menuItemBorder,
  944. "RadioButtonMenuItem.borderPainted", Boolean.TRUE,
  945. "RadioButtonMenuItem.font", menuTextValue,
  946. "RadioButtonMenuItem.selectionForeground", getMenuSelectedForeground(),
  947. "RadioButtonMenuItem.selectionBackground", getMenuSelectedBackground(),
  948. "RadioButtonMenuItem.disabledForeground", getMenuDisabledForeground(),
  949. "RadioButtonMenuItem.acceleratorFont", subTextValue,
  950. "RadioButtonMenuItem.acceleratorForeground", getAcceleratorForeground(),
  951. "RadioButtonMenuItem.acceleratorSelectionForeground", getAcceleratorSelectedForeground(),
  952. "RadioButtonMenuItem.checkIcon", new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getRadioButtonMenuItemIcon"),
  953. "RadioButtonMenuItem.arrowIcon", new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getMenuItemArrowIcon"),
  954. "RadioButtonMenuItem.commandSound", "sounds/MenuItemCommand.wav",
  955. "Spinner.ancestorInputMap",
  956. new UIDefaults.LazyInputMap(new Object[] {
  957. "UP", "increment",
  958. "KP_UP", "increment",
  959. "DOWN", "decrement",
  960. "KP_DOWN", "decrement",
  961. }),
  962. "Spinner.arrowButtonInsets", new Insets(0, 0, 0, 0),
  963. "Spinner.border", textFieldBorder,
  964. "Spinner.arrowButtonBorder", buttonBorder,
  965. "Spinner.font", controlTextValue,
  966. // SplitPane
  967. "SplitPane.dividerSize", new Integer(10),
  968. "SplitPane.ancestorInputMap",
  969. new UIDefaults.LazyInputMap(new Object[] {
  970. "UP", "negativeIncrement",
  971. "DOWN", "positiveIncrement",
  972. "LEFT", "negativeIncrement",
  973. "RIGHT", "positiveIncrement",
  974. "KP_UP", "negativeIncrement",
  975. "KP_DOWN", "positiveIncrement",
  976. "KP_LEFT", "negativeIncrement",
  977. "KP_RIGHT", "positiveIncrement",
  978. "HOME", "selectMin",
  979. "END", "selectMax",
  980. "F8", "startResize",
  981. "F6", "toggleFocus",
  982. "ctrl TAB", "focusOutForward",
  983. "ctrl shift TAB", "focusOutBackward"
  984. }),
  985. // Tree
  986. // Tree.font was mapped to system font pre 1.4.1
  987. "Tree.font", userTextValue,
  988. "Tree.textBackground", getWindowBackground(),
  989. "Tree.selectionBorderColor", MetalLookAndFeel.getFocusColor(),
  990. "Tree.openIcon", new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getTreeFolderIcon"),
  991. "Tree.closedIcon", new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getTreeFolderIcon"),
  992. "Tree.leafIcon", new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalIconFactory", "getTreeLeafIcon"),
  993. "Tree.expandedIcon", new UIDefaults.ProxyLazyValue(
  994. "javax.swing.plaf.metal.MetalIconFactory",
  995. "getTreeControlIcon",
  996. new Object[] {Boolean.valueOf(MetalIconFactory.DARK)}),
  997. "Tree.collapsedIcon", new UIDefaults.ProxyLazyValue(
  998. "javax.swing.plaf.metal.MetalIconFactory",
  999. "getTreeControlIcon",
  1000. new Object[] {Boolean.valueOf( MetalIconFactory.LIGHT )}),
  1001. "Tree.line", getPrimaryControl(), // horiz lines
  1002. "Tree.hash", getPrimaryControl(), // legs
  1003. "Tree.rowHeight", new Integer(0),
  1004. "Tree.focusInputMap",
  1005. new UIDefaults.LazyInputMap(new Object[] {
  1006. "ctrl C", "copy",
  1007. "ctrl V", "paste",
  1008. "ctrl X", "cut",
  1009. "COPY", "copy",
  1010. "PASTE", "paste",
  1011. "CUT", "cut",
  1012. "UP", "selectPrevious",
  1013. "KP_UP", "selectPrevious",
  1014. "shift UP", "selectPreviousExtendSelection",
  1015. "shift KP_UP", "selectPreviousExtendSelection",
  1016. "DOWN", "selectNext",
  1017. "KP_DOWN", "selectNext",
  1018. "shift DOWN", "selectNextExtendSelection",
  1019. "shift KP_DOWN", "selectNextExtendSelection",
  1020. "RIGHT", "selectChild",
  1021. "KP_RIGHT", "selectChild",
  1022. "LEFT", "selectParent",
  1023. "KP_LEFT", "selectParent",
  1024. "PAGE_UP", "scrollUpChangeSelection",
  1025. "shift PAGE_UP", "scrollUpExtendSelection",
  1026. "PAGE_DOWN", "scrollDownChangeSelection",
  1027. "shift PAGE_DOWN", "scrollDownExtendSelection",
  1028. "HOME", "selectFirst",
  1029. "shift HOME", "selectFirstExtendSelection",
  1030. "END", "selectLast",
  1031. "shift END", "selectLastExtendSelection",
  1032. "F2", "startEditing",
  1033. "ctrl A", "selectAll",
  1034. "ctrl SLASH", "selectAll",
  1035. "ctrl BACK_SLASH", "clearSelection",
  1036. "ctrl SPACE", "toggleSelectionPreserveAnchor",
  1037. "shift SPACE", "extendSelection",
  1038. "ctrl HOME", "selectFirstChangeLead",
  1039. "ctrl END", "selectLastChangeLead",
  1040. "ctrl UP", "selectPreviousChangeLead",
  1041. "ctrl KP_UP", "selectPreviousChangeLead",
  1042. "ctrl DOWN", "selectNextChangeLead",
  1043. "ctrl KP_DOWN", "selectNextChangeLead",
  1044. "ctrl PAGE_DOWN", "scrollDownChangeLead",
  1045. "ctrl shift PAGE_DOWN", "scrollDownExtendSelection",
  1046. "ctrl PAGE_UP", "scrollUpChangeLead",
  1047. "ctrl shift PAGE_UP", "scrollUpExtendSelection",
  1048. "ctrl LEFT", "scrollLeft",
  1049. "ctrl KP_LEFT", "scrollLeft",
  1050. "ctrl RIGHT", "scrollRight",
  1051. "ctrl KP_RIGHT", "scrollRight",
  1052. "SPACE", "toggleSelectionPreserveAnchor",
  1053. }),
  1054. "Tree.ancestorInputMap",
  1055. new UIDefaults.LazyInputMap(new Object[] {
  1056. "ESCAPE", "cancel"
  1057. }),
  1058. // ToolBar
  1059. "ToolBar.border", toolBarBorder,
  1060. "ToolBar.background", getMenuBackground(),
  1061. "ToolBar.foreground", getMenuForeground(),
  1062. "ToolBar.font", menuTextValue,
  1063. "ToolBar.dockingBackground", getMenuBackground(),
  1064. "ToolBar.floatingBackground", getMenuBackground(),
  1065. "ToolBar.dockingForeground", getPrimaryControlDarkShadow(),
  1066. "ToolBar.floatingForeground", getPrimaryControl(),
  1067. "ToolBar.ancestorInputMap",
  1068. new UIDefaults.LazyInputMap(new Object[] {
  1069. "UP", "navigateUp",
  1070. "KP_UP", "navigateUp",
  1071. "DOWN", "navigateDown",
  1072. "KP_DOWN", "navigateDown",
  1073. "LEFT", "navigateLeft",
  1074. "KP_LEFT", "navigateLeft",
  1075. "RIGHT", "navigateRight",
  1076. "KP_RIGHT", "navigateRight"
  1077. }),
  1078. // RootPane
  1079. "RootPane.frameBorder", new MetalLazyValue(
  1080. "javax.swing.plaf.metal.MetalBorders$FrameBorder"),
  1081. "RootPane.plainDialogBorder", dialogBorder,
  1082. "RootPane.informationDialogBorder", dialogBorder,
  1083. "RootPane.errorDialogBorder", new MetalLazyValue(
  1084. "javax.swing.plaf.metal.MetalBorders$ErrorDialogBorder"),
  1085. "RootPane.colorChooserDialogBorder", questionDialogBorder,
  1086. "RootPane.fileChooserDialogBorder", questionDialogBorder,
  1087. "RootPane.questionDialogBorder", questionDialogBorder,
  1088. "RootPane.warningDialogBorder", new MetalLazyValue(
  1089. "javax.swing.plaf.metal.MetalBorders$WarningDialogBorder"),
  1090. // These bindings are only enabled when there is a default
  1091. // button set on the rootpane.
  1092. "RootPane.defaultButtonWindowKeyBindings", new Object[] {
  1093. "ENTER", "press",
  1094. "released ENTER", "release",
  1095. "ctrl ENTER", "press",
  1096. "ctrl released ENTER", "release"
  1097. },
  1098. };
  1099. table.putDefaults(defaults);
  1100. if (isWindows() && useSystemFonts() && theme.isSystemTheme()) {
  1101. Toolkit kit = Toolkit.getDefaultToolkit();
  1102. Object messageFont = new MetalFontDesktopProperty(
  1103. "win.messagebox.font.height", kit, MetalTheme.
  1104. CONTROL_TEXT_FONT);
  1105. defaults = new Object[] {
  1106. "OptionPane.messageFont", messageFont,
  1107. "OptionPane.buttonFont", messageFont,
  1108. };
  1109. table.putDefaults(defaults);
  1110. }
  1111. }
  1112. protected void createDefaultTheme() {
  1113. getCurrentTheme();
  1114. }
  1115. public UIDefaults getDefaults() {
  1116. // PENDING: move this to initialize when API changes are allowed
  1117. METAL_LOOK_AND_FEEL_INITED = true;
  1118. createDefaultTheme();
  1119. UIDefaults table = super.getDefaults();
  1120. currentTheme.addCustomEntriesToTable(table);
  1121. currentTheme.install();
  1122. return table;
  1123. }
  1124. /**
  1125. * <p>
  1126. * Invoked when the user attempts an invalid operation,
  1127. * such as pasting into an uneditable <code>JTextField</code>
  1128. * that has focus.
  1129. * </p>
  1130. * <p>
  1131. * If the user has enabled visual error indication on
  1132. * the desktop, this method will flash the caption bar
  1133. * of the active window. The user can also set the
  1134. * property awt.visualbell=true to achieve the same
  1135. * results.
  1136. * </p>
  1137. *
  1138. * @param component Component the error occured in, may be
  1139. * null indicating the error condition is
  1140. * not directly associated with a
  1141. * <code>Component</code>.
  1142. *
  1143. * @see javax.swing.LookAndFeel#provideErrorFeedback
  1144. */
  1145. public void provideErrorFeedback(Component component) {
  1146. super.provideErrorFeedback(component);
  1147. }
  1148. public static void setCurrentTheme(MetalTheme theme) {
  1149. // NOTE: because you need to recreate the look and feel after
  1150. // this step, we don't bother blowing away any potential windows
  1151. // values.
  1152. if (theme == null) {
  1153. throw new NullPointerException("Can't have null theme");
  1154. }
  1155. currentTheme = theme;
  1156. cachedAppContext = AppContext.getAppContext();
  1157. cachedAppContext.put( "currentMetalTheme", theme );
  1158. }
  1159. private static MetalTheme getCurrentTheme() {
  1160. AppContext context = AppContext.getAppContext();
  1161. if ( cachedAppContext != context ) {
  1162. currentTheme = (MetalTheme)context.get( "currentMetalTheme" );
  1163. if (currentTheme == null) {
  1164. // This will happen in two cases:
  1165. // . When MetalLookAndFeel is first being initialized.
  1166. // . When a new AppContext has been created that hasn't
  1167. // triggered UIManager to load a LAF. Rather than invoke
  1168. // a method on the UIManager, which would trigger the loading
  1169. // of a potentially different LAF, we directly set the
  1170. // Theme here.
  1171. if (useHighContrastTheme()) {
  1172. currentTheme = new MetalHighContrastTheme();
  1173. }
  1174. else {
  1175. currentTheme = new DefaultMetalTheme();
  1176. }
  1177. setCurrentTheme(currentTheme);
  1178. }
  1179. cachedAppContext = context;
  1180. }
  1181. return currentTheme;
  1182. }
  1183. public static FontUIResource getControlTextFont() { return getCurrentTheme().getControlTextFont();}
  1184. public static FontUIResource getSystemTextFont() { return getCurrentTheme().getSystemTextFont();}
  1185. public static FontUIResource getUserTextFont() { return getCurrentTheme().getUserTextFont();}
  1186. public static FontUIResource getMenuTextFont() { return getCurrentTheme().getMenuTextFont();}
  1187. public static FontUIResource getWindowTitleFont() { return getCurrentTheme().getWindowTitleFont();}
  1188. public static FontUIResource getSubTextFont() { return getCurrentTheme().getSubTextFont();}
  1189. public static ColorUIResource getDesktopColor() { return getCurrentTheme().getDesktopColor(); }
  1190. public static ColorUIResource getFocusColor() { return getCurrentTheme().getFocusColor(); }
  1191. public static ColorUIResource getWhite() { return getCurrentTheme().getWhite(); }
  1192. public static ColorUIResource getBlack() { return getCurrentTheme().getBlack(); }
  1193. public static ColorUIResource getControl() { return getCurrentTheme().getControl(); }
  1194. public static ColorUIResource getControlShadow() { return getCurrentTheme().getControlShadow(); }
  1195. public static ColorUIResource getControlDarkShadow() { return getCurrentTheme().getControlDarkShadow(); }
  1196. public static ColorUIResource getControlInfo() { return getCurrentTheme().getControlInfo(); }
  1197. public static ColorUIResource getControlHighlight() { return getCurrentTheme().getControlHighlight(); }
  1198. public static ColorUIResource getControlDisabled() { return getCurrentTheme().getControlDisabled(); }
  1199. public static ColorUIResource getPrimaryControl() { return getCurrentTheme().getPrimaryControl(); }
  1200. public static ColorUIResource getPrimaryControlShadow() { return getCurrentTheme().getPrimaryControlShadow(); }
  1201. public static ColorUIResource getPrimaryControlDarkShadow() { return getCurrentTheme().getPrimaryControlDarkShadow(); }
  1202. public static ColorUIResource getPrimaryControlInfo() { return getCurrentTheme().getPrimaryControlInfo(); }
  1203. public static ColorUIResource getPrimaryControlHighlight() { return getCurrentTheme().getPrimaryControlHighlight(); }
  1204. public static ColorUIResource getSystemTextColor() { return getCurrentTheme().getSystemTextColor(); }
  1205. public static ColorUIResource getControlTextColor() { return getCurrentTheme().getControlTextColor(); }
  1206. public static ColorUIResource getInactiveControlTextColor() { return getCurrentTheme().getInactiveControlTextColor(); }
  1207. public static ColorUIResource getInactiveSystemTextColor() { return getCurrentTheme().getInactiveSystemTextColor(); }
  1208. public static ColorUIResource getUserTextColor() { return getCurrentTheme().getUserTextColor(); }
  1209. public static ColorUIResource getTextHighlightColor() { return getCurrentTheme().getTextHighlightColor(); }
  1210. public static ColorUIResource getHighlightedTextColor() { return getCurrentTheme().getHighlightedTextColor(); }
  1211. public static ColorUIResource getWindowBackground() { return getCurrentTheme().getWindowBackground(); }
  1212. public static ColorUIResource getWindowTitleBackground() { return getCurrentTheme().getWindowTitleBackground(); }
  1213. public static ColorUIResource getWindowTitleForeground() { return getCurrentTheme().getWindowTitleForeground(); }
  1214. public static ColorUIResource getWindowTitleInactiveBackground() { return getCurrentTheme().getWindowTitleInactiveBackground(); }
  1215. public static ColorUIResource getWindowTitleInactiveForeground() { return getCurrentTheme().getWindowTitleInactiveForeground(); }
  1216. public static ColorUIResource getMenuBackground() { return getCurrentTheme().getMenuBackground(); }
  1217. public static ColorUIResource getMenuForeground() { return getCurrentTheme().getMenuForeground(); }
  1218. public static ColorUIResource getMenuSelectedBackground() { return getCurrentTheme().getMenuSelectedBackground(); }
  1219. public static ColorUIResource getMenuSelectedForeground() { return getCurrentTheme().getMenuSelectedForeground(); }
  1220. public static ColorUIResource getMenuDisabledForeground() { return getCurrentTheme().getMenuDisabledForeground(); }
  1221. public static ColorUIResource getSeparatorBackground() { return getCurrentTheme().getSeparatorBackground(); }
  1222. public static ColorUIResource getSeparatorForeground() { return getCurrentTheme().getSeparatorForeground(); }
  1223. public static ColorUIResource getAcceleratorForeground() { return getCurrentTheme().getAcceleratorForeground(); }
  1224. public static ColorUIResource getAcceleratorSelectedForeground() { return getCurrentTheme().getAcceleratorSelectedForeground(); }
  1225. /**
  1226. * MetalLazyValue is a slimmed down version of <code>ProxyLaxyValue</code>.
  1227. * The code is duplicate so that it can get at the package private
  1228. * classes in metal.
  1229. */
  1230. private static class MetalLazyValue implements UIDefaults.LazyValue {
  1231. /**
  1232. * Name of the class to create.
  1233. */
  1234. private String className;
  1235. MetalLazyValue(String name) {
  1236. this.className = name;
  1237. }
  1238. public Object createValue(UIDefaults table) {
  1239. try {
  1240. Class c = Class.forName(className);
  1241. return c.newInstance();
  1242. } catch (ClassNotFoundException cnfe) {
  1243. } catch (InstantiationException ie) {
  1244. } catch (IllegalAccessException iae) {
  1245. }
  1246. return null;
  1247. }
  1248. }
  1249. /**
  1250. * FontActiveValue redirects to the appropriate metal theme method.
  1251. */
  1252. private static class FontActiveValue implements UIDefaults.ActiveValue {
  1253. private int type;
  1254. private MetalTheme theme;
  1255. FontActiveValue(MetalTheme theme, int type) {
  1256. this.theme = theme;
  1257. this.type = type;
  1258. }
  1259. public Object createValue(UIDefaults table) {
  1260. Object value = null;
  1261. switch (type) {
  1262. case MetalTheme.CONTROL_TEXT_FONT:
  1263. value = theme.getControlTextFont();
  1264. break;
  1265. case MetalTheme.SYSTEM_TEXT_FONT:
  1266. value = theme.getSystemTextFont();
  1267. break;
  1268. case MetalTheme.USER_TEXT_FONT:
  1269. value = theme.getUserTextFont();
  1270. break;
  1271. case MetalTheme.MENU_TEXT_FONT:
  1272. value = theme.getMenuTextFont();
  1273. break;
  1274. case MetalTheme.WINDOW_TITLE_FONT:
  1275. value = theme.getWindowTitleFont();
  1276. break;
  1277. case MetalTheme.SUB_TEXT_FONT:
  1278. value = theme.getSubTextFont();
  1279. break;
  1280. }
  1281. return value;
  1282. }
  1283. }
  1284. }