1:
21:
22: package ;
23:
24: import ;
25: import ;
26: import ;
27:
28: import ;
29: import ;
30: import ;
31: import ;
32: import ;
33: import ;
34: import ;
35: import ;
36:
37: public class GNULookAndFeel extends BasicLookAndFeel
38: {
39:
40: static Color blueGray = new Color(0xdc, 0xda, 0xd5);
41:
42: public boolean isNativeLookAndFeel() { return true; }
43: public boolean isSupportedLookAndFeel() { return true; }
44: public String getDescription() { return "GNU Look and Feel"; }
45: public String getID() { return "GNULookAndFeel"; }
46: public String getName() { return "GNU"; }
47:
48: static UIDefaults LAF_defaults;
49:
50: private final static String iconspath = "/gnu/javax/swing/plaf/gtk/icons/";
51:
52: public UIDefaults getDefaults()
53: {
54: if (LAF_defaults == null)
55: {
56: LAF_defaults = super.getDefaults();
57: Object[] myDefaults = new Object[] {
58: "Button.background", new ColorUIResource(blueGray),
59: "CheckBox.background", new ColorUIResource(blueGray),
60: "CheckBoxMenuItem.background", new ColorUIResource(blueGray),
61: "ToolBar.background", new ColorUIResource(blueGray),
62: "Panel.background", new ColorUIResource(blueGray),
63: "Slider.background", new ColorUIResource(blueGray),
64: "OptionPane.background", new ColorUIResource(blueGray),
65: "ProgressBar.background", new ColorUIResource(blueGray),
66: "TabbedPane.background", new ColorUIResource(blueGray),
67: "Label.background", new ColorUIResource(blueGray),
68: "Menu.background", new ColorUIResource(blueGray),
69: "MenuBar.background", new ColorUIResource(blueGray),
70: "MenuItem.background", new ColorUIResource(blueGray),
71: "ScrollBar.background", new ColorUIResource(blueGray),
72: "CheckBox.icon", new CheckBoxIcon(),
73: "RadioButton.icon", new RadioButtonIcon(),
74: "Tree.hash", new ColorUIResource(Color.black),
75:
76: "Tree.closedIcon",
77: new IconUIResource(new ImageIcon
78: (getClass().getResource
79: (iconspath + "TreeClosed.png"))),
80: "Tree.leafIcon",
81: new IconUIResource(new ImageIcon
82: (getClass().getResource
83: (iconspath + "TreeLeaf.png"))),
84: "Tree.openIcon",
85: new IconUIResource(new ImageIcon
86: (getClass().getResource
87: (iconspath + "TreeOpen.png"))),
88: };
89: LAF_defaults.putDefaults(myDefaults);
90: }
91: return LAF_defaults;
92: }
93:
94:
98: static class CheckBoxIcon
99: implements Icon
100: {
101:
107: public int getIconHeight()
108: {
109: return 13;
110: }
111:
112:
118: public int getIconWidth()
119: {
120: return 13;
121: }
122:
123:
132: public void paintIcon(Component c, Graphics g, int x, int y)
133: {
134: Color save = g.getColor();
135: g.setColor(c.getForeground());
136: g.drawRect(x, y, getIconWidth(), getIconHeight());
137:
138: JCheckBox item = (JCheckBox) c;
139: if (item.isSelected())
140: {
141: g.drawLine(3 + x, 5 + y, 3 + x, 9 + y);
142: g.drawLine(4 + x, 5 + y, 4 + x, 9 + y);
143: g.drawLine(5 + x, 7 + y, 9 + x, 3 + y);
144: g.drawLine(5 + x, 8 + y, 9 + x, 4 + y);
145: }
146:
147: g.setColor(save);
148: }
149: }
150:
151:
155: static class RadioButtonIcon
156: implements Icon
157: {
158:
164: public int getIconHeight()
165: {
166: return 13;
167: }
168:
169:
175: public int getIconWidth()
176: {
177: return 13;
178: }
179:
180:
189: public void paintIcon(Component c, Graphics g, int x, int y)
190: {
191: Color savedColor = g.getColor();
192: JRadioButton b = (JRadioButton) c;
193:
194:
195: if (b.isEnabled())
196: g.setColor(Color.GRAY);
197: else
198: g.setColor(Color.GRAY);
199: g.drawLine(x + 2, y + 1, x + 3, y + 1);
200: g.drawLine(x + 4, y, x + 7, y);
201: g.drawLine(x + 8, y + 1, x + 9, y + 1);
202: g.drawLine(x + 10, y + 2, x + 10, y + 3);
203: g.drawLine(x + 11, y + 4, x + 11, y + 7);
204: g.drawLine(x + 10, y + 8, x + 10, y + 9);
205: g.drawLine(x + 8, y + 10, x + 9, y + 10);
206: g.drawLine(x + 4, y + 11, x + 7, y + 11);
207: g.drawLine(x + 2, y + 10, x + 3, y + 10);
208: g.drawLine(x + 1, y + 9, x + 1, y + 8);
209: g.drawLine(x, y + 7, x, y + 4);
210: g.drawLine(x + 1, y + 2, x + 1, y + 3);
211:
212: if (b.getModel().isArmed())
213: {
214: g.setColor(Color.GRAY);
215: g.drawLine(x + 4, y + 1, x + 7, y + 1);
216: g.drawLine(x + 4, y + 10, x + 7, y + 10);
217: g.drawLine(x + 1, y + 4, x + 1, y + 7);
218: g.drawLine(x + 10, y + 4, x + 10, y + 7);
219: g.fillRect(x + 2, y + 2, 8, 8);
220: }
221: else
222: {
223:
224: if (b.isEnabled())
225: {
226: g.setColor(Color.WHITE);
227:
228: g.drawLine(x + 2, y + 8, x + 2, y + 9);
229: g.drawLine(x + 1, y + 4, x + 1, y + 7);
230: g.drawLine(x + 2, y + 2, x + 2, y + 3);
231: g.drawLine(x + 3, y + 2, x + 3, y + 2);
232: g.drawLine(x + 4, y + 1, x + 7, y + 1);
233: g.drawLine(x + 8, y + 2, x + 9, y + 2);
234: }
235: }
236:
237:
238: if (b.isEnabled())
239: {
240: g.setColor(Color.WHITE);
241:
242:
243: g.drawLine(x + 10, y + 1, x + 10, y + 1);
244: g.drawLine(x + 11, y + 2, x + 11, y + 3);
245: g.drawLine(x + 12, y + 4, x + 12, y + 7);
246: g.drawLine(x + 11, y + 8, x + 11, y + 9);
247: g.drawLine(x + 10, y + 10, x + 10, y + 10);
248: g.drawLine(x + 8, y + 11, x + 9, y + 11);
249: g.drawLine(x + 4, y + 12, x + 7, y + 12);
250: g.drawLine(x + 2, y + 11, x + 3, y + 11);
251: }
252:
253: if (b.isSelected())
254: {
255: if (b.isEnabled())
256: g.setColor(Color.BLACK);
257: else
258: g.setColor(Color.GRAY);
259: g.drawLine(x + 4, y + 3, x + 7, y + 3);
260: g.fillRect(x + 3, y + 4, 6, 4);
261: g.drawLine(x + 4, y + 8, x + 7, y + 8);
262: }
263: g.setColor(savedColor);
264: }
265: }
266: }