1. /*
  2. * @(#)MotifLookAndFeel.java 1.113 01/11/29
  3. *
  4. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package com.sun.java.swing.plaf.motif;
  8. import java.awt.Toolkit;
  9. import java.awt.Color;
  10. import java.awt.Font;
  11. import java.awt.Insets;
  12. import java.awt.event.KeyEvent;
  13. import java.awt.event.InputEvent;
  14. import java.util.*;
  15. import java.lang.reflect.*;
  16. import javax.swing.*;
  17. import javax.swing.plaf.*;
  18. import javax.swing.border.*;
  19. import javax.swing.text.JTextComponent;
  20. import javax.swing.text.DefaultEditorKit;
  21. import javax.swing.plaf.basic.BasicLookAndFeel;
  22. import javax.swing.plaf.basic.BasicBorders;
  23. import javax.swing.plaf.basic.BasicComboBoxRenderer;
  24. import javax.swing.plaf.basic.BasicComboBoxEditor;
  25. /**
  26. * Implements the Motif Look and Feel.
  27. * UI classes not implemented specifically for Motif will
  28. * default to those implemented in Basic.
  29. * <p>
  30. * For the keyboard keys defined for each component in this Look and
  31. * Feel (L&F), see
  32. * <a href="../../../../../../javax/swing/doc-files/Key-Motif.html">Component Keystroke Actions for the Motif L&F</a>.
  33. * <p>
  34. * <strong>Warning:</strong>
  35. * Serialized objects of this class will not be compatible with
  36. * future Swing releases. The current serialization support is appropriate
  37. * for short term storage or RMI between applications running the same
  38. * version of Swing. A future release of Swing will provide support for
  39. * long term persistence.
  40. *
  41. * @version 1.113 11/29/01
  42. * @author unattributed
  43. */
  44. public class MotifLookAndFeel extends BasicLookAndFeel
  45. {
  46. public String getName() {
  47. return "CDE/Motif";
  48. }
  49. public String getID() {
  50. return "Motif";
  51. }
  52. public String getDescription() {
  53. return "The CDE/Motif Look and Feel";
  54. }
  55. public boolean isNativeLookAndFeel() {
  56. String osName = System.getProperty("os.name");
  57. return (osName != null) && (osName.indexOf("Solaris") != -1);
  58. }
  59. public boolean isSupportedLookAndFeel() {
  60. return true;
  61. }
  62. /**
  63. * Load the SystemColors into the defaults table. The keys
  64. * for SystemColor defaults are the same as the names of
  65. * the public fields in SystemColor. If the table is being
  66. * created on a native Motif platform we use the SystemColor
  67. * values, otherwise we create color objects whose values match
  68. * the default CDE/Motif colors.
  69. */
  70. protected void initSystemColorDefaults(UIDefaults table)
  71. {
  72. String[] defaultSystemColors = {
  73. "desktop", "#005C5C", /* Color of the desktop background */
  74. "activeCaption", "#000080", /* Color for captions (title bars) when they are active. */
  75. "activeCaptionText", "#FFFFFF", /* Text color for text in captions (title bars). */
  76. "activeCaptionBorder", "#B24D7A", /* Border color for caption (title bar) window borders. */
  77. "inactiveCaption", "#AEB2C3", /* Color for captions (title bars) when not active. */
  78. "inactiveCaptionText", "#000000", /* Text color for text in inactive captions (title bars). */
  79. "inactiveCaptionBorder", "#AEB2C3", /* Border color for inactive caption (title bar) window borders. */
  80. "window", "#AEB2C3", /* Default color for the interior of windows */
  81. "windowBorder", "#AEB2C3", /* ??? */
  82. "windowText", "#000000", /* ??? */
  83. "menu", "#AEB2C3", /* ??? */
  84. "menuText", "#000000", /* ??? */
  85. "text", "#FFF7E9", /* Text background color */
  86. "textText", "#000000", /* Text foreground color */
  87. "textHighlight", "#000000", /* Text background color when selected */
  88. "textHighlightText", "#FFF7E9", /* Text color when selected */
  89. "textInactiveText", "#808080", /* Text color when disabled */
  90. "control", "#AEB2C3", /* Default color for controls (buttons, sliders, etc) */
  91. "controlText", "#000000", /* Default color for text in controls */
  92. "controlHighlight", "#DCDEE5", /* Highlight color for controls */
  93. "controlLtHighlight", "#DCDEE5", /* Light highlight color for controls */
  94. "controlShadow", "#63656F", /* Shadow color for controls */
  95. "controlLightShadow", "#9397A5", /* Shadow color for controls */
  96. "controlDkShadow", "#000000", /* Dark shadow color for controls */
  97. "scrollbar", "#AEB2C3", /* Scrollbar ??? color. PENDING(jeff) foreground? background? ?*/
  98. "info", "#FFF7E9", /* ??? */
  99. "infoText", "#000000" /* ??? */
  100. };
  101. // AWT SystemColors only for for CDE on JDK1.2
  102. loadSystemColors(table, defaultSystemColors, false/*is1dot2*/);
  103. }
  104. protected void initClassDefaults(UIDefaults table)
  105. {
  106. super.initClassDefaults(table);
  107. String motifPackageName = "com.sun.java.swing.plaf.motif.";
  108. Object[] uiDefaults = {
  109. "ButtonUI", motifPackageName + "MotifButtonUI",
  110. "CheckBoxUI", motifPackageName + "MotifCheckBoxUI",
  111. "DirectoryPaneUI", motifPackageName + "MotifDirectoryPaneUI",
  112. "FileChooserUI", motifPackageName + "MotifFileChooserUI",
  113. "LabelUI", motifPackageName + "MotifLabelUI",
  114. "MenuBarUI", motifPackageName + "MotifMenuBarUI",
  115. "MenuUI", motifPackageName + "MotifMenuUI",
  116. "MenuItemUI", motifPackageName + "MotifMenuItemUI",
  117. "CheckBoxMenuItemUI", motifPackageName + "MotifCheckBoxMenuItemUI",
  118. "RadioButtonMenuItemUI", motifPackageName + "MotifRadioButtonMenuItemUI",
  119. "RadioButtonUI", motifPackageName + "MotifRadioButtonUI",
  120. "ToggleButtonUI", motifPackageName + "MotifToggleButtonUI",
  121. "PopupMenuUI", motifPackageName + "MotifPopupMenuUI",
  122. "ProgressBarUI", motifPackageName + "MotifProgressBarUI",
  123. "ScrollBarUI", motifPackageName + "MotifScrollBarUI",
  124. "ScrollPaneUI", motifPackageName + "MotifScrollPaneUI",
  125. "SliderUI", motifPackageName + "MotifSliderUI",
  126. "SplitPaneUI", motifPackageName + "MotifSplitPaneUI",
  127. "TabbedPaneUI", motifPackageName + "MotifTabbedPaneUI",
  128. "TextAreaUI", motifPackageName + "MotifTextAreaUI",
  129. "TextFieldUI", motifPackageName + "MotifTextFieldUI",
  130. "PasswordFieldUI", motifPackageName + "MotifPasswordFieldUI",
  131. "TextPaneUI", motifPackageName + "MotifTextPaneUI",
  132. "EditorPaneUI", motifPackageName + "MotifEditorPaneUI",
  133. "TreeUI", motifPackageName + "MotifTreeUI",
  134. "InternalFrameUI", motifPackageName + "MotifInternalFrameUI",
  135. "DesktopPaneUI", motifPackageName + "MotifDesktopPaneUI",
  136. "SeparatorUI", motifPackageName + "MotifSeparatorUI",
  137. "PopupMenuSeparatorUI", motifPackageName + "MotifPopupMenuSeparatorUI",
  138. "OptionPaneUI", motifPackageName + "MotifOptionPaneUI",
  139. "ComboBoxUI", motifPackageName + "MotifComboBoxUI",
  140. "DesktopIconUI", motifPackageName + "MotifDesktopIconUI"
  141. };
  142. table.putDefaults(uiDefaults);
  143. }
  144. private void loadResourceBundle(UIDefaults table) {
  145. ResourceBundle bundle = ResourceBundle.getBundle("com.sun.java.swing.plaf.motif.resources.motif");
  146. Enumeration iter = bundle.getKeys();
  147. while(iter.hasMoreElements()) {
  148. String key = (String)iter.nextElement();
  149. //System.out.println("key :" +key+ " value: " + bundle.getObject(key));
  150. table.put( key, bundle.getObject(key) );
  151. }
  152. }
  153. protected void initComponentDefaults(UIDefaults table)
  154. {
  155. super.initComponentDefaults(table);
  156. loadResourceBundle(table);
  157. FontUIResource dialogPlain12 = new FontUIResource("Dialog",
  158. Font.PLAIN, 12);
  159. FontUIResource serifPlain12 = new FontUIResource("Serif",
  160. Font.PLAIN, 12);
  161. FontUIResource sansSerifPlain12 = new FontUIResource("SansSerif",
  162. Font.PLAIN, 12);
  163. FontUIResource monospacedPlain12 = new FontUIResource("Monospaced",
  164. Font.PLAIN, 12);
  165. ColorUIResource red = new ColorUIResource(Color.red);
  166. ColorUIResource black = new ColorUIResource(Color.black);
  167. ColorUIResource white = new ColorUIResource(Color.white);
  168. ColorUIResource lightGray = new ColorUIResource(Color.lightGray);
  169. ColorUIResource controlDarker = new ColorUIResource(147, 151, 165); // slate blue
  170. ColorUIResource scrollBarTrack = controlDarker;
  171. ColorUIResource menuItemPressedBackground = new ColorUIResource(165,165,165);
  172. ColorUIResource menuItemPressedForeground = new ColorUIResource(0,0,0);
  173. Border loweredBevelBorder = new MotifBorders.BevelBorder(false,
  174. table.getColor("controlShadow"),
  175. table.getColor("controlLtHighlight"));
  176. Border raisedBevelBorder = new MotifBorders.BevelBorder(true, table.getColor("controlShadow"),
  177. table.getColor("controlLtHighlight"));
  178. Border marginBorder = new BasicBorders.MarginBorder();
  179. Border focusBorder = new MotifBorders.FocusBorder(
  180. table.getColor("control"),
  181. table.getColor("activeCaptionBorder"));
  182. Border focusBevelBorder = new BorderUIResource.CompoundBorderUIResource(
  183. focusBorder,
  184. loweredBevelBorder);
  185. Border comboBoxBorder = new BorderUIResource.CompoundBorderUIResource(
  186. focusBorder,
  187. raisedBevelBorder);
  188. Border buttonBorder = new BorderUIResource.CompoundBorderUIResource(
  189. new MotifBorders.ButtonBorder(
  190. table.getColor("controlShadow"),
  191. table.getColor("controlHighlight"),
  192. table.getColor("controlDkShadow"),
  193. table.getColor("activeCaptionBorder")),
  194. marginBorder);
  195. Border toggleButtonBorder = new BorderUIResource.CompoundBorderUIResource(
  196. new MotifBorders.ToggleButtonBorder(
  197. table.getColor("controlShadow"),
  198. table.getColor("controlHighlight"),
  199. table.getColor("controlDkShadow"),
  200. table.getColor("activeCaptionBorder")), marginBorder);
  201. Border textFieldBorder = new BorderUIResource.CompoundBorderUIResource(
  202. focusBevelBorder,
  203. marginBorder);
  204. Object menuItemCheckIcon = new UIDefaults.LazyValue() {
  205. public Object createValue(UIDefaults table) {
  206. return MotifIconFactory.getMenuItemCheckIcon();
  207. }
  208. };
  209. Object menuItemArrowIcon = new UIDefaults.LazyValue() {
  210. public Object createValue(UIDefaults table) {
  211. return MotifIconFactory.getMenuItemArrowIcon();
  212. }
  213. };
  214. Object menuArrowIcon = new UIDefaults.LazyValue() {
  215. public Object createValue(UIDefaults table) {
  216. return MotifIconFactory.getMenuArrowIcon();
  217. }
  218. };
  219. Object checkBoxIcon = new UIDefaults.LazyValue() {
  220. public Object createValue(UIDefaults table) {
  221. return MotifIconFactory.getCheckBoxIcon();
  222. }
  223. };
  224. Object radioButtonIcon = new UIDefaults.LazyValue() {
  225. public Object createValue(UIDefaults table) {
  226. return MotifIconFactory.getRadioButtonIcon();
  227. }
  228. };
  229. Object unselectedTabBackground = new UIDefaults.LazyValue() {
  230. public Object createValue(UIDefaults table) {
  231. Color c = (Color)table.getColor("control");
  232. return new ColorUIResource(Math.max((int)(c.getRed()*.85),0),
  233. Math.max((int)(c.getGreen()*.85),0),
  234. Math.max((int)(c.getBlue()*.85),0));
  235. }
  236. };
  237. Object unselectedTabForeground = new UIDefaults.LazyValue() {
  238. public Object createValue(UIDefaults table) {
  239. Color c = (Color)table.getColor("controlText");
  240. return new ColorUIResource(Math.max((int)(c.getRed()*.85),0),
  241. Math.max((int)(c.getGreen()*.85),0),
  242. Math.max((int)(c.getBlue()*.85),0));
  243. }
  244. };
  245. Object unselectedTabShadow = new UIDefaults.LazyValue() {
  246. public Object createValue(UIDefaults table) {
  247. Color c = (Color)table.getColor("control");
  248. Color base = new Color(Math.max((int)(c.getRed()*.85),0),
  249. Math.max((int)(c.getGreen()*.85),0),
  250. Math.max((int)(c.getBlue()*.85),0));
  251. return new ColorUIResource(base.darker());
  252. }
  253. };
  254. Object unselectedTabHighlight = new UIDefaults.LazyValue() {
  255. public Object createValue(UIDefaults table) {
  256. Color c = (Color)table.getColor("control");
  257. Color base = new Color(Math.max((int)(c.getRed()*.85),0),
  258. Math.max((int)(c.getGreen()*.85),0),
  259. Math.max((int)(c.getBlue()*.85),0));
  260. return new ColorUIResource(base.brighter());
  261. }
  262. };
  263. // *** Text
  264. JTextComponent.KeyBinding[] fieldBindings = {
  265. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_INSERT,
  266. InputEvent.CTRL_MASK),
  267. DefaultEditorKit.copyAction),
  268. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_INSERT,
  269. InputEvent.SHIFT_MASK),
  270. DefaultEditorKit.pasteAction),
  271. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE,
  272. InputEvent.SHIFT_MASK),
  273. DefaultEditorKit.cutAction),
  274. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_F,
  275. InputEvent.CTRL_MASK),
  276. DefaultEditorKit.forwardAction),
  277. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_B,
  278. InputEvent.CTRL_MASK),
  279. DefaultEditorKit.backwardAction),
  280. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_D,
  281. InputEvent.CTRL_MASK),
  282. DefaultEditorKit.deleteNextCharAction),
  283. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT,
  284. InputEvent.SHIFT_MASK),
  285. DefaultEditorKit.selectionBackwardAction),
  286. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT,
  287. InputEvent.SHIFT_MASK),
  288. DefaultEditorKit.selectionForwardAction),
  289. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT,
  290. InputEvent.CTRL_MASK),
  291. DefaultEditorKit.previousWordAction),
  292. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT,
  293. InputEvent.CTRL_MASK),
  294. DefaultEditorKit.nextWordAction),
  295. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT,
  296. InputEvent.CTRL_MASK |
  297. InputEvent.SHIFT_MASK),
  298. DefaultEditorKit.selectionPreviousWordAction),
  299. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT,
  300. InputEvent.CTRL_MASK |
  301. InputEvent.SHIFT_MASK),
  302. DefaultEditorKit.selectionNextWordAction),
  303. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_SLASH,
  304. InputEvent.CTRL_MASK),
  305. DefaultEditorKit.selectAllAction),
  306. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 0),
  307. DefaultEditorKit.beginLineAction),
  308. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_END, 0),
  309. DefaultEditorKit.endLineAction),
  310. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_HOME,
  311. InputEvent.SHIFT_MASK),
  312. DefaultEditorKit.selectionBeginLineAction),
  313. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_END,
  314. InputEvent.SHIFT_MASK),
  315. DefaultEditorKit.selectionEndLineAction),
  316. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0),
  317. JTextField.notifyAction)
  318. };
  319. JTextComponent.KeyBinding[] multilineBindings = {
  320. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_INSERT,
  321. InputEvent.CTRL_MASK),
  322. DefaultEditorKit.copyAction),
  323. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_INSERT,
  324. InputEvent.SHIFT_MASK),
  325. DefaultEditorKit.pasteAction),
  326. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE,
  327. InputEvent.SHIFT_MASK),
  328. DefaultEditorKit.cutAction),
  329. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_F,
  330. InputEvent.CTRL_MASK),
  331. DefaultEditorKit.forwardAction),
  332. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_B,
  333. InputEvent.CTRL_MASK),
  334. DefaultEditorKit.backwardAction),
  335. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_D,
  336. InputEvent.CTRL_MASK),
  337. DefaultEditorKit.deleteNextCharAction),
  338. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_N,
  339. InputEvent.CTRL_MASK),
  340. DefaultEditorKit.downAction),
  341. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_P,
  342. InputEvent.CTRL_MASK),
  343. DefaultEditorKit.upAction),
  344. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT,
  345. InputEvent.SHIFT_MASK),
  346. DefaultEditorKit.selectionBackwardAction),
  347. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT,
  348. InputEvent.SHIFT_MASK),
  349. DefaultEditorKit.selectionForwardAction),
  350. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT,
  351. InputEvent.CTRL_MASK),
  352. DefaultEditorKit.previousWordAction),
  353. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT,
  354. InputEvent.CTRL_MASK),
  355. DefaultEditorKit.nextWordAction),
  356. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT,
  357. InputEvent.CTRL_MASK |
  358. InputEvent.SHIFT_MASK),
  359. DefaultEditorKit.selectionPreviousWordAction),
  360. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT,
  361. InputEvent.CTRL_MASK |
  362. InputEvent.SHIFT_MASK),
  363. DefaultEditorKit.selectionNextWordAction),
  364. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_SLASH,
  365. InputEvent.CTRL_MASK),
  366. DefaultEditorKit.selectAllAction),
  367. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 0),
  368. DefaultEditorKit.beginLineAction),
  369. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_END, 0),
  370. DefaultEditorKit.endLineAction),
  371. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_HOME,
  372. InputEvent.SHIFT_MASK),
  373. DefaultEditorKit.selectionBeginLineAction),
  374. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_END,
  375. InputEvent.SHIFT_MASK),
  376. DefaultEditorKit.selectionEndLineAction),
  377. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0),
  378. DefaultEditorKit.upAction),
  379. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0),
  380. DefaultEditorKit.downAction),
  381. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, 0),
  382. DefaultEditorKit.pageUpAction),
  383. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0),
  384. DefaultEditorKit.pageDownAction),
  385. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_UP,
  386. InputEvent.SHIFT_MASK),
  387. DefaultEditorKit.selectionUpAction),
  388. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN,
  389. InputEvent.SHIFT_MASK),
  390. DefaultEditorKit.selectionDownAction),
  391. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0),
  392. DefaultEditorKit.insertBreakAction),
  393. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0),
  394. DefaultEditorKit.insertTabAction),
  395. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SLASH,
  396. InputEvent.CTRL_MASK),
  397. "unselect"/*DefaultEditorKit.unselectAction*/),
  398. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_HOME,
  399. InputEvent.CTRL_MASK),
  400. DefaultEditorKit.beginAction),
  401. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_END,
  402. InputEvent.CTRL_MASK),
  403. DefaultEditorKit.endAction),
  404. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_HOME,
  405. InputEvent.CTRL_MASK |
  406. InputEvent.SHIFT_MASK),
  407. DefaultEditorKit.selectionBeginAction),
  408. new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_END,
  409. InputEvent.CTRL_MASK |
  410. InputEvent.SHIFT_MASK),
  411. DefaultEditorKit.selectionEndAction)
  412. };
  413. // *** Tree
  414. Object treeOpenIcon = LookAndFeel.makeIcon(getClass(),
  415. "icons/TreeOpen.gif");
  416. Object treeClosedIcon = LookAndFeel.makeIcon(getClass(),
  417. "icons/TreeClosed.gif");
  418. Object treeLeafIcon = new UIDefaults.LazyValue() {
  419. public Object createValue(UIDefaults table) {
  420. return MotifTreeCellRenderer.loadLeafIcon();
  421. }
  422. };
  423. Object treeExpandedIcon = new UIDefaults.LazyValue() {
  424. public Object createValue(UIDefaults table) {
  425. return MotifTreeUI.MotifExpandedIcon.createExpandedIcon();
  426. }
  427. };
  428. Object treeCollapsedIcon = new UIDefaults.LazyValue() {
  429. public Object createValue(UIDefaults table) {
  430. return MotifTreeUI.MotifCollapsedIcon.createCollapsedIcon();
  431. }
  432. };
  433. Border menuBarBorder = new MotifBorders.MenuBarBorder(
  434. table.getColor("controlShadow"),
  435. table.getColor("controlHighlight"),
  436. table.getColor("controlDkShadow"),
  437. table.getColor("activeCaptionBorder"));
  438. Border menuMarginBorder = new BorderUIResource.CompoundBorderUIResource(
  439. loweredBevelBorder,
  440. marginBorder);
  441. Border focusCellHighlightBorder = new BorderUIResource.LineBorderUIResource(
  442. table.getColor("activeCaptionBorder"));
  443. Object sliderFocusInsets = new InsetsUIResource( 0, 0, 0, 0 );
  444. // ** for tabbedpane
  445. Object tabbedPaneTabInsets = new InsetsUIResource(3, 4, 3, 4);
  446. Object tabbedPaneTabPadInsets = new InsetsUIResource(3, 0, 1, 0);
  447. Object tabbedPaneTabAreaInsets = new InsetsUIResource(4, 2, 0, 8);
  448. Object tabbedPaneContentBorderInsets = new InsetsUIResource(2, 2, 2, 2);
  449. // ** for optionpane
  450. Object optionPaneBorder = new BorderUIResource.EmptyBorderUIResource(10,0,10,0);
  451. Object optionPaneButtonAreaBorder = new BorderUIResource.EmptyBorderUIResource(10,10,12,10);
  452. Object optionPaneMessageAreaBorder = new BorderUIResource.EmptyBorderUIResource(0,10,12,10);
  453. Object[] defaults = {
  454. "Desktop.background", table.get("desktop"),
  455. "Panel.background", table.get("control"),
  456. "Panel.foreground", table.get("textText"),
  457. "Panel.font", dialogPlain12,
  458. "ProgressBar.font", dialogPlain12,
  459. "ProgressBar.foreground", controlDarker,
  460. "ProgressBar.background", table.get("control"),
  461. "ProgressBar.selectionForeground", table.get("control"),
  462. "ProgressBar.selectionBackground", table.get("controlText"),
  463. "ProgressBar.border", loweredBevelBorder,
  464. "ProgressBar.cellLength", new Integer(6),
  465. "ProgressBar.cellSpacing", new Integer(0),
  466. // Buttons
  467. "Button.margin", new InsetsUIResource(2, 4, 2, 4),
  468. "Button.border", buttonBorder,
  469. "Button.background", table.get("control"),
  470. "Button.foreground", table.get("controlText"),
  471. "Button.select", table.get("controlLightShadow"),
  472. "Button.font", dialogPlain12,
  473. "CheckBox.textIconGap", new Integer(8),
  474. "CheckBox.margin", new InsetsUIResource(2, 2, 6, 2),
  475. "CheckBox.icon", checkBoxIcon,
  476. "CheckBox.focus", table.get("activeCaptionBorder"),
  477. "RadioButton.margin", new InsetsUIResource(2, 2, 6, 2),
  478. "RadioButton.textIconGap", new Integer(8),
  479. "RadioButton.background", table.get("control"),
  480. "RadioButton.foreground", table.get("controlText"),
  481. "RadioButton.icon", radioButtonIcon,
  482. "RadioButton.focus", table.get("activeCaptionBorder"),
  483. "RadioButton.icon", radioButtonIcon,
  484. "ToggleButton.border", toggleButtonBorder,
  485. "ToggleButton.background", table.get("control"),
  486. "ToggleButton.foreground", table.get("controlText"),
  487. "ToggleButton.focus", table.get("controlText"),
  488. "ToggleButton.select", table.get("controlLightShadow"),
  489. // Menus
  490. "Menu.border", menuMarginBorder,
  491. "Menu.font", dialogPlain12,
  492. "Menu.acceleratorFont", dialogPlain12,
  493. "Menu.foreground", table.get("menuText"),
  494. "Menu.background", table.get("menu"),
  495. "Menu.selectionForeground", menuItemPressedForeground,
  496. "Menu.selectionBackground", menuItemPressedBackground,
  497. "Menu.checkIcon", menuItemCheckIcon,
  498. "Menu.arrowIcon", menuArrowIcon,
  499. "MenuBar.border", menuBarBorder,
  500. "MenuBar.background", table.get("menu"),
  501. "MenuBar.foreground", table.get("menuText"),
  502. "MenuBar.font", dialogPlain12,
  503. "MenuItem.border", menuMarginBorder,
  504. "MenuItem.font", dialogPlain12,
  505. "MenuItem.acceleratorFont", dialogPlain12,
  506. "MenuItem.foreground", table.get("menuText"),
  507. "MenuItem.background", table.get("menu"),
  508. "MenuItem.selectionForeground", menuItemPressedForeground,
  509. "MenuItem.selectionBackground", menuItemPressedBackground,
  510. "MenuItem.checkIcon", menuItemCheckIcon,
  511. "MenuItem.arrowIcon", menuItemArrowIcon,
  512. "RadioButtonMenuItem.border", menuMarginBorder,
  513. "RadioButtonMenuItem.font", dialogPlain12,
  514. "RadioButtonMenuItem.acceleratorFont", dialogPlain12,
  515. "RadioButtonMenuItem.foreground", table.get("menuText"),
  516. "RadioButtonMenuItem.background", table.get("menu"),
  517. "RadioButtonMenuItem.selectionForeground", menuItemPressedForeground,
  518. "RadioButtonMenuItem.selectionBackground", menuItemPressedBackground,
  519. "RadioButtonMenuItem.checkIcon", radioButtonIcon,
  520. "RadioButtonMenuItem.arrowIcon", menuItemArrowIcon,
  521. "CheckBoxMenuItem.border", menuMarginBorder,
  522. "CheckBoxMenuItem.font", dialogPlain12,
  523. "CheckBoxMenuItem.acceleratorFont", dialogPlain12,
  524. "CheckBoxMenuItem.foreground", table.get("menuText"),
  525. "CheckBoxMenuItem.background", table.get("menu"),
  526. "CheckBoxMenuItem.selectionForeground", menuItemPressedForeground,
  527. "CheckBoxMenuItem.selectionBackground", menuItemPressedBackground,
  528. "CheckBoxMenuItem.checkIcon", checkBoxIcon,
  529. "CheckBoxMenuItem.arrowIcon", menuItemArrowIcon,
  530. "PopupMenu.background", table.get("menu"),
  531. "PopupMenu.border", raisedBevelBorder,
  532. "PopupMenu.foreground", table.get("menuText"),
  533. "PopupMenu.font", dialogPlain12,
  534. "Label.font", dialogPlain12,
  535. "Label.background", table.get("control"),
  536. "Label.foreground", table.get("controlText"),
  537. "Separator.shadow", table.get("controlShadow"), // DEPRECATED - DO NOT USE!
  538. "Separator.highlight", table.get("controlLtHighlight"), // DEPRECATED - DO NOT USE!
  539. "Separator.background", table.get("controlLtHighlight"),
  540. "Separator.foreground", table.get("controlShadow"),
  541. "List.focusCellHighlightBorder", focusCellHighlightBorder,
  542. "DesktopIcon.icon", LookAndFeel.makeIcon(getClass(),
  543. "icons/DesktopIcon.gif"),
  544. "DesktopIcon.border", null,
  545. "ScrollBar.background", scrollBarTrack,
  546. "ScrollBar.foreground", table.get("control"),
  547. "ScrollBar.track", scrollBarTrack,
  548. "ScrollBar.trackHighlight", table.get("controlDkShadow"),
  549. "ScrollBar.thumb", table.get("control"),
  550. "ScrollBar.thumbHighlight", table.get("controlHighlight"),
  551. "ScrollBar.thumbDarkShadow", table.get("controlDkShadow"),
  552. "ScrollBar.thumbLightShadow", table.get("controlShadow"),
  553. "ScrollBar.border", loweredBevelBorder,
  554. "ScrollPane.font", dialogPlain12,
  555. "ScrollPane.background", table.get("control"),
  556. "ScrollPane.foreground", table.get("controlText"),
  557. "ScrollPane.border", null,
  558. "ScrollPane.viewportBorder", loweredBevelBorder,
  559. "Slider.border", focusBevelBorder,
  560. "Slider.foreground", table.get("control"),
  561. "Slider.background", controlDarker,
  562. "Slider.highlight", table.get("controlHighlight"),
  563. "Slider.shadow", table.get("controlShadow"),
  564. "Slider.focus", table.get("controlDkShadow"),
  565. "Slider.focusInsets", sliderFocusInsets,
  566. "SplitPane.background", table.get("control"),
  567. "SplitPane.highlight", table.get("controlHighlight"),
  568. "SplitPane.shadow", table.get("controlShadow"),
  569. "SplitPane.dividerSize", new Integer(18),
  570. "SplitPane.activeThumb", table.get("activeCaptionBorder"),
  571. "TabbedPane.font", dialogPlain12,
  572. "TabbedPane.background", table.get("control"),
  573. "TabbedPane.foreground", table.get("controlText"),
  574. "TabbedPane.highlight", table.get("controlHighlight"),
  575. "TabbedPane.lightHighlight", table.get("controlLtHighlight"),
  576. "TabbedPane.shadow", table.get("controlShadow"),
  577. "TabbedPane.darkShadow", table.get("controlShadow"),
  578. "TabbedPane.unselectedTabBackground", unselectedTabBackground,
  579. "TabbedPane.unselectedTabForeground", unselectedTabForeground,
  580. "TabbedPane.unselectedTabHighlight", unselectedTabHighlight,
  581. "TabbedPane.unselectedTabShadow", unselectedTabShadow,
  582. "TabbedPane.focus", table.get("activeCaptionBorder"),
  583. "TabbedPane.tabInsets", tabbedPaneTabInsets,
  584. "TabbedPane.selectedTabPadInsets", tabbedPaneTabPadInsets,
  585. "TabbedPane.tabAreaInsets", tabbedPaneTabAreaInsets,
  586. "TabbedPane.contentBorderInsets", tabbedPaneContentBorderInsets,
  587. "Tree.background", controlDarker, // default: dark slate blue
  588. "Tree.hash", table.get("controlDkShadow"), // default: black
  589. "Tree.iconShadow", table.get("controlShadow"),
  590. "Tree.iconHighlight", table.get("controlHighlight"),
  591. "Tree.iconBackground", table.get("control"),
  592. "Tree.iconForeground", table.get("controlShadow"), // default: black
  593. "Tree.textBackground", controlDarker, // default: dark slate blue
  594. "Tree.textForeground", table.get("textText"), // default: black
  595. "Tree.selectionBackground", table.get("text"), // default: white
  596. "Tree.selectionForeground", table.get("textText"), // default: black
  597. "Tree.selectionBorderColor", table.get("activeCaptionBorder"), // default: maroon
  598. "Tree.openIcon", treeOpenIcon,
  599. "Tree.closedIcon", treeClosedIcon,
  600. "Tree.leafIcon", treeLeafIcon,
  601. "Tree.expandedIcon", treeExpandedIcon,
  602. "Tree.collapsedIcon", treeCollapsedIcon,
  603. "Tree.editorBorder", focusBorder,
  604. "Tree.editorBorderSelectionColor", table.get("activeCaptionBorder"),
  605. "Tree.rowHeight", new Integer(18),
  606. "Tree.changeSelectionWithFocus", Boolean.FALSE,
  607. "Tree.drawsFocusBorderAroundIcon", Boolean.TRUE,
  608. "Table.focusCellHighlightBorder", focusCellHighlightBorder,
  609. "Table.scrollPaneBorder", null,
  610. // "Table.background", white, // cell background color
  611. // "Table.focusCellBackground", white,
  612. "ComboBox.control", table.get("control"),
  613. "ComboBox.controlForeground", black,
  614. "ComboBox.background", table.get("window"),
  615. "ComboBox.foreground", black,
  616. "ComboBox.border", comboBoxBorder,
  617. "ComboBox.selectionBackground", black,
  618. "ComboBox.selectionForeground", table.get("text"),
  619. "ComboBox.disabledBackground", table.get("control"),
  620. "ComboBox.disabledForeground", table.get("textInactiveText"),
  621. "ComboBox.font", dialogPlain12,
  622. "TextField.caretForeground", black,
  623. "TextField.caretBlinkRate", new Integer(500),
  624. "TextField.inactiveForeground", table.get("textInactiveText"),
  625. "TextField.selectionBackground", table.get("textHighlight"),
  626. "TextField.selectionForeground", table.get("textHighlightText"),
  627. "TextField.background", table.get("window"),
  628. "TextField.foreground", table.get("textText"),
  629. "TextField.font", sansSerifPlain12,
  630. "TextField.border", textFieldBorder,
  631. "TextField.keyBindings", fieldBindings,
  632. "PasswordField.caretForeground", black,
  633. "PasswordField.caretBlinkRate", new Integer(500),
  634. "PasswordField.inactiveForeground", table.get("textInactiveText"),
  635. "PasswordField.selectionBackground", table.get("textHighlight"),
  636. "PasswordField.selectionForeground", table.get("textHighlightText"),
  637. "PasswordField.background", table.get("window"),
  638. "PasswordField.foreground", table.get("textText"),
  639. "PasswordField.font", monospacedPlain12,
  640. "PasswordField.border", textFieldBorder,
  641. "PasswordField.keyBindings", fieldBindings,
  642. "TextArea.caretForeground", black,
  643. "TextArea.caretBlinkRate", new Integer(500),
  644. "TextArea.inactiveForeground", table.get("textInactiveText"),
  645. "TextArea.selectionBackground", table.get("textHighlight"),
  646. "TextArea.selectionForeground", table.get("textHighlightText"),
  647. "TextArea.background", table.get("window"),
  648. "TextArea.foreground", table.get("textText"),
  649. "TextArea.font", monospacedPlain12,
  650. "TextArea.border", marginBorder,
  651. "TextArea.keyBindings", multilineBindings,
  652. "TextPane.caretForeground", black,
  653. "TextPane.caretBlinkRate", new Integer(500),
  654. "TextPane.inactiveForeground", table.get("textInactiveText"),
  655. "TextPane.selectionBackground", lightGray,
  656. "TextPane.selectionForeground", table.get("textHighlightText"),
  657. "TextPane.background", white,
  658. "TextPane.foreground", table.get("textText"),
  659. "TextPane.font", serifPlain12,
  660. "TextPane.border", marginBorder,
  661. "TextPane.keyBindings", multilineBindings,
  662. "EditorPane.caretForeground", red,
  663. "EditorPane.caretBlinkRate", new Integer(500),
  664. "EditorPane.inactiveForeground", table.get("textInactiveText"),
  665. "EditorPane.selectionBackground", lightGray,
  666. "EditorPane.selectionForeground", table.get("textHighlightText"),
  667. "EditorPane.background", white,
  668. "EditorPane.foreground", table.get("textText"),
  669. "EditorPane.font", serifPlain12,
  670. "EditorPane.border", marginBorder,
  671. "EditorPane.keyBindings", multilineBindings,
  672. "FileChooser.pathLabelMnemonic", new Integer(KeyEvent.VK_P), // 'p'
  673. "FileChooser.filterLabelMnemonic", new Integer (KeyEvent.VK_R), // 'r'
  674. "FileChooser.foldersLabelMnemonic", new Integer (KeyEvent.VK_O), // 'o'
  675. "FileChooser.filesLabelMnemonic", new Integer (KeyEvent.VK_I), // 'i'
  676. "FileChooser.enterFileNameLabelMnemonic", new Integer (KeyEvent.VK_N), // 'n'
  677. "ToolTip.border", raisedBevelBorder,
  678. "ToolTip.background", table.get("info"),
  679. "ToolTip.foreground", table.get("infoText"),
  680. "OptionPane.border", optionPaneBorder,
  681. "OptionPane.messageAreaBorder", optionPaneMessageAreaBorder,
  682. "OptionPane.buttonAreaBorder", optionPaneButtonAreaBorder,
  683. "OptionPane.errorIcon", LookAndFeel.makeIcon(getClass(),
  684. "icons/Error.gif"),
  685. "OptionPane.informationIcon", LookAndFeel.makeIcon(getClass(),
  686. "icons/Inform.gif"),
  687. "OptionPane.warningIcon", LookAndFeel.makeIcon(getClass(),
  688. "icons/Warn.gif"),
  689. "OptionPane.questionIcon", LookAndFeel.makeIcon(getClass(),
  690. "icons/Question.gif")
  691. };
  692. table.putDefaults(defaults);
  693. }
  694. /*
  695. * Returns whether this is being run on a JDK 1.2 or later VM.
  696. * This is a system-wide, rather than AppContext-wide, state.
  697. */
  698. /*package-private*/ static boolean is1dot2 = true;
  699. static {
  700. try {
  701. // Test if method introduced in 1.2 is available.
  702. Method m = Toolkit.class.getMethod("getMaximumCursorColors", null);
  703. is1dot2 = (m != null);
  704. } catch (NoSuchMethodException e) {
  705. is1dot2 = false;
  706. }
  707. }
  708. }