1. /*
  2. * @(#)BasicLookAndFeel.java 1.208 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.basic;
  8. import java.awt.Font;
  9. import java.awt.Color;
  10. import java.awt.SystemColor;
  11. import java.awt.event.*;
  12. import java.awt.Insets;
  13. import java.awt.Component;
  14. import java.awt.Container;
  15. import java.awt.FocusTraversalPolicy;
  16. import java.net.URL;
  17. import java.io.*;
  18. import java.awt.Dimension;
  19. import java.awt.KeyboardFocusManager;
  20. import java.util.*;
  21. import java.lang.reflect.*;
  22. import javax.sound.sampled.*;
  23. import javax.swing.LookAndFeel;
  24. import javax.swing.AbstractAction;
  25. import javax.swing.Action;
  26. import javax.swing.ActionMap;
  27. import javax.swing.BorderFactory;
  28. import javax.swing.JComponent;
  29. import javax.swing.ImageIcon;
  30. import javax.swing.UIDefaults;
  31. import javax.swing.UIManager;
  32. import javax.swing.KeyStroke;
  33. import javax.swing.JTextField;
  34. import javax.swing.DefaultListCellRenderer;
  35. import javax.swing.FocusManager;
  36. import javax.swing.LayoutFocusTraversalPolicy;
  37. import javax.swing.SwingUtilities;
  38. import javax.swing.border.*;
  39. import javax.swing.plaf.*;
  40. import javax.swing.text.JTextComponent;
  41. import javax.swing.text.DefaultEditorKit;
  42. /**
  43. * Implements the a standard base LookAndFeel class from which
  44. * standard desktop LookAndFeel classes (JLF, Mac, Windows, etc.)
  45. * can be derived. This class cannot be instantiated directly,
  46. * however the UI classes "Basic" defines can be.
  47. * <p>
  48. * <strong>Warning:</strong>
  49. * Serialized objects of this class will not be compatible with
  50. * future Swing releases. The current serialization support is
  51. * appropriate for short term storage or RMI between applications running
  52. * the same version of Swing. As of 1.4, support for long term storage
  53. * of all JavaBeans<sup><font size="-2">TM</font></sup>
  54. * has been added to the <code>java.beans</code> package.
  55. * Please see {@link java.beans.XMLEncoder}.
  56. *
  57. * @version 1.208 01/23/03
  58. * @author unattributed
  59. */
  60. public abstract class BasicLookAndFeel extends LookAndFeel implements Serializable
  61. {
  62. /**
  63. * Lock used when manipulating clipPlaying.
  64. */
  65. private Object audioLock = new Object();
  66. /**
  67. * The Clip that is currently playing (set in AudioAction).
  68. */
  69. private Clip clipPlaying;
  70. public UIDefaults getDefaults() {
  71. UIDefaults table = new UIDefaults();
  72. initClassDefaults(table);
  73. initSystemColorDefaults(table);
  74. initComponentDefaults(table);
  75. return table;
  76. }
  77. /**
  78. * Initialize the uiClassID to BasicComponentUI mapping.
  79. * The JComponent classes define their own uiClassID constants
  80. * (see AbstractComponent.getUIClassID). This table must
  81. * map those constants to a BasicComponentUI class of the
  82. * appropriate type.
  83. *
  84. * @see #getDefaults
  85. */
  86. protected void initClassDefaults(UIDefaults table)
  87. {
  88. String basicPackageName = "javax.swing.plaf.basic.";
  89. Object[] uiDefaults = {
  90. "ButtonUI", basicPackageName + "BasicButtonUI",
  91. "CheckBoxUI", basicPackageName + "BasicCheckBoxUI",
  92. "ColorChooserUI", basicPackageName + "BasicColorChooserUI",
  93. "FormattedTextFieldUI", basicPackageName + "BasicFormattedTextFieldUI",
  94. "MenuBarUI", basicPackageName + "BasicMenuBarUI",
  95. "MenuUI", basicPackageName + "BasicMenuUI",
  96. "MenuItemUI", basicPackageName + "BasicMenuItemUI",
  97. "CheckBoxMenuItemUI", basicPackageName + "BasicCheckBoxMenuItemUI",
  98. "RadioButtonMenuItemUI", basicPackageName + "BasicRadioButtonMenuItemUI",
  99. "RadioButtonUI", basicPackageName + "BasicRadioButtonUI",
  100. "ToggleButtonUI", basicPackageName + "BasicToggleButtonUI",
  101. "PopupMenuUI", basicPackageName + "BasicPopupMenuUI",
  102. "ProgressBarUI", basicPackageName + "BasicProgressBarUI",
  103. "ScrollBarUI", basicPackageName + "BasicScrollBarUI",
  104. "ScrollPaneUI", basicPackageName + "BasicScrollPaneUI",
  105. "SplitPaneUI", basicPackageName + "BasicSplitPaneUI",
  106. "SliderUI", basicPackageName + "BasicSliderUI",
  107. "SeparatorUI", basicPackageName + "BasicSeparatorUI",
  108. "SpinnerUI", basicPackageName + "BasicSpinnerUI",
  109. "ToolBarSeparatorUI", basicPackageName + "BasicToolBarSeparatorUI",
  110. "PopupMenuSeparatorUI", basicPackageName + "BasicPopupMenuSeparatorUI",
  111. "TabbedPaneUI", basicPackageName + "BasicTabbedPaneUI",
  112. "TextAreaUI", basicPackageName + "BasicTextAreaUI",
  113. "TextFieldUI", basicPackageName + "BasicTextFieldUI",
  114. "PasswordFieldUI", basicPackageName + "BasicPasswordFieldUI",
  115. "TextPaneUI", basicPackageName + "BasicTextPaneUI",
  116. "EditorPaneUI", basicPackageName + "BasicEditorPaneUI",
  117. "TreeUI", basicPackageName + "BasicTreeUI",
  118. "LabelUI", basicPackageName + "BasicLabelUI",
  119. "ListUI", basicPackageName + "BasicListUI",
  120. "ToolBarUI", basicPackageName + "BasicToolBarUI",
  121. "ToolTipUI", basicPackageName + "BasicToolTipUI",
  122. "ComboBoxUI", basicPackageName + "BasicComboBoxUI",
  123. "TableUI", basicPackageName + "BasicTableUI",
  124. "TableHeaderUI", basicPackageName + "BasicTableHeaderUI",
  125. "InternalFrameUI", basicPackageName + "BasicInternalFrameUI",
  126. "DesktopPaneUI", basicPackageName + "BasicDesktopPaneUI",
  127. "DesktopIconUI", basicPackageName + "BasicDesktopIconUI",
  128. "OptionPaneUI", basicPackageName + "BasicOptionPaneUI",
  129. "PanelUI", basicPackageName + "BasicPanelUI",
  130. "ViewportUI", basicPackageName + "BasicViewportUI",
  131. "RootPaneUI", basicPackageName + "BasicRootPaneUI",
  132. };
  133. table.putDefaults(uiDefaults);
  134. }
  135. /**
  136. * Load the SystemColors into the defaults table. The keys
  137. * for SystemColor defaults are the same as the names of
  138. * the public fields in SystemColor. If the table is being
  139. * created on a native Windows platform we use the SystemColor
  140. * values, otherwise we create color objects whose values match
  141. * the defaults Windows95 colors.
  142. */
  143. protected void initSystemColorDefaults(UIDefaults table)
  144. {
  145. String[] defaultSystemColors = {
  146. "desktop", "#005C5C", /* Color of the desktop background */
  147. "activeCaption", "#000080", /* Color for captions (title bars) when they are active. */
  148. "activeCaptionText", "#FFFFFF", /* Text color for text in captions (title bars). */
  149. "activeCaptionBorder", "#C0C0C0", /* Border color for caption (title bar) window borders. */
  150. "inactiveCaption", "#808080", /* Color for captions (title bars) when not active. */
  151. "inactiveCaptionText", "#C0C0C0", /* Text color for text in inactive captions (title bars). */
  152. "inactiveCaptionBorder", "#C0C0C0", /* Border color for inactive caption (title bar) window borders. */
  153. "window", "#FFFFFF", /* Default color for the interior of windows */
  154. "windowBorder", "#000000", /* ??? */
  155. "windowText", "#000000", /* ??? */
  156. "menu", "#C0C0C0", /* Background color for menus */
  157. "menuText", "#000000", /* Text color for menus */
  158. "text", "#C0C0C0", /* Text background color */
  159. "textText", "#000000", /* Text foreground color */
  160. "textHighlight", "#000080", /* Text background color when selected */
  161. "textHighlightText", "#FFFFFF", /* Text color when selected */
  162. "textInactiveText", "#808080", /* Text color when disabled */
  163. "control", "#C0C0C0", /* Default color for controls (buttons, sliders, etc) */
  164. "controlText", "#000000", /* Default color for text in controls */
  165. "controlHighlight", "#C0C0C0", /* Specular highlight (opposite of the shadow) */
  166. "controlLtHighlight", "#FFFFFF", /* Highlight color for controls */
  167. "controlShadow", "#808080", /* Shadow color for controls */
  168. "controlDkShadow", "#000000", /* Dark shadow color for controls */
  169. "scrollbar", "#E0E0E0", /* Scrollbar background (usually the "track") */
  170. "info", "#FFFFE1", /* ??? */
  171. "infoText", "#000000" /* ??? */
  172. };
  173. loadSystemColors(table, defaultSystemColors, isNativeLookAndFeel());
  174. }
  175. /**
  176. * If this is the native look and feel the initial values for the
  177. * system color properties are the same as the SystemColor constants.
  178. * If not we use the integer color values in the <code>systemColors</code>
  179. * argument.
  180. */
  181. protected void loadSystemColors(UIDefaults table, String[] systemColors, boolean useNative)
  182. {
  183. /* PENDING(hmuller) We don't load the system colors below because
  184. * they're not reliable. Hopefully we'll be able to do better in
  185. * a future version of AWT.
  186. */
  187. if (useNative) {
  188. for(int i = 0; i < systemColors.length; i += 2) {
  189. Color color = Color.black;
  190. try {
  191. String name = systemColors[i];
  192. color = (Color)(SystemColor.class.getField(name).get(null));
  193. } catch (Exception e) {
  194. }
  195. table.put(systemColors[i], new ColorUIResource(color));
  196. }
  197. } else {
  198. for(int i = 0; i < systemColors.length; i += 2) {
  199. Color color = Color.black;
  200. try {
  201. color = Color.decode(systemColors[i + 1]);
  202. }
  203. catch(NumberFormatException e) {
  204. e.printStackTrace();
  205. }
  206. table.put(systemColors[i], new ColorUIResource(color));
  207. }
  208. }
  209. }
  210. /**
  211. * Initialize the defaults table with the name of the ResourceBundle
  212. * used for getting localized defaults. Also initialize the default
  213. * locale used when no locale is passed into UIDefaults.get(). The
  214. * default locale should generally not be relied upon. It is here for
  215. * compatability with releases prior to 1.4.
  216. */
  217. private void initResourceBundle(UIDefaults table) {
  218. table.setDefaultLocale( Locale.getDefault() );
  219. table.addResourceBundle( "com.sun.swing.internal.plaf.basic.resources.basic" );
  220. }
  221. protected void initComponentDefaults(UIDefaults table)
  222. {
  223. initResourceBundle(table);
  224. // *** Shared Integers
  225. Integer fiveHundred = new Integer(500);
  226. // *** Shared Fonts
  227. Integer twelve = new Integer(12);
  228. Integer fontPlain = new Integer(Font.PLAIN);
  229. Integer fontBold = new Integer(Font.BOLD);
  230. Object dialogPlain12 = new UIDefaults.ProxyLazyValue(
  231. "javax.swing.plaf.FontUIResource",
  232. null,
  233. new Object[] {"Dialog", fontPlain, twelve});
  234. Object serifPlain12 = new UIDefaults.ProxyLazyValue(
  235. "javax.swing.plaf.FontUIResource",
  236. null,
  237. new Object[] {"Serif", fontPlain, twelve});
  238. Object sansSerifPlain12 = new UIDefaults.ProxyLazyValue(
  239. "javax.swing.plaf.FontUIResource",
  240. null,
  241. new Object[] {"SansSerif", fontPlain, twelve});
  242. Object monospacedPlain12 = new UIDefaults.ProxyLazyValue(
  243. "javax.swing.plaf.FontUIResource",
  244. null,
  245. new Object[] {"MonoSpaced", fontPlain, twelve});
  246. Object dialogBold12 = new UIDefaults.ProxyLazyValue(
  247. "javax.swing.plaf.FontUIResource",
  248. null,
  249. new Object[] {"Dialog", fontBold, twelve});
  250. // *** Shared Colors
  251. ColorUIResource red = new ColorUIResource(Color.red);
  252. ColorUIResource black = new ColorUIResource(Color.black);
  253. ColorUIResource white = new ColorUIResource(Color.white);
  254. ColorUIResource yellow = new ColorUIResource(Color.yellow);
  255. ColorUIResource gray = new ColorUIResource(Color.gray);
  256. ColorUIResource lightGray = new ColorUIResource(Color.lightGray);
  257. ColorUIResource darkGray = new ColorUIResource(Color.darkGray);
  258. ColorUIResource scrollBarTrack = new ColorUIResource(224, 224, 224);
  259. // *** Shared Insets
  260. InsetsUIResource zeroInsets = new InsetsUIResource(0,0,0,0);
  261. // *** Shared Borders
  262. Object marginBorder = new UIDefaults.ProxyLazyValue(
  263. "javax.swing.plaf.basic.BasicBorders$MarginBorder");
  264. Object etchedBorder = new UIDefaults.ProxyLazyValue(
  265. "javax.swing.plaf.BorderUIResource",
  266. "getEtchedBorderUIResource");
  267. Object loweredBevelBorder = new UIDefaults.ProxyLazyValue(
  268. "javax.swing.plaf.BorderUIResource",
  269. "getLoweredBevelBorderUIResource");
  270. Object popupMenuBorder = new UIDefaults.ProxyLazyValue(
  271. "javax.swing.plaf.basic.BasicBorders",
  272. "getInternalFrameBorder");
  273. Object blackLineBorder = new UIDefaults.ProxyLazyValue(
  274. "javax.swing.plaf.BorderUIResource",
  275. "getBlackLineBorderUIResource");
  276. Object focusCellHighlightBorder = new UIDefaults.ProxyLazyValue(
  277. "javax.swing.plaf.BorderUIResource$LineBorderUIResource",
  278. null,
  279. new Object[] {yellow});
  280. Object tableHeaderBorder = new UIDefaults.ProxyLazyValue(
  281. "javax.swing.plaf.BorderUIResource$BevelBorderUIResource",
  282. null,
  283. new Object[] { new Integer(BevelBorder.RAISED),
  284. table.getColor("controlLtHighlight"),
  285. table.getColor("control"),
  286. table.getColor("controlDkShadow"),
  287. table.getColor("controlShadow") });
  288. // *** Button value objects
  289. Object buttonBorder =
  290. new UIDefaults.ProxyLazyValue(
  291. "javax.swing.plaf.basic.BasicBorders",
  292. "getButtonBorder");
  293. Object buttonToggleBorder =
  294. new UIDefaults.ProxyLazyValue(
  295. "javax.swing.plaf.basic.BasicBorders",
  296. "getToggleButtonBorder");
  297. Object radioButtonBorder =
  298. new UIDefaults.ProxyLazyValue(
  299. "javax.swing.plaf.basic.BasicBorders",
  300. "getRadioButtonBorder");
  301. // *** FileChooser / FileView value objects
  302. Object newFolderIcon = LookAndFeel.makeIcon(getClass(), "icons/NewFolder.gif");
  303. Object upFolderIcon = LookAndFeel.makeIcon(getClass(), "icons/UpFolder.gif");
  304. Object homeFolderIcon = LookAndFeel.makeIcon(getClass(), "icons/HomeFolder.gif");
  305. Object detailsViewIcon = LookAndFeel.makeIcon(getClass(), "icons/DetailsView.gif");
  306. Object listViewIcon = LookAndFeel.makeIcon(getClass(), "icons/ListView.gif");
  307. Object directoryIcon = LookAndFeel.makeIcon(getClass(), "icons/Directory.gif");
  308. Object fileIcon = LookAndFeel.makeIcon(getClass(), "icons/File.gif");
  309. Object computerIcon = LookAndFeel.makeIcon(getClass(), "icons/Computer.gif");
  310. Object hardDriveIcon = LookAndFeel.makeIcon(getClass(), "icons/HardDrive.gif");
  311. Object floppyDriveIcon = LookAndFeel.makeIcon(getClass(), "icons/FloppyDrive.gif");
  312. // *** InternalFrame value objects
  313. Object internalFrameBorder = new UIDefaults.ProxyLazyValue(
  314. "javax.swing.plaf.basic.BasicBorders",
  315. "getInternalFrameBorder");
  316. // *** List value objects
  317. Object listCellRendererActiveValue = new UIDefaults.ActiveValue() {
  318. public Object createValue(UIDefaults table) {
  319. return new DefaultListCellRenderer.UIResource();
  320. }
  321. };
  322. // *** Menus value objects
  323. Object menuBarBorder =
  324. new UIDefaults.ProxyLazyValue(
  325. "javax.swing.plaf.basic.BasicBorders",
  326. "getMenuBarBorder");
  327. Object menuItemCheckIcon =
  328. new UIDefaults.ProxyLazyValue(
  329. "javax.swing.plaf.basic.BasicIconFactory",
  330. "getMenuItemCheckIcon");
  331. Object menuItemArrowIcon =
  332. new UIDefaults.ProxyLazyValue(
  333. "javax.swing.plaf.basic.BasicIconFactory",
  334. "getMenuItemArrowIcon");
  335. Object menuArrowIcon =
  336. new UIDefaults.ProxyLazyValue(
  337. "javax.swing.plaf.basic.BasicIconFactory",
  338. "getMenuArrowIcon");
  339. Object checkBoxIcon =
  340. new UIDefaults.ProxyLazyValue(
  341. "javax.swing.plaf.basic.BasicIconFactory",
  342. "getCheckBoxIcon");
  343. Object radioButtonIcon =
  344. new UIDefaults.ProxyLazyValue(
  345. "javax.swing.plaf.basic.BasicIconFactory",
  346. "getRadioButtonIcon");
  347. Object checkBoxMenuItemIcon =
  348. new UIDefaults.ProxyLazyValue(
  349. "javax.swing.plaf.basic.BasicIconFactory",
  350. "getCheckBoxMenuItemIcon");
  351. Object radioButtonMenuItemIcon =
  352. new UIDefaults.ProxyLazyValue(
  353. "javax.swing.plaf.basic.BasicIconFactory",
  354. "getRadioButtonMenuItemIcon");
  355. Object menuItemAcceleratorDelimiter = new String("+");
  356. // *** OptionPane value objects
  357. Object optionPaneMinimumSize = new DimensionUIResource(262, 90);
  358. Integer zero = new Integer(0);
  359. Object zeroBorder = new UIDefaults.ProxyLazyValue(
  360. "javax.swing.plaf.BorderUIResource$EmptyBorderUIResource",
  361. new Object[] {zero, zero, zero, zero});
  362. Integer ten = new Integer(10);
  363. Object optionPaneBorder = new UIDefaults.ProxyLazyValue(
  364. "javax.swing.plaf.BorderUIResource$EmptyBorderUIResource",
  365. new Object[] {ten, ten, twelve, ten});
  366. Object optionPaneButtonAreaBorder = new UIDefaults.ProxyLazyValue(
  367. "javax.swing.plaf.BorderUIResource$EmptyBorderUIResource",
  368. new Object[] {new Integer(6), zero, zero, zero});
  369. // *** ProgessBar value objects
  370. Object progressBarBorder =
  371. new UIDefaults.ProxyLazyValue(
  372. "javax.swing.plaf.basic.BasicBorders",
  373. "getProgressBarBorder");
  374. // ** ScrollBar value objects
  375. Object minimumThumbSize = new DimensionUIResource(8,8);
  376. Object maximumThumbSize = new DimensionUIResource(4096,4096);
  377. // ** Slider value objects
  378. Object sliderFocusInsets = new InsetsUIResource( 2, 2, 2, 2 );
  379. Object toolBarSeparatorSize = new DimensionUIResource( 10, 10 );
  380. // *** SplitPane value objects
  381. Object splitPaneBorder =
  382. new UIDefaults.ProxyLazyValue(
  383. "javax.swing.plaf.basic.BasicBorders",
  384. "getSplitPaneBorder");
  385. Object splitPaneDividerBorder =
  386. new UIDefaults.ProxyLazyValue(
  387. "javax.swing.plaf.basic.BasicBorders",
  388. "getSplitPaneDividerBorder");
  389. // ** TabbedBane value objects
  390. Object tabbedPaneTabInsets = new InsetsUIResource(0, 4, 1, 4);
  391. Object tabbedPaneTabPadInsets = new InsetsUIResource(2, 2, 2, 1);
  392. Object tabbedPaneTabAreaInsets = new InsetsUIResource(3, 2, 0, 2);
  393. Object tabbedPaneContentBorderInsets = new InsetsUIResource(2, 2, 3, 3);
  394. // *** Text value objects
  395. Object textFieldBorder =
  396. new UIDefaults.ProxyLazyValue(
  397. "javax.swing.plaf.basic.BasicBorders",
  398. "getTextFieldBorder");
  399. Object editorMargin = new InsetsUIResource(3,3,3,3);
  400. Object caretBlinkRate = fiveHundred;
  401. Integer four = new Integer(4);
  402. Object[] allAuditoryCues = new Object[] {
  403. "CheckBoxMenuItem.commandSound",
  404. "InternalFrame.closeSound",
  405. "InternalFrame.maximizeSound",
  406. "InternalFrame.minimizeSound",
  407. "InternalFrame.restoreDownSound",
  408. "InternalFrame.restoreUpSound",
  409. "MenuItem.commandSound",
  410. "OptionPane.errorSound",
  411. "OptionPane.informationSound",
  412. "OptionPane.questionSound",
  413. "OptionPane.warningSound",
  414. "PopupMenu.popupSound",
  415. "RadioButtonMenuItem.commandSound"};
  416. Object[] noAuditoryCues = new Object[] {"mute"};
  417. // *** Component Defaults
  418. Object[] defaults = {
  419. // *** Auditory Feedback
  420. "AuditoryCues.cueList", allAuditoryCues,
  421. "AuditoryCues.allAuditoryCues", allAuditoryCues,
  422. "AuditoryCues.noAuditoryCues", noAuditoryCues,
  423. // this key defines which of the various cues to render.
  424. // L&Fs that want auditory feedback NEED to override playList.
  425. "AuditoryCues.playList", null,
  426. // *** Buttons
  427. "Button.font", dialogPlain12,
  428. "Button.background", table.get("control"),
  429. "Button.foreground", table.get("controlText"),
  430. "Button.shadow", table.getColor("controlShadow"),
  431. "Button.darkShadow", table.getColor("controlDkShadow"),
  432. "Button.light", table.getColor("controlHighlight"),
  433. "Button.highlight", table.getColor("controlLtHighlight"),
  434. "Button.border", buttonBorder,
  435. "Button.margin", new InsetsUIResource(2, 14, 2, 14),
  436. "Button.textIconGap", four,
  437. "Button.textShiftOffset", zero,
  438. "Button.focusInputMap", new UIDefaults.LazyInputMap(new Object[] {
  439. "SPACE", "pressed",
  440. "released SPACE", "released",
  441. "ENTER", "pressed",
  442. "released ENTER", "released"
  443. }),
  444. "ToggleButton.font", dialogPlain12,
  445. "ToggleButton.background", table.get("control"),
  446. "ToggleButton.foreground", table.get("controlText"),
  447. "ToggleButton.shadow", table.getColor("controlShadow"),
  448. "ToggleButton.darkShadow", table.getColor("controlDkShadow"),
  449. "ToggleButton.light", table.getColor("controlHighlight"),
  450. "ToggleButton.highlight", table.getColor("controlLtHighlight"),
  451. "ToggleButton.border", buttonToggleBorder,
  452. "ToggleButton.margin", new InsetsUIResource(2, 14, 2, 14),
  453. "ToggleButton.textIconGap", four,
  454. "ToggleButton.textShiftOffset", zero,
  455. "ToggleButton.focusInputMap",
  456. new UIDefaults.LazyInputMap(new Object[] {
  457. "SPACE", "pressed",
  458. "released SPACE", "released"
  459. }),
  460. "RadioButton.font", dialogPlain12,
  461. "RadioButton.background", table.get("control"),
  462. "RadioButton.foreground", table.get("controlText"),
  463. "RadioButton.shadow", table.getColor("controlShadow"),
  464. "RadioButton.darkShadow", table.getColor("controlDkShadow"),
  465. "RadioButton.light", table.getColor("controlHighlight"),
  466. "RadioButton.highlight", table.getColor("controlLtHighlight"),
  467. "RadioButton.border", radioButtonBorder,
  468. "RadioButton.margin", new InsetsUIResource(2, 2, 2, 2),
  469. "RadioButton.textIconGap", four,
  470. "RadioButton.textShiftOffset", zero,
  471. "RadioButton.icon", radioButtonIcon,
  472. "RadioButton.focusInputMap",
  473. new UIDefaults.LazyInputMap(new Object[] {
  474. "SPACE", "pressed",
  475. "released SPACE", "released",
  476. "RETURN", "pressed"
  477. }),
  478. "CheckBox.font", dialogPlain12,
  479. "CheckBox.background", table.get("control"),
  480. "CheckBox.foreground", table.get("controlText"),
  481. "CheckBox.border", radioButtonBorder,
  482. "CheckBox.margin", new InsetsUIResource(2, 2, 2, 2),
  483. "CheckBox.textIconGap", four,
  484. "CheckBox.textShiftOffset", zero,
  485. "CheckBox.icon", checkBoxIcon,
  486. "CheckBox.focusInputMap",
  487. new UIDefaults.LazyInputMap(new Object[] {
  488. "SPACE", "pressed",
  489. "released SPACE", "released"
  490. }),
  491. // *** ColorChooser
  492. "ColorChooser.font", dialogPlain12,
  493. "ColorChooser.background", table.get("control"),
  494. "ColorChooser.foreground", table.get("controlText"),
  495. "ColorChooser.swatchesSwatchSize", new Dimension(10, 10),
  496. "ColorChooser.swatchesRecentSwatchSize", new Dimension(10, 10),
  497. "ColorChooser.swatchesDefaultRecentColor", table.get("control"),
  498. "ColorChooser.rgbRedMnemonic", new Integer(KeyEvent.VK_D),
  499. "ColorChooser.rgbGreenMnemonic", new Integer(KeyEvent.VK_N),
  500. "ColorChooser.rgbBlueMnemonic", new Integer(KeyEvent.VK_B),
  501. // *** ComboBox
  502. "ComboBox.font", sansSerifPlain12,
  503. "ComboBox.background", table.get("window"),
  504. "ComboBox.foreground", table.get("textText"),
  505. "ComboBox.buttonBackground", table.get("control"),
  506. "ComboBox.buttonShadow", table.get("controlShadow"),
  507. "ComboBox.buttonDarkShadow", table.get("controlDkShadow"),
  508. "ComboBox.buttonHighlight", table.get("controlLtHighlight"),
  509. "ComboBox.selectionBackground", table.get("textHighlight"),
  510. "ComboBox.selectionForeground", table.get("textHighlightText"),
  511. "ComboBox.disabledBackground", table.get("control"),
  512. "ComboBox.disabledForeground", table.get("textInactiveText"),
  513. "ComboBox.ancestorInputMap",
  514. new UIDefaults.LazyInputMap(new Object[] {
  515. "ESCAPE", "hidePopup",
  516. "PAGE_UP", "pageUpPassThrough",
  517. "PAGE_DOWN", "pageDownPassThrough",
  518. "HOME", "homePassThrough",
  519. "END", "endPassThrough",
  520. "ENTER", "enterPressed"
  521. }),
  522. // *** FileChooser
  523. "FileChooser.cancelButtonMnemonic", new Integer(KeyEvent.VK_C),
  524. "FileChooser.saveButtonMnemonic", new Integer(KeyEvent.VK_S),
  525. "FileChooser.openButtonMnemonic", new Integer(KeyEvent.VK_O),
  526. "FileChooser.updateButtonMnemonic", new Integer(KeyEvent.VK_U),
  527. "FileChooser.helpButtonMnemonic", new Integer(KeyEvent.VK_H),
  528. "FileChooser.directoryOpenButtonMnemonic", new Integer(KeyEvent.VK_O),
  529. "FileChooser.newFolderIcon", newFolderIcon,
  530. "FileChooser.upFolderIcon", upFolderIcon,
  531. "FileChooser.homeFolderIcon", homeFolderIcon,
  532. "FileChooser.detailsViewIcon", detailsViewIcon,
  533. "FileChooser.listViewIcon", listViewIcon,
  534. "FileChooser.ancestorInputMap",
  535. new UIDefaults.LazyInputMap(new Object[] {
  536. "ESCAPE", "cancelSelection"
  537. }),
  538. "FileView.directoryIcon", directoryIcon,
  539. "FileView.fileIcon", fileIcon,
  540. "FileView.computerIcon", computerIcon,
  541. "FileView.hardDriveIcon", hardDriveIcon,
  542. "FileView.floppyDriveIcon", floppyDriveIcon,
  543. // *** InternalFrame
  544. "InternalFrame.titleFont", dialogBold12,
  545. "InternalFrame.borderColor", table.get("control"),
  546. "InternalFrame.borderShadow", table.get("controlShadow"),
  547. "InternalFrame.borderDarkShadow", table.getColor("controlDkShadow"),
  548. "InternalFrame.borderHighlight", table.getColor("controlLtHighlight"),
  549. "InternalFrame.borderLight", table.getColor("controlHighlight"),
  550. "InternalFrame.border", internalFrameBorder,
  551. "InternalFrame.icon", LookAndFeel.makeIcon(getClass(), "icons/JavaCup.gif"),
  552. /* Default frame icons are undefined for Basic. */
  553. "InternalFrame.maximizeIcon",
  554. new UIDefaults.ProxyLazyValue(
  555. "javax.swing.plaf.basic.BasicIconFactory",
  556. "createEmptyFrameIcon"),
  557. "InternalFrame.minimizeIcon",
  558. new UIDefaults.ProxyLazyValue(
  559. "javax.swing.plaf.basic.BasicIconFactory",
  560. "createEmptyFrameIcon"),
  561. "InternalFrame.iconifyIcon",
  562. new UIDefaults.ProxyLazyValue(
  563. "javax.swing.plaf.basic.BasicIconFactory",
  564. "createEmptyFrameIcon"),
  565. "InternalFrame.closeIcon",
  566. new UIDefaults.ProxyLazyValue(
  567. "javax.swing.plaf.basic.BasicIconFactory",
  568. "createEmptyFrameIcon"),
  569. // InternalFrame Auditory Cue Mappings
  570. "InternalFrame.closeSound", null,
  571. "InternalFrame.maximizeSound", null,
  572. "InternalFrame.minimizeSound", null,
  573. "InternalFrame.restoreDownSound", null,
  574. "InternalFrame.restoreUpSound", null,
  575. "InternalFrame.activeTitleBackground", table.get("activeCaption"),
  576. "InternalFrame.activeTitleForeground", table.get("activeCaptionText"),
  577. "InternalFrame.inactiveTitleBackground", table.get("inactiveCaption"),
  578. "InternalFrame.inactiveTitleForeground", table.get("inactiveCaptionText"),
  579. "InternalFrame.windowBindings", new Object[] {
  580. "shift ESCAPE", "showSystemMenu",
  581. "ctrl SPACE", "showSystemMenu",
  582. "ESCAPE", "hideSystemMenu"},
  583. "DesktopIcon.border", internalFrameBorder,
  584. "Desktop.background", table.get("desktop"),
  585. "Desktop.ancestorInputMap",
  586. new UIDefaults.LazyInputMap(new Object[] {
  587. "ctrl F5", "restore",
  588. "ctrl F4", "close",
  589. "ctrl F7", "move",
  590. "ctrl F8", "resize",
  591. "RIGHT", "right",
  592. "KP_RIGHT", "right",
  593. "shift RIGHT", "shrinkRight",
  594. "shift KP_RIGHT", "shrinkRight",
  595. "LEFT", "left",
  596. "KP_LEFT", "left",
  597. "shift LEFT", "shrinkLeft",
  598. "shift KP_LEFT", "shrinkLeft",
  599. "UP", "up",
  600. "KP_UP", "up",
  601. "shift UP", "shrinkUp",
  602. "shift KP_UP", "shrinkUp",
  603. "DOWN", "down",
  604. "KP_DOWN", "down",
  605. "shift DOWN", "shrinkDown",
  606. "shift KP_DOWN", "shrinkDown",
  607. "ESCAPE", "escape",
  608. "ctrl F9", "minimize",
  609. "ctrl F10", "maximize",
  610. "ctrl F6", "selectNextFrame",
  611. "ctrl TAB", "selectNextFrame",
  612. "ctrl alt F6", "selectNextFrame",
  613. "shift ctrl alt F6", "selectPreviousFrame",
  614. "ctrl F12", "navigateNext",
  615. "shift ctrl F12", "navigatePrevious"
  616. }),
  617. // *** Label
  618. "Label.font", dialogPlain12,
  619. "Label.background", table.get("control"),
  620. "Label.foreground", table.get("controlText"),
  621. "Label.disabledForeground", white,
  622. "Label.disabledShadow", table.get("controlShadow"),
  623. "Label.border", null,
  624. // *** List
  625. "List.font", dialogPlain12,
  626. "List.background", table.get("window"),
  627. "List.foreground", table.get("textText"),
  628. "List.selectionBackground", table.get("textHighlight"),
  629. "List.selectionForeground", table.get("textHighlightText"),
  630. "List.focusCellHighlightBorder", focusCellHighlightBorder,
  631. "List.border", null,
  632. "List.cellRenderer", listCellRendererActiveValue,
  633. "List.focusInputMap",
  634. new UIDefaults.LazyInputMap(new Object[] {
  635. "ctrl C", "copy",
  636. "ctrl V", "paste",
  637. "ctrl X", "cut",
  638. "COPY", "copy",
  639. "PASTE", "paste",
  640. "CUT", "cut",
  641. "UP", "selectPreviousRow",
  642. "KP_UP", "selectPreviousRow",
  643. "shift UP", "selectPreviousRowExtendSelection",
  644. "shift KP_UP", "selectPreviousRowExtendSelection",
  645. "DOWN", "selectNextRow",
  646. "KP_DOWN", "selectNextRow",
  647. "shift DOWN", "selectNextRowExtendSelection",
  648. "shift KP_DOWN", "selectNextRowExtendSelection",
  649. "LEFT", "selectPreviousColumn",
  650. "KP_LEFT", "selectPreviousColumn",
  651. "shift LEFT", "selectPreviousColumnExtendSelection",
  652. "shift KP_LEFT", "selectPreviousColumnExtendSelection",
  653. "RIGHT", "selectNextColumn",
  654. "KP_RIGHT", "selectNextColumn",
  655. "shift RIGHT", "selectNextColumnExtendSelection",
  656. "shift KP_RIGHT", "selectNextColumnExtendSelection",
  657. "ctrl SPACE", "selectNextRowExtendSelection",
  658. "HOME", "selectFirstRow",
  659. "shift HOME", "selectFirstRowExtendSelection",
  660. "END", "selectLastRow",
  661. "shift END", "selectLastRowExtendSelection",
  662. "PAGE_UP", "scrollUp",
  663. "shift PAGE_UP", "scrollUpExtendSelection",
  664. "PAGE_DOWN", "scrollDown",
  665. "shift PAGE_DOWN", "scrollDownExtendSelection",
  666. "ctrl A", "selectAll",
  667. "ctrl SLASH", "selectAll",
  668. "ctrl BACK_SLASH", "clearSelection"
  669. }),
  670. "List.focusInputMap.RightToLeft",
  671. new UIDefaults.LazyInputMap(new Object[] {
  672. "LEFT", "selectNextColumn",
  673. "KP_LEFT", "selectNextColumn",
  674. "shift LEFT", "selectNextColumnExtendSelection",
  675. "shift KP_LEFT", "selectNextColumnExtendSelection",
  676. "RIGHT", "selectPreviousColumn",
  677. "KP_RIGHT", "selectPreviousColumn",
  678. "shift RIGHT", "selectPreviousColumnExtendSelection",
  679. "shift KP_RIGHT", "selectPreviousColumnExtendSelection",
  680. }),
  681. // *** Menus
  682. "MenuBar.font", dialogPlain12,
  683. "MenuBar.background", table.get("menu"),
  684. "MenuBar.foreground", table.get("menuText"),
  685. "MenuBar.shadow", table.getColor("controlShadow"),
  686. "MenuBar.highlight", table.getColor("controlLtHighlight"),
  687. "MenuBar.border", menuBarBorder,
  688. "MenuBar.windowBindings", new Object[] {
  689. "F10", "takeFocus" },
  690. "MenuItem.font", dialogPlain12,
  691. "MenuItem.acceleratorFont", dialogPlain12,
  692. "MenuItem.background", table.get("menu"),
  693. "MenuItem.foreground", table.get("menuText"),
  694. "MenuItem.selectionForeground", table.get("textHighlightText"),
  695. "MenuItem.selectionBackground", table.get("textHighlight"),
  696. "MenuItem.disabledForeground", null,
  697. "MenuItem.acceleratorForeground", table.get("menuText"),
  698. "MenuItem.acceleratorSelectionForeground", table.get("textHighlightText"),
  699. "MenuItem.acceleratorDelimiter", menuItemAcceleratorDelimiter,
  700. "MenuItem.border", marginBorder,
  701. "MenuItem.borderPainted", Boolean.FALSE,
  702. "MenuItem.margin", new InsetsUIResource(2, 2, 2, 2),
  703. "MenuItem.checkIcon", menuItemCheckIcon,
  704. "MenuItem.arrowIcon", menuItemArrowIcon,
  705. "MenuItem.commandSound", null,
  706. "RadioButtonMenuItem.font", dialogPlain12,
  707. "RadioButtonMenuItem.acceleratorFont", dialogPlain12,
  708. "RadioButtonMenuItem.background", table.get("menu"),
  709. "RadioButtonMenuItem.foreground", table.get("menuText"),
  710. "RadioButtonMenuItem.selectionForeground", table.get("textHighlightText"),
  711. "RadioButtonMenuItem.selectionBackground", table.get("textHighlight"),
  712. "RadioButtonMenuItem.disabledForeground", null,
  713. "RadioButtonMenuItem.acceleratorForeground", table.get("menuText"),
  714. "RadioButtonMenuItem.acceleratorSelectionForeground", table.get("textHighlightText"),
  715. "RadioButtonMenuItem.border", marginBorder,
  716. "RadioButtonMenuItem.borderPainted", Boolean.FALSE,
  717. "RadioButtonMenuItem.margin", new InsetsUIResource(2, 2, 2, 2),
  718. "RadioButtonMenuItem.checkIcon", radioButtonMenuItemIcon,
  719. "RadioButtonMenuItem.arrowIcon", menuItemArrowIcon,
  720. "RadioButtonMenuItem.commandSound", null,
  721. "CheckBoxMenuItem.font", dialogPlain12,
  722. "CheckBoxMenuItem.acceleratorFont", dialogPlain12,
  723. "CheckBoxMenuItem.background", table.get("menu"),
  724. "CheckBoxMenuItem.foreground", table.get("menuText"),
  725. "CheckBoxMenuItem.selectionForeground", table.get("textHighlightText"),
  726. "CheckBoxMenuItem.selectionBackground", table.get("textHighlight"),
  727. "CheckBoxMenuItem.disabledForeground", null,
  728. "CheckBoxMenuItem.acceleratorForeground", table.get("menuText"),
  729. "CheckBoxMenuItem.acceleratorSelectionForeground", table.get("textHighlightText"),
  730. "CheckBoxMenuItem.border", marginBorder,
  731. "CheckBoxMenuItem.borderPainted", Boolean.FALSE,
  732. "CheckBoxMenuItem.margin", new InsetsUIResource(2, 2, 2, 2),
  733. "CheckBoxMenuItem.checkIcon", checkBoxMenuItemIcon,
  734. "CheckBoxMenuItem.arrowIcon", menuItemArrowIcon,
  735. "CheckBoxMenuItem.commandSound", null,
  736. "Menu.font", dialogPlain12,
  737. "Menu.acceleratorFont", dialogPlain12,
  738. "Menu.background", table.get("menu"),
  739. "Menu.foreground", table.get("menuText"),
  740. "Menu.selectionForeground", table.get("textHighlightText"),
  741. "Menu.selectionBackground", table.get("textHighlight"),
  742. "Menu.disabledForeground", null,
  743. "Menu.acceleratorForeground", table.get("menuText"),
  744. "Menu.acceleratorSelectionForeground", table.get("textHighlightText"),
  745. "Menu.border", marginBorder,
  746. "Menu.borderPainted", Boolean.FALSE,
  747. "Menu.margin", new InsetsUIResource(2, 2, 2, 2),
  748. "Menu.checkIcon", menuItemCheckIcon,
  749. "Menu.arrowIcon", menuArrowIcon,
  750. "Menu.menuPopupOffsetX", new Integer(0),
  751. "Menu.menuPopupOffsetY", new Integer(0),
  752. "Menu.submenuPopupOffsetX", new Integer(0),
  753. "Menu.submenuPopupOffsetY", new Integer(0),
  754. "Menu.shortcutKeys", new int[] {KeyEvent.ALT_MASK},
  755. "Menu.crossMenuMnemonic", Boolean.TRUE,
  756. // PopupMenu
  757. "PopupMenu.font", dialogPlain12,
  758. "PopupMenu.background", table.get("menu"),
  759. "PopupMenu.foreground", table.get("menuText"),
  760. "PopupMenu.border", popupMenuBorder,
  761. // Internal Frame Auditory Cue Mappings
  762. "PopupMenu.popupSound", null,
  763. // These window InputMap bindings are used when the Menu is
  764. // selected.
  765. "PopupMenu.selectedWindowInputMapBindings", new Object[] {
  766. "ESCAPE", "cancel",
  767. "DOWN", "selectNext",
  768. "KP_DOWN", "selectNext",
  769. "UP", "selectPrevious",
  770. "KP_UP", "selectPrevious",
  771. "LEFT", "selectParent",
  772. "KP_LEFT", "selectParent",
  773. "RIGHT", "selectChild",
  774. "KP_RIGHT", "selectChild",
  775. "ENTER", "return",
  776. "SPACE", "return"
  777. },
  778. "PopupMenu.selectedWindowInputMapBindings.RightToLeft", new Object[] {
  779. "LEFT", "selectChild",
  780. "KP_LEFT", "selectChild",
  781. "RIGHT", "selectParent",
  782. "KP_RIGHT", "selectParent",
  783. },
  784. // *** OptionPane
  785. // You can additionaly define OptionPane.messageFont which will
  786. // dictate the fonts used for the message, and
  787. // OptionPane.buttonFont, which defines the font for the buttons.
  788. "OptionPane.font", dialogPlain12,
  789. "OptionPane.background", table.get("control"),
  790. "OptionPane.foreground", table.get("controlText"),
  791. "OptionPane.messageForeground", table.get("controlText"),
  792. "OptionPane.border", optionPaneBorder,
  793. "OptionPane.messageAreaBorder", zeroBorder,
  794. "OptionPane.buttonAreaBorder", optionPaneButtonAreaBorder,
  795. "OptionPane.minimumSize", optionPaneMinimumSize,
  796. "OptionPane.errorIcon", LookAndFeel.makeIcon(getClass(), "icons/Error.gif"),
  797. "OptionPane.informationIcon", LookAndFeel.makeIcon(getClass(), "icons/Inform.gif"),
  798. "OptionPane.warningIcon", LookAndFeel.makeIcon(getClass(), "icons/Warn.gif"),
  799. "OptionPane.questionIcon", LookAndFeel.makeIcon(getClass(), "icons/Question.gif"),
  800. "OptionPane.windowBindings", new Object[] {
  801. "ESCAPE", "close" },
  802. // OptionPane Auditory Cue Mappings
  803. "OptionPane.errorSound", null,
  804. "OptionPane.informationSound", null, // Info and Plain
  805. "OptionPane.questionSound", null,
  806. "OptionPane.warningSound", null,
  807. "OptionPane.buttonClickThreshhold", fiveHundred,
  808. // *** Panel
  809. "Panel.font", dialogPlain12,
  810. "Panel.background", table.get("control"),
  811. "Panel.foreground", table.get("textText"),
  812. // *** ProgressBar
  813. "ProgressBar.font", dialogPlain12,
  814. "ProgressBar.foreground", table.get("textHighlight"),
  815. "ProgressBar.background", table.get("control"),
  816. "ProgressBar.selectionForeground", table.get("control"),
  817. "ProgressBar.selectionBackground", table.get("textHighlight"),
  818. "ProgressBar.border", progressBarBorder,
  819. "ProgressBar.cellLength", new Integer(1),
  820. "ProgressBar.cellSpacing", zero,
  821. "ProgressBar.repaintInterval", new Integer(50),
  822. "ProgressBar.cycleTime", new Integer(3000),
  823. // *** Separator
  824. "Separator.shadow", table.get("controlShadow"), // DEPRECATED - DO NOT USE!
  825. "Separator.highlight", table.get("controlLtHighlight"), // DEPRECATED - DO NOT USE!
  826. "Separator.background", table.get("controlLtHighlight"),
  827. "Separator.foreground", table.get("controlShadow"),
  828. // *** ScrollBar/ScrollPane/Viewport
  829. "ScrollBar.background", scrollBarTrack,
  830. "ScrollBar.foreground", table.get("control"),
  831. "ScrollBar.track", table.get("scrollbar"),
  832. "ScrollBar.trackHighlight", table.get("controlDkShadow"),
  833. "ScrollBar.thumb", table.get("control"),
  834. "ScrollBar.thumbHighlight", table.get("controlLtHighlight"),
  835. "ScrollBar.thumbDarkShadow", table.get("controlDkShadow"),
  836. "ScrollBar.thumbShadow", table.get("controlShadow"),
  837. "ScrollBar.border", null,
  838. "ScrollBar.minimumThumbSize", minimumThumbSize,
  839. "ScrollBar.maximumThumbSize", maximumThumbSize,
  840. "ScrollBar.focusInputMap",
  841. new UIDefaults.LazyInputMap(new Object[] {
  842. "RIGHT", "positiveUnitIncrement",
  843. "KP_RIGHT", "positiveUnitIncrement",
  844. "DOWN", "positiveUnitIncrement",
  845. "KP_DOWN", "positiveUnitIncrement",
  846. "PAGE_DOWN", "positiveBlockIncrement",
  847. "LEFT", "negativeUnitIncrement",
  848. "KP_LEFT", "negativeUnitIncrement",
  849. "UP", "negativeUnitIncrement",
  850. "KP_UP", "negativeUnitIncrement",
  851. "PAGE_UP", "negativeBlockIncrement",
  852. "HOME", "minScroll",
  853. "END", "maxScroll"
  854. }),
  855. "ScrollBar.focusInputMap.RightToLeft",
  856. new UIDefaults.LazyInputMap(new Object[] {
  857. "RIGHT", "negativeUnitIncrement",
  858. "KP_RIGHT", "negativeUnitIncrement",
  859. "LEFT", "positiveUnitIncrement",
  860. "KP_LEFT", "positiveUnitIncrement",
  861. }),
  862. "ScrollBar.width", new Integer(16),
  863. "ScrollPane.font", dialogPlain12,
  864. "ScrollPane.background", table.get("control"),
  865. "ScrollPane.foreground", table.get("controlText"),
  866. "ScrollPane.border", textFieldBorder,
  867. "ScrollPane.viewportBorder", null,
  868. "ScrollPane.ancestorInputMap",
  869. new UIDefaults.LazyInputMap(new Object[] {
  870. "RIGHT", "unitScrollRight",
  871. "KP_RIGHT", "unitScrollRight",
  872. "DOWN", "unitScrollDown",
  873. "KP_DOWN", "unitScrollDown",
  874. "LEFT", "unitScrollLeft",
  875. "KP_LEFT", "unitScrollLeft",
  876. "UP", "unitScrollUp",
  877. "KP_UP", "unitScrollUp",
  878. "PAGE_UP", "scrollUp",
  879. "PAGE_DOWN", "scrollDown",
  880. "ctrl PAGE_UP", "scrollLeft",
  881. "ctrl PAGE_DOWN", "scrollRight",
  882. "ctrl HOME", "scrollHome",
  883. "ctrl END", "scrollEnd"
  884. }),
  885. "ScrollPane.ancestorInputMap.RightToLeft",
  886. new UIDefaults.LazyInputMap(new Object[] {
  887. "ctrl PAGE_UP", "scrollRight",
  888. "ctrl PAGE_DOWN", "scrollLeft",
  889. }),
  890. "Viewport.font", dialogPlain12,
  891. "Viewport.background", table.get("control"),
  892. "Viewport.foreground", table.get("textText"),
  893. // *** Slider
  894. "Slider.foreground", table.get("control"),
  895. "Slider.background", table.get("control"),
  896. "Slider.highlight", table.get("controlLtHighlight"),
  897. "Slider.shadow", table.get("controlShadow"),
  898. "Slider.focus", table.get("controlDkShadow"),
  899. "Slider.border", null,
  900. "Slider.focusInsets", sliderFocusInsets,
  901. "Slider.focusInputMap",
  902. new UIDefaults.LazyInputMap(new Object[] {
  903. "RIGHT", "positiveUnitIncrement",
  904. "KP_RIGHT", "positiveUnitIncrement",
  905. "DOWN", "negativeUnitIncrement",
  906. "KP_DOWN", "negativeUnitIncrement",
  907. "PAGE_DOWN", "negativeBlockIncrement",
  908. "LEFT", "negativeUnitIncrement",
  909. "KP_LEFT", "negativeUnitIncrement",
  910. "UP", "positiveUnitIncrement",
  911. "KP_UP", "positiveUnitIncrement",
  912. "PAGE_UP", "positiveBlockIncrement",
  913. "HOME", "minScroll",
  914. "END", "maxScroll"
  915. }),
  916. "Slider.focusInputMap.RightToLeft",
  917. new UIDefaults.LazyInputMap(new Object[] {
  918. "RIGHT", "negativeUnitIncrement",
  919. "KP_RIGHT", "negativeUnitIncrement",
  920. "LEFT", "positiveUnitIncrement",
  921. "KP_LEFT", "positiveUnitIncrement",
  922. }),
  923. // *** Spinner
  924. "Spinner.font", monospacedPlain12,
  925. "Spinner.background", table.get("control"),
  926. "Spinner.foreground", table.get("control"),
  927. "Spinner.border", textFieldBorder,
  928. "Spinner.arrowButtonBorder", null,
  929. "Spinner.arrowButtonInsets", null,
  930. "Spinner.arrowButtonSize", new Dimension(16, 5),
  931. "Spinner.ancestorInputMap",
  932. new UIDefaults.LazyInputMap(new Object[] {
  933. "UP", "increment",
  934. "KP_UP", "increment",
  935. "DOWN", "decrement",
  936. "KP_DOWN", "decrement",
  937. }),
  938. "Spinner.editorBorderPainted", Boolean.FALSE,
  939. // *** SplitPane
  940. "SplitPane.background", table.get("control"),
  941. "SplitPane.highlight", table.get("controlLtHighlight"),
  942. "SplitPane.shadow", table.get("controlShadow"),
  943. "SplitPane.darkShadow", table.get("controlDkShadow"),
  944. "SplitPane.border", splitPaneBorder,
  945. "SplitPane.dividerSize", new Integer(7),
  946. "SplitPaneDivider.border", splitPaneDividerBorder,
  947. "SplitPane.ancestorInputMap",
  948. new UIDefaults.LazyInputMap(new Object[] {
  949. "UP", "negativeIncrement",
  950. "DOWN", "positiveIncrement",
  951. "LEFT", "negativeIncrement",
  952. "RIGHT", "positiveIncrement",
  953. "KP_UP", "negativeIncrement",
  954. "KP_DOWN", "positiveIncrement",
  955. "KP_LEFT", "negativeIncrement",
  956. "KP_RIGHT", "positiveIncrement",
  957. "HOME", "selectMin",
  958. "END", "selectMax",
  959. "F8", "startResize",
  960. "F6", "toggleFocus",
  961. "ctrl TAB", "focusOutForward",
  962. "ctrl shift TAB", "focusOutBackward"
  963. }),
  964. // *** TabbedPane
  965. "TabbedPane.font", dialogPlain12,
  966. "TabbedPane.background", table.get("control"),
  967. "TabbedPane.foreground", table.get("controlText"),
  968. "TabbedPane.highlight", table.get("controlLtHighlight"),
  969. "TabbedPane.light", table.get("controlHighlight"),
  970. "TabbedPane.shadow", table.get("controlShadow"),
  971. "TabbedPane.darkShadow", table.get("controlDkShadow"),
  972. "TabbedPane.selected", null,
  973. "TabbedPane.focus", table.get("controlText"),
  974. "TabbedPane.textIconGap", four,
  975. "TabbedPane.tabInsets", tabbedPaneTabInsets,
  976. "TabbedPane.selectedTabPadInsets", tabbedPaneTabPadInsets,
  977. "TabbedPane.tabAreaInsets", tabbedPaneTabAreaInsets,
  978. "TabbedPane.contentBorderInsets", tabbedPaneContentBorderInsets,
  979. "TabbedPane.tabRunOverlay", new Integer(2),
  980. "TabbedPane.focusInputMap",
  981. new UIDefaults.LazyInputMap(new Object[] {
  982. "RIGHT", "navigateRight",
  983. "KP_RIGHT", "navigateRight",
  984. "LEFT", "navigateLeft",
  985. "KP_LEFT", "navigateLeft",
  986. "UP", "navigateUp",
  987. "KP_UP", "navigateUp",
  988. "DOWN", "navigateDown",
  989. "KP_DOWN", "navigateDown",
  990. "ctrl DOWN", "requestFocusForVisibleComponent",
  991. "ctrl KP_DOWN", "requestFocusForVisibleComponent",
  992. }),
  993. "TabbedPane.ancestorInputMap",
  994. new UIDefaults.LazyInputMap(new Object[] {
  995. "ctrl TAB", "navigateNext",
  996. "ctrl shift TAB", "navigatePrevious",
  997. "ctrl PAGE_DOWN", "navigatePageDown",
  998. "ctrl PAGE_UP", "navigatePageUp",
  999. "ctrl UP", "requestFocus",
  1000. "ctrl KP_UP", "requestFocus",
  1001. }),
  1002. // *** Table
  1003. "Table.font", dialogPlain12,
  1004. "Table.foreground", table.get("controlText"), // cell text color
  1005. "Table.background", table.get("window"), // cell background color
  1006. "Table.selectionForeground", table.get("textHighlightText"),
  1007. "Table.selectionBackground", table.get("textHighlight"),
  1008. "Table.gridColor", gray, // grid line color
  1009. "Table.focusCellBackground", table.get("window"),
  1010. "Table.focusCellForeground", table.get("controlText"),
  1011. "Table.focusCellHighlightBorder", focusCellHighlightBorder,
  1012. "Table.scrollPaneBorder", loweredBevelBorder,
  1013. "Table.ancestorInputMap",
  1014. new UIDefaults.LazyInputMap(new Object[] {
  1015. "ctrl C", "copy",
  1016. "ctrl V", "paste",
  1017. "ctrl X", "cut",
  1018. "COPY", "copy",
  1019. "PASTE", "paste",
  1020. "CUT", "cut",
  1021. "RIGHT", "selectNextColumn",
  1022. "KP_RIGHT", "selectNextColumn",
  1023. "LEFT", "selectPreviousColumn",
  1024. "KP_LEFT", "selectPreviousColumn",
  1025. "DOWN", "selectNextRow",
  1026. "KP_DOWN", "selectNextRow",
  1027. "UP", "selectPreviousRow",
  1028. "KP_UP", "selectPreviousRow",
  1029. "shift RIGHT", "selectNextColumnExtendSelection",
  1030. "shift KP_RIGHT", "selectNextColumnExtendSelection",
  1031. "shift LEFT", "selectPreviousColumnExtendSelection",
  1032. "shift KP_LEFT", "selectPreviousColumnExtendSelection",
  1033. "shift DOWN", "selectNextRowExtendSelection",
  1034. "shift KP_DOWN", "selectNextRowExtendSelection",
  1035. "shift UP", "selectPreviousRowExtendSelection",
  1036. "shift KP_UP", "selectPreviousRowExtendSelection",
  1037. "PAGE_UP", "scrollUpChangeSelection",
  1038. "PAGE_DOWN", "scrollDownChangeSelection",
  1039. "HOME", "selectFirstColumn",
  1040. "END", "selectLastColumn",
  1041. "shift PAGE_UP", "scrollUpExtendSelection",
  1042. "shift PAGE_DOWN", "scrollDownExtendSelection",
  1043. "shift HOME", "selectFirstColumnExtendSelection",
  1044. "shift END", "selectLastColumnExtendSelection",
  1045. "ctrl PAGE_UP", "scrollLeftChangeSelection",
  1046. "ctrl PAGE_DOWN", "scrollRightChangeSelection",
  1047. "ctrl HOME", "selectFirstRow",
  1048. "ctrl END", "selectLastRow",
  1049. "ctrl shift PAGE_UP", "scrollRightExtendSelection",
  1050. "ctrl shift PAGE_DOWN", "scrollLeftExtendSelection",
  1051. "ctrl shift HOME", "selectFirstRowExtendSelection",
  1052. "ctrl shift END", "selectLastRowExtendSelection",
  1053. "TAB", "selectNextColumnCell",
  1054. "shift TAB", "selectPreviousColumnCell",
  1055. "ENTER", "selectNextRowCell",
  1056. "shift ENTER", "selectPreviousRowCell",
  1057. "ctrl A", "selectAll",
  1058. "ESCAPE", "cancel",
  1059. "F2", "startEditing"
  1060. }),
  1061. "Table.ancestorInputMap.RightToLeft",
  1062. new UIDefaults.LazyInputMap(new Object[] {
  1063. "RIGHT", "selectPreviousColumn",
  1064. "KP_RIGHT", "selectPreviousColumn",
  1065. "LEFT", "selectNextColumn",
  1066. "KP_LEFT", "selectNextColumn",
  1067. "shift RIGHT", "selectPreviousColumnExtendSelection",
  1068. "shift KP_RIGHT", "selectPreviousColumnExtendSelection",
  1069. "shift LEFT", "selectNextColumnExtendSelection",
  1070. "shift KP_LEFT", "selectNextColumnExtendSelection",
  1071. "ctrl PAGE_UP", "scrollRightChangeSelection",
  1072. "ctrl PAGE_DOWN", "scrollLeftChangeSelection",
  1073. "ctrl shift PAGE_UP", "scrollRightExtendSelection",
  1074. "ctrl shift PAGE_DOWN", "scrollLeftExtendSelection",
  1075. }),
  1076. "TableHeader.font", dialogPlain12,
  1077. "TableHeader.foreground", table.get("controlText"), // header text color
  1078. "TableHeader.background", table.get("control"), // header background
  1079. "TableHeader.cellBorder", tableHeaderBorder,
  1080. // *** Text
  1081. "TextField.font", sansSerifPlain12,
  1082. "TextField.background", table.get("window"),
  1083. "TextField.foreground", table.get("textText"),
  1084. "TextField.shadow", table.getColor("controlShadow"),
  1085. "TextField.darkShadow", table.getColor("controlDkShadow"),
  1086. "TextField.light", table.getColor("controlHighlight"),
  1087. "TextField.highlight", table.getColor("controlLtHighlight"),
  1088. "TextField.inactiveForeground", table.get("textInactiveText"),
  1089. "TextField.inactiveBackground", table.get("control"),
  1090. "TextField.selectionBackground", table.get("textHighlight"),
  1091. "TextField.selectionForeground", table.get("textHighlightText"),
  1092. "TextField.caretForeground", table.get("textText"),
  1093. "TextField.caretBlinkRate", caretBlinkRate,
  1094. "TextField.border", textFieldBorder,
  1095. "TextField.margin", zeroInsets,
  1096. "FormattedTextField.font", sansSerifPlain12,
  1097. "FormattedTextField.background", table.get("window"),
  1098. "FormattedTextField.foreground", table.get("textText"),
  1099. "FormattedTextField.inactiveForeground", table.get("textInactiveText"),
  1100. "FormattedTextField.inactiveBackground", table.get("control"),
  1101. "FormattedTextField.selectionBackground", table.get("textHighlight"),
  1102. "FormattedTextField.selectionForeground", table.get("textHighlightText"),
  1103. "FormattedTextField.caretForeground", table.get("textText"),
  1104. "FormattedTextField.caretBlinkRate", caretBlinkRate,
  1105. "FormattedTextField.border", textFieldBorder,
  1106. "FormattedTextField.margin", zeroInsets,
  1107. "FormattedTextField.focusInputMap",
  1108. new UIDefaults.LazyInputMap(new Object[] {
  1109. "ctrl C", DefaultEditorKit.copyAction,
  1110. "ctrl V", DefaultEditorKit.pasteAction,
  1111. "ctrl X", DefaultEditorKit.cutAction,
  1112. "COPY", DefaultEditorKit.copyAction,
  1113. "PASTE", DefaultEditorKit.pasteAction,
  1114. "CUT", DefaultEditorKit.cutAction,
  1115. "shift LEFT", DefaultEditorKit.selectionBackwardAction,
  1116. "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction,
  1117. "shift RIGHT", DefaultEditorKit.selectionForwardAction,
  1118. "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction,
  1119. "ctrl LEFT", DefaultEditorKit.previousWordAction,
  1120. "ctrl KP_LEFT", DefaultEditorKit.previousWordAction,
  1121. "ctrl RIGHT", DefaultEditorKit.nextWordAction,
  1122. "ctrl KP_RIGHT", DefaultEditorKit.nextWordAction,
  1123. "ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
  1124. "ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction,
  1125. "ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction,
  1126. "ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction,
  1127. "ctrl A", DefaultEditorKit.selectAllAction,
  1128. "HOME", DefaultEditorKit.beginLineAction,
  1129. "END", DefaultEditorKit.endLineAction,
  1130. "shift HOME", DefaultEditorKit.selectionBeginLineAction,
  1131. "shift END", DefaultEditorKit.selectionEndLineAction,
  1132. "typed \010", DefaultEditorKit.deletePrevCharAction,
  1133. "DELETE", DefaultEditorKit.deleteNextCharAction,
  1134. "RIGHT", DefaultEditorKit.forwardAction,
  1135. "LEFT", DefaultEditorKit.backwardAction,
  1136. "KP_RIGHT", DefaultEditorKit.forwardAction,
  1137. "KP_LEFT", DefaultEditorKit.backwardAction,
  1138. "ENTER", JTextField.notifyAction,
  1139. "ctrl BACK_SLASH", "unselect",
  1140. "control shift O", "toggle-componentOrientation",
  1141. "ESCAPE", "reset-field-edit",
  1142. "UP", "increment",
  1143. "KP_UP", "increment",
  1144. "DOWN", "decrement",
  1145. "KP_DOWN", "decrement",
  1146. }),
  1147. "PasswordField.font", monospacedPlain12,
  1148. "PasswordField.background", table.get("window"),
  1149. "PasswordField.foreground", table.get("textText"),
  1150. "PasswordField.inactiveForeground", table.get("textInactiveText"),
  1151. "PasswordField.inactiveBackground", table.get("control"),
  1152. "PasswordField.selectionBackground", table.get("textHighlight"),
  1153. "PasswordField.selectionForeground", table.get("textHighlightText"),
  1154. "PasswordField.caretForeground", table.get("textText"),
  1155. "PasswordField.caretBlinkRate", caretBlinkRate,
  1156. "PasswordField.border", textFieldBorder,
  1157. "PasswordField.margin", zeroInsets,
  1158. "TextArea.font", monospacedPlain12,
  1159. "TextArea.background", table.get("window"),
  1160. "TextArea.foreground", table.get("textText"),
  1161. "TextArea.inactiveForeground", table.get("textInactiveText"),
  1162. "TextArea.selectionBackground", table.get("textHighlight"),
  1163. "TextArea.selectionForeground", table.get("textHighlightText"),
  1164. "TextArea.caretForeground", table.get("textText"),
  1165. "TextArea.caretBlinkRate", caretBlinkRate,
  1166. "TextArea.border", marginBorder,
  1167. "TextArea.margin", zeroInsets,
  1168. "TextPane.font", serifPlain12,
  1169. "TextPane.background", white,
  1170. "TextPane.foreground", table.get("textText"),
  1171. "TextPane.selectionBackground", table.get("textHighlight"),
  1172. "TextPane.selectionForeground", table.get("textHighlightText"),
  1173. "TextPane.caretForeground", table.get("textText"),
  1174. "TextPane.caretBlinkRate", caretBlinkRate,
  1175. "TextPane.inactiveForeground", table.get("textInactiveText"),
  1176. "TextPane.border", marginBorder,
  1177. "TextPane.margin", editorMargin,
  1178. "EditorPane.font", serifPlain12,
  1179. "EditorPane.background", white,
  1180. "EditorPane.foreground", table.get("textText"),
  1181. "EditorPane.selectionBackground", table.get("textHighlight"),
  1182. "EditorPane.selectionForeground", table.get("textHighlightText"),
  1183. "EditorPane.caretForeground", table.get("textText"),
  1184. "EditorPane.caretBlinkRate", caretBlinkRate,
  1185. "EditorPane.inactiveForeground", table.get("textInactiveText"),
  1186. "EditorPane.border", marginBorder,
  1187. "EditorPane.margin", editorMargin,
  1188. // *** TitledBorder
  1189. "TitledBorder.font", dialogPlain12,
  1190. "TitledBorder.titleColor", table.get("controlText"),
  1191. "TitledBorder.border", etchedBorder,
  1192. // *** ToolBar
  1193. "ToolBar.font", dialogPlain12,
  1194. "ToolBar.background", table.get("control"),
  1195. "ToolBar.foreground", table.get("controlText"),
  1196. "ToolBar.shadow", table.getColor("controlShadow"),
  1197. "ToolBar.darkShadow", table.getColor("controlDkShadow"),
  1198. "ToolBar.light", table.getColor("controlHighlight"),
  1199. "ToolBar.highlight", table.getColor("controlLtHighlight"),
  1200. "ToolBar.dockingBackground", table.get("control"),
  1201. "ToolBar.dockingForeground", red,
  1202. "ToolBar.floatingBackground", table.get("control"),
  1203. "ToolBar.floatingForeground", darkGray,
  1204. "ToolBar.border", etchedBorder,
  1205. "ToolBar.separatorSize", toolBarSeparatorSize,
  1206. "ToolBar.ancestorInputMap",
  1207. new UIDefaults.LazyInputMap(new Object[] {
  1208. "UP", "navigateUp",
  1209. "KP_UP", "navigateUp",
  1210. "DOWN", "navigateDown",
  1211. "KP_DOWN", "navigateDown",
  1212. "LEFT", "navigateLeft",
  1213. "KP_LEFT", "navigateLeft",
  1214. "RIGHT", "navigateRight",
  1215. "KP_RIGHT", "navigateRight"
  1216. }),
  1217. // *** ToolTips
  1218. "ToolTip.font", sansSerifPlain12,
  1219. "ToolTip.background", table.get("info"),
  1220. "ToolTip.foreground", table.get("infoText"),
  1221. "ToolTip.border", blackLineBorder,
  1222. // ToolTips also support backgroundInactive, borderInactive,
  1223. // and foregroundInactive
  1224. // *** Tree
  1225. "Tree.font", dialogPlain12,
  1226. "Tree.background", table.get("window"),
  1227. "Tree.foreground", table.get("textText"),
  1228. "Tree.hash", gray,
  1229. "Tree.textForeground", table.get("textText"),
  1230. "Tree.textBackground", table.get("text"),
  1231. "Tree.selectionForeground", table.get("textHighlightText"),
  1232. "Tree.selectionBackground", table.get("textHighlight"),
  1233. "Tree.selectionBorderColor", black,
  1234. "Tree.editorBorder", blackLineBorder,
  1235. "Tree.leftChildIndent", new Integer(7),
  1236. "Tree.rightChildIndent", new Integer(13),
  1237. "Tree.rowHeight", new Integer(16),
  1238. "Tree.scrollsOnExpand", Boolean.TRUE,
  1239. "Tree.openIcon", LookAndFeel.makeIcon(getClass(), "icons/TreeOpen.gif"),
  1240. "Tree.closedIcon", LookAndFeel.makeIcon(getClass(), "icons/TreeClosed.gif"),
  1241. "Tree.leafIcon", LookAndFeel.makeIcon(getClass(), "icons/TreeLeaf.gif"),
  1242. "Tree.expandedIcon", null,
  1243. "Tree.collapsedIcon", null,
  1244. "Tree.changeSelectionWithFocus", Boolean.TRUE,
  1245. "Tree.drawsFocusBorderAroundIcon", Boolean.FALSE,
  1246. "Tree.focusInputMap",
  1247. new UIDefaults.LazyInputMap(new Object[] {
  1248. "ctrl C", "copy",
  1249. "ctrl V", "paste",
  1250. "ctrl X", "cut",
  1251. "COPY", "copy",
  1252. "PASTE", "paste",
  1253. "CUT", "cut",
  1254. "UP", "selectPrevious",
  1255. "KP_UP", "selectPrevious",
  1256. "shift UP", "selectPreviousExtendSelection",
  1257. "shift KP_UP", "selectPreviousExtendSelection",
  1258. "DOWN", "selectNext",
  1259. "KP_DOWN", "selectNext",
  1260. "shift DOWN", "selectNextExtendSelection",
  1261. "shift KP_DOWN", "selectNextExtendSelection",
  1262. "RIGHT", "selectChild",
  1263. "KP_RIGHT", "selectChild",
  1264. "LEFT", "selectParent",
  1265. "KP_LEFT", "selectParent",
  1266. "PAGE_UP", "scrollUpChangeSelection",
  1267. "shift PAGE_UP", "scrollUpExtendSelection",
  1268. "PAGE_DOWN", "scrollDownChangeSelection",
  1269. "shift PAGE_DOWN", "scrollDownExtendSelection",
  1270. "HOME", "selectFirst",
  1271. "shift HOME", "selectFirstExtendSelection",
  1272. "END", "selectLast",
  1273. "shift END", "selectLastExtendSelection",
  1274. "F2", "startEditing",
  1275. "ctrl A", "selectAll",
  1276. "ctrl SLASH", "selectAll",
  1277. "ctrl BACK_SLASH", "clearSelection",
  1278. "ctrl SPACE", "toggleSelectionPreserveAnchor",
  1279. "shift SPACE", "extendSelection",
  1280. "ctrl HOME", "selectFirstChangeLead",
  1281. "ctrl END", "selectLastChangeLead",
  1282. "ctrl UP", "selectPreviousChangeLead",
  1283. "ctrl KP_UP", "selectPreviousChangeLead",
  1284. "ctrl DOWN", "selectNextChangeLead",
  1285. "ctrl KP_DOWN", "selectNextChangeLead",
  1286. "ctrl PAGE_DOWN", "scrollDownChangeLead",
  1287. "ctrl shift PAGE_DOWN", "scrollDownExtendSelection",
  1288. "ctrl PAGE_UP", "scrollUpChangeLead",
  1289. "ctrl shift PAGE_UP", "scrollUpExtendSelection",
  1290. "ctrl LEFT", "scrollLeft",
  1291. "ctrl KP_LEFT", "scrollLeft",
  1292. "ctrl RIGHT", "scrollRight",
  1293. "ctrl KP_RIGHT", "scrollRight",
  1294. "SPACE", "toggleSelectionPreserveAnchor",
  1295. }),
  1296. "Tree.focusInputMap.RightToLeft",
  1297. new UIDefaults.LazyInputMap(new Object[] {
  1298. "RIGHT", "selectParent",
  1299. "KP_RIGHT", "selectParent",
  1300. "LEFT", "selectChild",
  1301. "KP_LEFT", "selectChild",
  1302. }),
  1303. "Tree.ancestorInputMap",
  1304. new UIDefaults.LazyInputMap(new Object[] {
  1305. "ESCAPE", "cancel"
  1306. }),
  1307. // These bindings are only enabled when there is a default
  1308. // button set on the rootpane.
  1309. "RootPane.defaultButtonWindowKeyBindings", new Object[] {
  1310. "ENTER", "press",
  1311. "released ENTER", "release",
  1312. "ctrl ENTER", "press",
  1313. "ctrl released ENTER", "release"
  1314. },
  1315. };
  1316. table.putDefaults(defaults);
  1317. }
  1318. // ********* Auditory Cue support methods and objects *********
  1319. // also see the "AuditoryCues" section of the defaults table
  1320. /**
  1321. * Returns an <code>ActionMap</code>.
  1322. * <P>
  1323. * This <code>ActionMap</code> contains <code>Actions</code> that
  1324. * embody the ability to render an auditory cue. These auditory
  1325. * cues map onto user and system activities that may be useful
  1326. * for an end user to know about (such as a dialog box appearing).
  1327. * <P>
  1328. * At the appropriate time in a <code>JComponent</code> UI's lifecycle,
  1329. * the ComponentUI is responsible for getting the appropriate
  1330. * <code>Action</code> out of the <code>ActionMap</code> and passing
  1331. * it on to <code>playSound</code>.
  1332. * <P>
  1333. * The <code>Actions</code> in this <code>ActionMap</code> are
  1334. * created by the <code>createAudioAction</code> method.
  1335. *
  1336. * @return an ActionMap containing Actions
  1337. * responsible for rendering auditory cues
  1338. * @see #createAudioAction
  1339. * @see #playSound(Action)
  1340. * @since 1.4
  1341. */
  1342. protected ActionMap getAudioActionMap() {
  1343. ActionMap audioActionMap = (ActionMap)UIManager.get(
  1344. "AuditoryCues.actionMap");
  1345. if (audioActionMap == null) {
  1346. Object[] acList = (Object[])UIManager.get("AuditoryCues.cueList");
  1347. if (acList != null) {
  1348. audioActionMap = new ActionMapUIResource();
  1349. for(int counter = acList.length-1; counter >= 0; counter--) {
  1350. audioActionMap.put(acList[counter],
  1351. createAudioAction(acList[counter]));
  1352. }
  1353. }
  1354. UIManager.getLookAndFeelDefaults().put("AuditoryCues.actionMap",
  1355. audioActionMap);
  1356. }
  1357. return audioActionMap;
  1358. }
  1359. /**
  1360. * Returns an <code>Action</code>.
  1361. * <P>
  1362. * This Action contains the information and logic to render an
  1363. * auditory cue. The <code>Object</code> that is passed to this
  1364. * method contains the information needed to render the auditory
  1365. * cue. Normally, this <code>Object</code> is a <code>String</code>
  1366. * that points to an audio file relative to the current package.
  1367. * This <code>Action</code>'s <code>actionPerformed</code> method
  1368. * is fired by the <code>playSound</code> method.
  1369. *
  1370. * @return an Action which knows how to render the auditory
  1371. * cue for one particular system or user activity
  1372. * @see #playSound(Action)
  1373. * @since 1.4
  1374. */
  1375. protected Action createAudioAction(Object key) {
  1376. if (key != null) {
  1377. String audioKey = (String)key;
  1378. String audioValue = (String)UIManager.get(key);
  1379. return new AudioAction(audioKey, audioValue);
  1380. } else {
  1381. return null;
  1382. }
  1383. }
  1384. /**
  1385. * Pass the name String to the super constructor. This is used
  1386. * later to identify the Action and decide whether to play it or
  1387. * not. Store the resource String. I is used to get the audio
  1388. * resource. In this case, the resource is an audio file.
  1389. *
  1390. * @since 1.4
  1391. */
  1392. private class AudioAction extends AbstractAction implements LineListener {
  1393. // We strive to only play one sound at a time (other platforms
  1394. // appear to do this). This is done by maintaining the field
  1395. // clipPlaying. Every time a sound is to be played,
  1396. // cancelCurrentSound is invoked to cancel any sound that may be
  1397. // playing.
  1398. private String audioResource;
  1399. private byte[] audioBuffer;
  1400. /**
  1401. * The String is the name of the Action and
  1402. * points to the audio resource.
  1403. * The byte[] is a buffer of the audio bits.
  1404. */
  1405. public AudioAction(String name, String resource) {
  1406. super(name);
  1407. audioResource = resource;
  1408. }
  1409. public void actionPerformed(ActionEvent e) {
  1410. if (audioBuffer == null) {
  1411. audioBuffer = loadAudioData(audioResource);
  1412. }
  1413. if (audioBuffer != null) {
  1414. cancelCurrentSound(null);
  1415. try {
  1416. AudioInputStream soundStream =
  1417. AudioSystem.getAudioInputStream(
  1418. new ByteArrayInputStream(audioBuffer));
  1419. DataLine.Info info =
  1420. new DataLine.Info(Clip.class, soundStream.getFormat());
  1421. Clip clip = (Clip) AudioSystem.getLine(info);
  1422. clip.open(soundStream);
  1423. clip.addLineListener(this);
  1424. synchronized(audioLock) {
  1425. clipPlaying = clip;
  1426. }
  1427. clip.start();
  1428. } catch (Exception ex) {}
  1429. }
  1430. }
  1431. public void update(LineEvent event) {
  1432. if (event.getType() == LineEvent.Type.STOP) {
  1433. cancelCurrentSound((Clip)event.getLine());
  1434. }
  1435. }
  1436. /**
  1437. * If the parameter is null, or equal to the currently
  1438. * playing sound, then cancel the currently playing sound.
  1439. */
  1440. private void cancelCurrentSound(Clip clip) {
  1441. Clip lastClip = null;
  1442. synchronized(audioLock) {
  1443. if (clip == null || clip == clipPlaying) {
  1444. lastClip = clipPlaying;
  1445. clipPlaying = null;
  1446. }
  1447. }
  1448. if (lastClip != null) {
  1449. lastClip.removeLineListener(this);
  1450. lastClip.close();
  1451. }
  1452. }
  1453. }
  1454. /**
  1455. * Utility method that helps get permission for loading audio files.
  1456. * This is an exact copy of
  1457. * <code>javax.swing.SwingUtilities#doPrivileged(final Runnable)</code>.
  1458. * The SwingUtilities version is unusable here as it is package private.
  1459. *
  1460. * @param doRun the object that needs special access, in this case,
  1461. * to the file system
  1462. * @see javax.swing.SwingUtilities#doPrivileged(final Runnable)
  1463. * @since 1.4
  1464. */
  1465. private final static void doPrivileged(final Runnable doRun) {
  1466. java.security.AccessController.doPrivileged(
  1467. new java.security.PrivilegedAction() {
  1468. public Object run() {
  1469. doRun.run();
  1470. return null;
  1471. }
  1472. }
  1473. );
  1474. }
  1475. /**
  1476. * Utility method that loads audio bits for the specified
  1477. * <code>soundFile</code> filename. If this method is unable to
  1478. * build a viable path name from the <code>baseClass</code> and
  1479. * <code>soundFile</code> passed into this method, it will
  1480. * return <code>null</code>.
  1481. *
  1482. * @param baseClass used as the root class/location to get the
  1483. * soundFile from
  1484. * @param soundFile the name of the audio file to be retrieved
  1485. * from disk
  1486. * @return A byte[] with audio data or null
  1487. * @since 1.4
  1488. */
  1489. private byte[] loadAudioData(final String soundFile){
  1490. if (soundFile == null) {
  1491. return null;
  1492. }
  1493. /* Copy resource into a byte array. This is
  1494. * necessary because several browsers consider
  1495. * Class.getResource a security risk since it
  1496. * can be used to load additional classes.
  1497. * Class.getResourceAsStream just returns raw
  1498. * bytes, which we can convert to a sound.
  1499. */
  1500. final byte[][] buffer = new byte[1][];
  1501. doPrivileged(new Runnable() {
  1502. public void run() {
  1503. try {
  1504. InputStream resource = BasicLookAndFeel.this.
  1505. getClass().getResourceAsStream(soundFile);
  1506. if (resource == null) {
  1507. return;
  1508. }
  1509. BufferedInputStream in =
  1510. new BufferedInputStream(resource);
  1511. ByteArrayOutputStream out =
  1512. new ByteArrayOutputStream(1024);
  1513. buffer[0] = new byte[1024];
  1514. int n;
  1515. while ((n = in.read(buffer[0])) > 0) {
  1516. out.write(buffer[0], 0, n);
  1517. }
  1518. in.close();
  1519. out.flush();
  1520. buffer[0] = out.toByteArray();
  1521. } catch (IOException ioe) {
  1522. System.err.println(ioe.toString());
  1523. return;
  1524. }
  1525. }
  1526. });
  1527. if (buffer[0] == null) {
  1528. System.err.println(getClass().getName() + "/" +
  1529. soundFile + " not found.");
  1530. return null;
  1531. }
  1532. if (buffer[0].length == 0) {
  1533. System.err.println("warning: " + soundFile +
  1534. " is zero-length");
  1535. return null;
  1536. }
  1537. return buffer[0];
  1538. }
  1539. /**
  1540. * Decides whether to fire the <code>Action</code> that is passed into
  1541. * it and, if needed, fires the <code>Action</code>'s
  1542. * <code>actionPerformed</code> method. This has the effect
  1543. * of rendering the audio appropriate for the situation.
  1544. * <P>
  1545. * The set of possible cues to be played are stored in the default
  1546. * table value "AuditoryCues.cueList". The cues that will be played
  1547. * are stored in "AuditoryCues.playList".
  1548. *
  1549. * @param audioAction an Action that knows how to render the audio
  1550. * associated with the system or user activity
  1551. * that is occurring
  1552. * @since 1.4
  1553. */
  1554. protected void playSound(Action audioAction) {
  1555. if (audioAction != null) {
  1556. Object[] audioStrings = (Object[])
  1557. UIManager.get("AuditoryCues.playList");
  1558. if (audioStrings != null) {
  1559. // create a HashSet to help us decide to play or not
  1560. HashSet audioCues = new HashSet();
  1561. for (int i = 0; i < audioStrings.length; i++) {
  1562. audioCues.add(audioStrings[i]);
  1563. }
  1564. // get the name of the Action
  1565. String actionName = (String)audioAction.getValue(Action.NAME);
  1566. // if the actionName is in the audioCues HashSet, play it.
  1567. if (audioCues.contains(actionName)) {
  1568. audioAction.actionPerformed(new
  1569. ActionEvent(this, ActionEvent.ACTION_PERFORMED,
  1570. actionName));
  1571. }
  1572. }
  1573. }
  1574. }
  1575. // At this point we need this method here. But we assume that there
  1576. // will be a common method for this purpose in the future releases.
  1577. static void compositeRequestFocus(Component component) {
  1578. if (component instanceof Container) {
  1579. Container container = (Container)component;
  1580. if (container.isFocusCycleRoot()) {
  1581. FocusTraversalPolicy policy = container.getFocusTraversalPolicy();
  1582. Component comp = policy.getDefaultComponent(container);
  1583. if (comp!=null) {
  1584. comp.requestFocus();
  1585. return;
  1586. }
  1587. }
  1588. Container rootAncestor = container.getFocusCycleRootAncestor();
  1589. if (rootAncestor!=null) {
  1590. FocusTraversalPolicy policy = rootAncestor.getFocusTraversalPolicy();
  1591. Component comp = policy.getComponentAfter(rootAncestor, container);
  1592. if (comp!=null && SwingUtilities.isDescendingFrom(comp, container)) {
  1593. comp.requestFocus();
  1594. return;
  1595. }
  1596. }
  1597. }
  1598. component.requestFocus();
  1599. }
  1600. }