47 |
import java.util.Locale; |
import java.util.Locale; |
48 |
|
|
49 |
import javax.swing.border.Border; |
import javax.swing.border.Border; |
50 |
|
import javax.swing.event.SwingPropertyChangeSupport; |
51 |
import javax.swing.plaf.ComponentUI; |
import javax.swing.plaf.ComponentUI; |
52 |
import javax.swing.plaf.metal.MetalLookAndFeel; |
import javax.swing.plaf.metal.MetalLookAndFeel; |
53 |
|
|
54 |
|
/** |
55 |
|
* Manages the current {@link LookAndFeel} and any auxiliary {@link LookAndFeel} |
56 |
|
* instances. |
57 |
|
*/ |
58 |
public class UIManager implements Serializable |
public class UIManager implements Serializable |
59 |
{ |
{ |
60 |
|
/** |
61 |
|
* Represents the basic information about a {@link LookAndFeel} (LAF), so |
62 |
|
* that a list of installed LAFs can be presented without actually loading |
63 |
|
* the LAF class(es). |
64 |
|
*/ |
65 |
public static class LookAndFeelInfo |
public static class LookAndFeelInfo |
66 |
{ |
{ |
67 |
String name, clazz; |
String name, clazz; |
68 |
|
|
69 |
|
/** |
70 |
|
* Creates a new instance. |
71 |
|
* |
72 |
|
* @param name the look and feel name. |
73 |
|
* @param clazz the look and feel class name. |
74 |
|
*/ |
75 |
public LookAndFeelInfo(String name, |
public LookAndFeelInfo(String name, |
76 |
String clazz) |
String clazz) |
77 |
{ |
{ |
79 |
this.clazz = clazz; |
this.clazz = clazz; |
80 |
} |
} |
81 |
|
|
82 |
|
/** |
83 |
|
* Returns the name of the look and feel. |
84 |
|
* |
85 |
|
* @return The name of the look and feel. |
86 |
|
*/ |
87 |
public String getName() |
public String getName() |
88 |
{ |
{ |
89 |
return name; |
return name; |
90 |
} |
} |
91 |
|
|
92 |
|
/** |
93 |
|
* Returns the fully qualified class name for the {@link LookAndFeel}. |
94 |
|
* |
95 |
|
* @return The fully qualified class name for the {@link LookAndFeel}. |
96 |
|
*/ |
97 |
public String getClassName() |
public String getClassName() |
98 |
{ |
{ |
99 |
return clazz; |
return clazz; |
119 |
|
|
120 |
private static final long serialVersionUID = -5547433830339189365L; |
private static final long serialVersionUID = -5547433830339189365L; |
121 |
|
|
122 |
|
/** The installed look and feel(s). */ |
123 |
static LookAndFeelInfo [] installed = { |
static LookAndFeelInfo [] installed = { |
124 |
new LookAndFeelInfo ("Metal", "javax.swing.plaf.metal.MetalLookAndFeel") |
new LookAndFeelInfo("Metal", "javax.swing.plaf.metal.MetalLookAndFeel") |
125 |
}; |
}; |
126 |
|
|
127 |
static LookAndFeel[] aux_installed; |
/** The installed auxiliary look and feels. */ |
128 |
|
static LookAndFeel[] auxLookAndFeels; |
129 |
|
|
130 |
|
/** The current look and feel. */ |
131 |
|
static LookAndFeel currentLookAndFeel; |
132 |
|
|
133 |
static LookAndFeel look_and_feel = new MetalLookAndFeel(); |
static UIDefaults currentUIDefaults; |
134 |
|
|
135 |
|
/** Property change listener mechanism. */ |
136 |
|
static SwingPropertyChangeSupport listeners |
137 |
|
= new SwingPropertyChangeSupport(UIManager.class); |
138 |
|
|
139 |
static |
static |
140 |
{ |
{ |
153 |
System.err.println("error: " + ex.getMessage()); |
System.err.println("error: " + ex.getMessage()); |
154 |
System.err.println("falling back to Metal Look and Feel"); |
System.err.println("falling back to Metal Look and Feel"); |
155 |
} |
} |
156 |
} |
currentLookAndFeel = new MetalLookAndFeel(); |
157 |
|
currentLookAndFeel.initialize(); |
158 |
|
currentUIDefaults = currentLookAndFeel.getDefaults(); |
159 |
|
|
160 |
|
} |
161 |
|
|
162 |
|
/** |
163 |
|
* Creates a new instance of the <code>UIManager</code>. There is no need |
164 |
|
* to construct an instance of this class, since all methods are static. |
165 |
|
*/ |
166 |
public UIManager() |
public UIManager() |
167 |
{ |
{ |
168 |
// Do nothing here. |
// Do nothing here. |
175 |
*/ |
*/ |
176 |
public static void addPropertyChangeListener(PropertyChangeListener listener) |
public static void addPropertyChangeListener(PropertyChangeListener listener) |
177 |
{ |
{ |
178 |
// FIXME |
listeners.addPropertyChangeListener(listener); |
179 |
} |
} |
180 |
|
|
181 |
/** |
/** |
183 |
* |
* |
184 |
* @param listener the listener to remove |
* @param listener the listener to remove |
185 |
*/ |
*/ |
186 |
public static void removePropertyChangeListener(PropertyChangeListener listener) |
public static void removePropertyChangeListener(PropertyChangeListener |
187 |
|
listener) |
188 |
{ |
{ |
189 |
// FIXME |
listeners.removePropertyChangeListener(listener); |
190 |
} |
} |
191 |
|
|
192 |
/** |
/** |
198 |
*/ |
*/ |
199 |
public static PropertyChangeListener[] getPropertyChangeListeners() |
public static PropertyChangeListener[] getPropertyChangeListeners() |
200 |
{ |
{ |
201 |
// FIXME |
return listeners.getPropertyChangeListeners(); |
|
throw new Error ("Not implemented"); |
|
202 |
} |
} |
203 |
|
|
204 |
/** |
/** |
205 |
* Add a LookAndFeel to the list of auxiliary look and feels. |
* Add a {@link LookAndFeel} to the list of auxiliary look and feels. |
206 |
|
* |
207 |
|
* @param laf the auxiliary look and feel (<code>null</code> not permitted). |
208 |
|
* |
209 |
|
* @throws NullPointerException if <code>laf</code> is <code>null</code>. |
210 |
|
* |
211 |
|
* @see #getAuxiliaryLookAndFeels() |
212 |
*/ |
*/ |
213 |
public static void addAuxiliaryLookAndFeel (LookAndFeel l) |
public static void addAuxiliaryLookAndFeel(LookAndFeel laf) |
214 |
{ |
{ |
215 |
if (aux_installed == null) |
if (laf == null) |
216 |
|
throw new NullPointerException("Null 'laf' argument."); |
217 |
|
if (auxLookAndFeels == null) |
218 |
{ |
{ |
219 |
aux_installed = new LookAndFeel[1]; |
auxLookAndFeels = new LookAndFeel[1]; |
220 |
aux_installed[0] = l; |
auxLookAndFeels[0] = laf; |
221 |
return; |
return; |
222 |
} |
} |
223 |
|
|
224 |
LookAndFeel[] T = new LookAndFeel[ aux_installed.length+1 ]; |
LookAndFeel[] temp = new LookAndFeel[auxLookAndFeels.length + 1]; |
225 |
System.arraycopy(aux_installed, 0, T, 0, aux_installed.length); |
System.arraycopy(auxLookAndFeels, 0, temp, 0, auxLookAndFeels.length); |
226 |
aux_installed = T; |
auxLookAndFeels = temp; |
227 |
aux_installed[aux_installed.length-1] = l; |
auxLookAndFeels[auxLookAndFeels.length - 1] = laf; |
228 |
} |
} |
229 |
|
|
230 |
|
/** |
231 |
|
* Removes a {@link LookAndFeel} (LAF) from the list of auxiliary LAFs. |
232 |
|
* |
233 |
|
* @param laf the LAF to remove. |
234 |
|
* |
235 |
|
* @return <code>true</code> if the LAF was removed, and <code>false</code> |
236 |
|
* otherwise. |
237 |
|
*/ |
238 |
public static boolean removeAuxiliaryLookAndFeel(LookAndFeel laf) |
public static boolean removeAuxiliaryLookAndFeel(LookAndFeel laf) |
239 |
{ |
{ |
240 |
if (aux_installed == null) |
if (auxLookAndFeels == null) |
241 |
return false; |
return false; |
242 |
|
int count = auxLookAndFeels.length; |
243 |
for (int i=0;i<aux_installed.length;i++) |
if (count == 1 && auxLookAndFeels[0] == laf) |
244 |
{ |
{ |
245 |
if (aux_installed[i] == laf) |
auxLookAndFeels = null; |
246 |
|
return true; |
247 |
|
} |
248 |
|
for (int i = 0; i < count; i++) |
249 |
|
{ |
250 |
|
if (auxLookAndFeels[i] == laf) |
251 |
{ |
{ |
252 |
aux_installed[ i ] = aux_installed[aux_installed.length-1]; |
LookAndFeel[] temp = new LookAndFeel[auxLookAndFeels.length - 1]; |
253 |
LookAndFeel[] T = new LookAndFeel[ aux_installed.length-1 ]; |
if (i == 0) |
254 |
System.arraycopy (aux_installed, 0, T, 0, aux_installed.length-1); |
{ |
255 |
aux_installed = T; |
System.arraycopy(auxLookAndFeels, 1, temp, 0, count - 1); |
256 |
|
} |
257 |
|
else if (i == count - 1) |
258 |
|
{ |
259 |
|
System.arraycopy(auxLookAndFeels, 0, temp, 0, count - 1); |
260 |
|
} |
261 |
|
else |
262 |
|
{ |
263 |
|
System.arraycopy(auxLookAndFeels, 0, temp, 0, i); |
264 |
|
System.arraycopy(auxLookAndFeels, i + 1, temp, i, |
265 |
|
count - i - 1); |
266 |
|
} |
267 |
|
auxLookAndFeels = temp; |
268 |
return true; |
return true; |
269 |
} |
} |
270 |
} |
} |
271 |
return false; |
return false; |
272 |
} |
} |
273 |
|
|
274 |
public static LookAndFeel[] getAuxiliaryLookAndFeels() |
/** |
275 |
|
* Returns an array (possibly <code>null</code>) containing the auxiliary |
276 |
|
* {@link LookAndFeel}s that are in use. These are used by the |
277 |
|
* {@link javax.swing.plaf.multi.MultiLookAndFeel} class. |
278 |
|
* |
279 |
|
* @return The auxiliary look and feels (possibly <code>null</code>). |
280 |
|
* |
281 |
|
* @see #addAuxiliaryLookAndFeel(LookAndFeel) |
282 |
|
*/ |
283 |
|
public static LookAndFeel[] getAuxiliaryLookAndFeels() |
284 |
{ |
{ |
285 |
return aux_installed; |
return auxLookAndFeels; |
286 |
} |
} |
287 |
|
|
288 |
public static Object get(Object key) |
/** |
289 |
|
* Returns an object from the {@link UIDefaults} table for the current |
290 |
|
* {@link LookAndFeel}. |
291 |
|
* |
292 |
|
* @param key the key. |
293 |
|
* |
294 |
|
* @return The object. |
295 |
|
*/ |
296 |
|
public static Object get(Object key) |
297 |
{ |
{ |
298 |
return getLookAndFeel().getDefaults().get(key); |
return getLookAndFeelDefaults().get(key); |
299 |
} |
} |
300 |
|
|
301 |
public static Object get(Object key, Locale locale) |
/** |
302 |
|
* Returns an object from the {@link UIDefaults} table for the current |
303 |
|
* {@link LookAndFeel}. |
304 |
|
* |
305 |
|
* @param key the key. |
306 |
|
* |
307 |
|
* @return The object. |
308 |
|
*/ |
309 |
|
public static Object get(Object key, Locale locale) |
310 |
{ |
{ |
311 |
return getLookAndFeel().getDefaults().get(key ,locale); |
return getLookAndFeelDefaults().get(key ,locale); |
312 |
} |
} |
313 |
|
|
314 |
/** |
/** |
319 |
*/ |
*/ |
320 |
public static boolean getBoolean(Object key) |
public static boolean getBoolean(Object key) |
321 |
{ |
{ |
322 |
Boolean value = (Boolean) getLookAndFeel().getDefaults().get(key); |
Boolean value = (Boolean) getLookAndFeelDefaults().get(key); |
323 |
return value != null ? value.booleanValue() : false; |
return value != null ? value.booleanValue() : false; |
324 |
} |
} |
325 |
|
|
331 |
*/ |
*/ |
332 |
public static boolean getBoolean(Object key, Locale locale) |
public static boolean getBoolean(Object key, Locale locale) |
333 |
{ |
{ |
334 |
Boolean value = (Boolean) getLookAndFeel().getDefaults().get(key, locale); |
Boolean value = (Boolean) getLookAndFeelDefaults().get(key, locale); |
335 |
return value != null ? value.booleanValue() : false; |
return value != null ? value.booleanValue() : false; |
336 |
} |
} |
337 |
|
|
340 |
*/ |
*/ |
341 |
public static Border getBorder(Object key) |
public static Border getBorder(Object key) |
342 |
{ |
{ |
343 |
return (Border) getLookAndFeel().getDefaults().get(key); |
return (Border) getLookAndFeelDefaults().get(key); |
344 |
} |
} |
345 |
|
|
346 |
/** |
/** |
350 |
*/ |
*/ |
351 |
public static Border getBorder(Object key, Locale locale) |
public static Border getBorder(Object key, Locale locale) |
352 |
{ |
{ |
353 |
return (Border) getLookAndFeel().getDefaults().get(key, locale); |
return (Border) getLookAndFeelDefaults().get(key, locale); |
354 |
} |
} |
355 |
|
|
356 |
/** |
/** |
357 |
* Returns a drawing color from the defaults table. |
* Returns a drawing color from the defaults table. |
358 |
*/ |
*/ |
359 |
public static Color getColor(Object key) |
public static Color getColor(Object key) |
360 |
{ |
{ |
361 |
return (Color) getLookAndFeel().getDefaults().get(key); |
return (Color) getLookAndFeelDefaults().get(key); |
362 |
} |
} |
363 |
|
|
364 |
/** |
/** |
365 |
* Returns a drawing color from the defaults table. |
* Returns a drawing color from the defaults table. |
366 |
*/ |
*/ |
367 |
public static Color getColor(Object key, Locale locale) |
public static Color getColor(Object key, Locale locale) |
368 |
{ |
{ |
369 |
return (Color) getLookAndFeel().getDefaults().get(key); |
return (Color) getLookAndFeelDefaults().get(key); |
370 |
} |
} |
371 |
|
|
372 |
/** |
/** |
373 |
* this string can be passed to Class.forName() |
* The fully qualified class name of the cross platform (Metal) look and feel. |
374 |
|
* This string can be passed to Class.forName() |
375 |
|
* |
376 |
|
* @return <code>"javax.swing.plaf.metal.MetalLookAndFeel"</code> |
377 |
*/ |
*/ |
378 |
public static String getCrossPlatformLookAndFeelClassName() |
public static String getCrossPlatformLookAndFeelClassName() |
379 |
{ |
{ |
380 |
return "javax.swing.plaf.metal.MetalLookAndFeel"; |
return "javax.swing.plaf.metal.MetalLookAndFeel"; |
381 |
} |
} |
382 |
|
|
383 |
/** |
/** |
384 |
* Returns the default values for this look and feel. |
* Returns the default values for this look and feel. |
385 |
|
* |
386 |
|
* @return The {@link UIDefaults} for the current {@link LookAndFeel}. |
387 |
*/ |
*/ |
388 |
public static UIDefaults getDefaults() |
public static UIDefaults getDefaults() |
389 |
{ |
{ |
390 |
return getLookAndFeel().getDefaults(); |
return currentUIDefaults; |
391 |
} |
} |
392 |
|
|
393 |
/** |
/** |
395 |
*/ |
*/ |
396 |
public static Dimension getDimension(Object key) |
public static Dimension getDimension(Object key) |
397 |
{ |
{ |
398 |
return (Dimension) getLookAndFeel().getDefaults().get(key); |
return (Dimension) getLookAndFeelDefaults().get(key); |
399 |
} |
} |
400 |
|
|
401 |
/** |
/** |
403 |
*/ |
*/ |
404 |
public static Dimension getDimension(Object key, Locale locale) |
public static Dimension getDimension(Object key, Locale locale) |
405 |
{ |
{ |
406 |
return (Dimension) getLookAndFeel().getDefaults().get(key, locale); |
return (Dimension) getLookAndFeelDefaults().get(key, locale); |
407 |
} |
} |
408 |
|
|
409 |
/** |
/** |
416 |
*/ |
*/ |
417 |
public static Font getFont(Object key) |
public static Font getFont(Object key) |
418 |
{ |
{ |
419 |
return (Font) getLookAndFeel().getDefaults().get(key); |
return (Font) getLookAndFeelDefaults().get(key); |
420 |
} |
} |
421 |
|
|
422 |
/** |
/** |
429 |
*/ |
*/ |
430 |
public static Font getFont(Object key, Locale locale) |
public static Font getFont(Object key, Locale locale) |
431 |
{ |
{ |
432 |
return (Font) getLookAndFeel().getDefaults().get(key ,locale); |
return (Font) getLookAndFeelDefaults().get(key ,locale); |
433 |
} |
} |
434 |
|
|
435 |
/** |
/** |
437 |
*/ |
*/ |
438 |
public static Icon getIcon(Object key) |
public static Icon getIcon(Object key) |
439 |
{ |
{ |
440 |
return (Icon) getLookAndFeel().getDefaults().get(key); |
return (Icon) getLookAndFeelDefaults().get(key); |
441 |
} |
} |
442 |
|
|
443 |
/** |
/** |
445 |
*/ |
*/ |
446 |
public static Icon getIcon(Object key, Locale locale) |
public static Icon getIcon(Object key, Locale locale) |
447 |
{ |
{ |
448 |
return (Icon) getLookAndFeel().getDefaults().get(key, locale); |
return (Icon) getLookAndFeelDefaults().get(key, locale); |
449 |
} |
} |
450 |
|
|
451 |
/** |
/** |
453 |
*/ |
*/ |
454 |
public static Insets getInsets(Object key) |
public static Insets getInsets(Object key) |
455 |
{ |
{ |
456 |
return (Insets) getLookAndFeel().getDefaults().getInsets(key); |
return getLookAndFeelDefaults().getInsets(key); |
457 |
} |
} |
458 |
|
|
459 |
/** |
/** |
461 |
*/ |
*/ |
462 |
public static Insets getInsets(Object key, Locale locale) |
public static Insets getInsets(Object key, Locale locale) |
463 |
{ |
{ |
464 |
return (Insets) getLookAndFeel().getDefaults().getInsets(key, locale); |
return getLookAndFeelDefaults().getInsets(key, locale); |
465 |
} |
} |
466 |
|
|
467 |
|
/** |
468 |
|
* Returns an array containing information about the {@link LookAndFeel}s |
469 |
|
* that are installed. |
470 |
|
* |
471 |
|
* @return A list of the look and feels that are available (installed). |
472 |
|
*/ |
473 |
public static LookAndFeelInfo[] getInstalledLookAndFeels() |
public static LookAndFeelInfo[] getInstalledLookAndFeels() |
474 |
{ |
{ |
475 |
return installed; |
return installed; |
477 |
|
|
478 |
public static int getInt(Object key) |
public static int getInt(Object key) |
479 |
{ |
{ |
480 |
Integer x = (Integer) getLookAndFeel().getDefaults().get(key); |
Integer x = (Integer) getLookAndFeelDefaults().get(key); |
481 |
if (x == null) |
if (x == null) |
482 |
return 0; |
return 0; |
483 |
return x.intValue(); |
return x.intValue(); |
485 |
|
|
486 |
public static int getInt(Object key, Locale locale) |
public static int getInt(Object key, Locale locale) |
487 |
{ |
{ |
488 |
Integer x = (Integer) getLookAndFeel().getDefaults().get(key, locale); |
Integer x = (Integer) getLookAndFeelDefaults().get(key, locale); |
489 |
if (x == null) |
if (x == null) |
490 |
return 0; |
return 0; |
491 |
return x.intValue(); |
return x.intValue(); |
492 |
} |
} |
493 |
|
|
494 |
|
/** |
495 |
|
* Returns the current look and feel (which may be <code>null</code>). |
496 |
|
* |
497 |
|
* @return The current look and feel. |
498 |
|
* |
499 |
|
* @see #setLookAndFeel(LookAndFeel) |
500 |
|
*/ |
501 |
public static LookAndFeel getLookAndFeel() |
public static LookAndFeel getLookAndFeel() |
502 |
{ |
{ |
503 |
return look_and_feel; |
return currentLookAndFeel; |
504 |
} |
} |
505 |
|
|
506 |
/** |
/** |
507 |
* Returns the <code>UIDefaults</code> table of the currently active |
* Returns the <code>UIDefaults</code> table of the currently active |
508 |
* look and feel. |
* look and feel. |
509 |
|
* |
510 |
|
* @return The {@link UIDefaults} for the current {@link LookAndFeel}. |
511 |
*/ |
*/ |
512 |
public static UIDefaults getLookAndFeelDefaults() |
public static UIDefaults getLookAndFeelDefaults() |
513 |
{ |
{ |
514 |
return getLookAndFeel().getDefaults(); |
return currentUIDefaults; |
515 |
} |
} |
516 |
|
|
517 |
/** |
/** |
519 |
*/ |
*/ |
520 |
public static String getString(Object key) |
public static String getString(Object key) |
521 |
{ |
{ |
522 |
return (String) getLookAndFeel().getDefaults().get(key); |
return (String) getLookAndFeelDefaults().get(key); |
523 |
} |
} |
524 |
|
|
525 |
/** |
/** |
527 |
*/ |
*/ |
528 |
public static String getString(Object key, Locale locale) |
public static String getString(Object key, Locale locale) |
529 |
{ |
{ |
530 |
return (String) getLookAndFeel().getDefaults().get(key, locale); |
return (String) getLookAndFeelDefaults().get(key, locale); |
531 |
} |
} |
532 |
|
|
533 |
/** |
/** |
534 |
* Returns the name of the LookAndFeel class that implements the |
* Returns the name of the {@link LookAndFeel} class that implements the |
535 |
* native systems look and feel if there is one, otherwise the name |
* native systems look and feel if there is one, otherwise the name |
536 |
* of the default cross platform LookAndFeel class. |
* of the default cross platform LookAndFeel class. |
537 |
|
* |
538 |
|
* @return The fully qualified class name for the system look and feel. |
539 |
|
* |
540 |
|
* @see #getCrossPlatformLookAndFeelClassName() |
541 |
*/ |
*/ |
542 |
public static String getSystemLookAndFeelClassName() |
public static String getSystemLookAndFeelClassName() |
543 |
{ |
{ |
545 |
} |
} |
546 |
|
|
547 |
/** |
/** |
548 |
* Returns the Look and Feel object that renders the target component. |
* Returns UI delegate from the current {@link LookAndFeel} that renders the |
549 |
|
* target component. |
550 |
|
* |
551 |
|
* @param target the target component. |
552 |
*/ |
*/ |
553 |
public static ComponentUI getUI(JComponent target) |
public static ComponentUI getUI(JComponent target) |
554 |
{ |
{ |
555 |
return getDefaults().getUI(target); |
return getLookAndFeelDefaults().getUI(target); |
556 |
} |
} |
557 |
|
|
558 |
/** |
/** |
559 |
* Creates a new look and feel and adds it to the current array. |
* Creates a new look and feel and adds it to the current array. |
560 |
|
* |
561 |
|
* @param name the look and feel name. |
562 |
|
* @param className the fully qualified name of the class that implements the |
563 |
|
* look and feel. |
564 |
*/ |
*/ |
565 |
public static void installLookAndFeel(String name, String className) |
public static void installLookAndFeel(String name, String className) |
566 |
{ |
{ |
567 |
|
installLookAndFeel(new LookAndFeelInfo(name, className)); |
568 |
} |
} |
569 |
|
|
570 |
/** |
/** |
573 |
*/ |
*/ |
574 |
public static void installLookAndFeel(LookAndFeelInfo info) |
public static void installLookAndFeel(LookAndFeelInfo info) |
575 |
{ |
{ |
576 |
|
// FIXME: not yet implemented |
577 |
} |
} |
578 |
|
|
579 |
/** |
/** |
581 |
*/ |
*/ |
582 |
public static Object put(Object key, Object value) |
public static Object put(Object key, Object value) |
583 |
{ |
{ |
584 |
return getLookAndFeel().getDefaults().put(key,value); |
return getLookAndFeelDefaults().put(key,value); |
585 |
} |
} |
586 |
|
|
587 |
/** |
/** |
589 |
*/ |
*/ |
590 |
public static void setInstalledLookAndFeels(UIManager.LookAndFeelInfo[] infos) |
public static void setInstalledLookAndFeels(UIManager.LookAndFeelInfo[] infos) |
591 |
{ |
{ |
592 |
|
// FIXME: not yet implemented. |
593 |
} |
} |
594 |
|
|
595 |
/** |
/** |
596 |
* Set the current default look. |
* Sets the current {@link LookAndFeel}. |
597 |
|
* |
598 |
|
* @param newLookAndFeel the new look and feel (<code>null</code> permitted). |
599 |
|
* |
600 |
|
* @throws UnsupportedLookAndFeelException if the look and feel is not |
601 |
|
* supported on the current platform. |
602 |
|
* |
603 |
|
* @see LookAndFeel#isSupportedLookAndFeel() |
604 |
*/ |
*/ |
605 |
public static void setLookAndFeel(LookAndFeel newLookAndFeel) |
public static void setLookAndFeel(LookAndFeel newLookAndFeel) |
606 |
throws UnsupportedLookAndFeelException |
throws UnsupportedLookAndFeelException |
607 |
{ |
{ |
608 |
if (! newLookAndFeel.isSupportedLookAndFeel()) |
if (newLookAndFeel != null && ! newLookAndFeel.isSupportedLookAndFeel()) |
609 |
throw new UnsupportedLookAndFeelException(newLookAndFeel.getName()); |
throw new UnsupportedLookAndFeelException(newLookAndFeel.getName()); |
610 |
|
|
611 |
if (look_and_feel != null) |
LookAndFeel oldLookAndFeel = currentLookAndFeel; |
612 |
look_and_feel.uninitialize(); |
if (oldLookAndFeel != null) |
613 |
|
oldLookAndFeel.uninitialize(); |
614 |
|
|
615 |
// Set the current default look and feel using a LookAndFeel object. |
// Set the current default look and feel using a LookAndFeel object. |
616 |
look_and_feel = newLookAndFeel; |
currentLookAndFeel = newLookAndFeel; |
617 |
look_and_feel.initialize(); |
if (newLookAndFeel != null) |
618 |
|
{ |
619 |
|
newLookAndFeel.initialize(); |
620 |
|
currentUIDefaults = newLookAndFeel.getDefaults(); |
621 |
|
} |
622 |
|
else |
623 |
|
{ |
624 |
|
currentUIDefaults = null; |
625 |
|
} |
626 |
|
listeners.firePropertyChange("lookAndFeel", oldLookAndFeel, newLookAndFeel); |
627 |
//revalidate(); |
//revalidate(); |
628 |
//repaint(); |
//repaint(); |
629 |
} |
} |
630 |
|
|
631 |
/** |
/** |
632 |
* Set the current default look and feel using a class name. |
* Set the current default look and feel using a class name. |
633 |
|
* |
634 |
|
* @param className the look and feel class name. |
635 |
|
* |
636 |
|
* @throws UnsupportedLookAndFeelException if the look and feel is not |
637 |
|
* supported on the current platform. |
638 |
|
* |
639 |
|
* @see LookAndFeel#isSupportedLookAndFeel() |
640 |
*/ |
*/ |
641 |
public static void setLookAndFeel (String className) |
public static void setLookAndFeel(String className) |
642 |
throws ClassNotFoundException, InstantiationException, IllegalAccessException, |
throws ClassNotFoundException, InstantiationException, IllegalAccessException, |
643 |
UnsupportedLookAndFeelException |
UnsupportedLookAndFeelException |
644 |
{ |
{ |