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