1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.xnap.gui.theme;
21
22 import javax.swing.plaf.FontUIResource;
23
24 import java.awt.Component;
25
26 /***
27 * This class provides a default implementation for a theme. A theme can
28 * customize the fonts and colors of an application.
29 */
30 public abstract class AbstractTheme implements Theme {
31
32
33
34
35
36 private String name;
37
38
39
40 public AbstractTheme(String name)
41 {
42 this.name = name;
43 }
44
45
46
47 /***
48 * Returns false.
49 */
50 public boolean isConfigurable()
51 {
52 return false;
53 }
54
55 /***
56 * Returns false.
57 */
58 public boolean isIconTheme()
59 {
60 return false;
61 }
62
63 /***
64 * Returns the class name of this theme.
65 */
66 public String getClassName()
67 {
68 return getClass().getName();
69 }
70
71 /***
72 * Show a configuration dialog.
73 *
74 * @return true, if theme should be reloaded; false, otherwise
75 * @see #isConfigurable()
76 */
77 public boolean showConfigurationDialog(Component parent)
78 {
79 return false;
80 }
81
82 /***
83 * Returns the name of this theme.
84 */
85 public String getName()
86 {
87 return name;
88 }
89
90 /***
91 * Creates and returns font properties. Sets all fonts to
92 * <code>font</code>.
93 */
94 public static Object[] createProperties(FontUIResource font)
95 {
96 Object[] array = new Object[] {
97 "Table.font", font,
98 "TextPane.font", font,
99 "TextArea.font", font,
100 "TextField.font", font,
101 "PasswordField.font", font,
102 "EditorPane.font", font,
103 "ProgressBar.font", font,
104
105 "MenuBar.font", font,
106 "Menu.font", font,
107 "MenuItem.font", font,
108 "PopupMenu.font", font,
109 "CheckBoxMenuItem.font", font,
110 "RadioButtonMenuItem.font", font,
111
112 "CheckBox.font", font,
113 "ComboBox.font", font,
114 "Button.font", font,
115 "Tree.font", font,
116 "ScrollPane.font", font,
117 "TabbedPane.font", font,
118 "TitledBorder.font", font,
119 "OptionPane.font", font,
120 "ToolBar.font", font,
121 "RadioButton.font", font,
122 "ToggleButton.font", font,
123 "ToolTip.font", font,
124 "TableHeader.font", font,
125 "Panel.font", font,
126 "List.font", font,
127 "ColorChooser.font", font,
128 "Label.font", font,
129 "Viewport.font", font,
130 };
131
132 return array;
133 }
134
135 /***
136 * Returns the name of this theme.
137 */
138 public String toString()
139 {
140 return getName();
141 }
142
143 }