100 |
|
|
101 |
static LookAndFeel[] aux_installed; |
static LookAndFeel[] aux_installed; |
102 |
|
|
103 |
static LookAndFeel look_and_feel = new MetalLookAndFeel(); |
static LookAndFeel currentLookAndFeel; |
104 |
|
|
105 |
|
static UIDefaults currentUIDefaults; |
106 |
|
|
107 |
/** Property change listener mechanism. */ |
/** Property change listener mechanism. */ |
108 |
static SwingPropertyChangeSupport listeners |
static SwingPropertyChangeSupport listeners |
125 |
System.err.println("error: " + ex.getMessage()); |
System.err.println("error: " + ex.getMessage()); |
126 |
System.err.println("falling back to Metal Look and Feel"); |
System.err.println("falling back to Metal Look and Feel"); |
127 |
} |
} |
128 |
} |
currentLookAndFeel = new MetalLookAndFeel(); |
129 |
|
currentLookAndFeel.initialize(); |
130 |
|
currentUIDefaults = currentLookAndFeel.getDefaults(); |
131 |
|
|
132 |
|
} |
133 |
|
|
134 |
public UIManager() |
public UIManager() |
135 |
{ |
{ |
136 |
// Do nothing here. |
// Do nothing here. |
211 |
return aux_installed; |
return aux_installed; |
212 |
} |
} |
213 |
|
|
214 |
public static Object get(Object key) |
public static Object get(Object key) |
215 |
{ |
{ |
216 |
return getLookAndFeel().getDefaults().get(key); |
return getLookAndFeelDefaults().get(key); |
217 |
} |
} |
218 |
|
|
219 |
public static Object get(Object key, Locale locale) |
public static Object get(Object key, Locale locale) |
220 |
{ |
{ |
221 |
return getLookAndFeel().getDefaults().get(key ,locale); |
return getLookAndFeelDefaults().get(key ,locale); |
222 |
} |
} |
223 |
|
|
224 |
/** |
/** |
229 |
*/ |
*/ |
230 |
public static boolean getBoolean(Object key) |
public static boolean getBoolean(Object key) |
231 |
{ |
{ |
232 |
Boolean value = (Boolean) getLookAndFeel().getDefaults().get(key); |
Boolean value = (Boolean) getLookAndFeelDefaults().get(key); |
233 |
return value != null ? value.booleanValue() : false; |
return value != null ? value.booleanValue() : false; |
234 |
} |
} |
235 |
|
|
241 |
*/ |
*/ |
242 |
public static boolean getBoolean(Object key, Locale locale) |
public static boolean getBoolean(Object key, Locale locale) |
243 |
{ |
{ |
244 |
Boolean value = (Boolean) getLookAndFeel().getDefaults().get(key, locale); |
Boolean value = (Boolean) getLookAndFeelDefaults().get(key, locale); |
245 |
return value != null ? value.booleanValue() : false; |
return value != null ? value.booleanValue() : false; |
246 |
} |
} |
247 |
|
|
250 |
*/ |
*/ |
251 |
public static Border getBorder(Object key) |
public static Border getBorder(Object key) |
252 |
{ |
{ |
253 |
return (Border) getLookAndFeel().getDefaults().get(key); |
return (Border) getLookAndFeelDefaults().get(key); |
254 |
} |
} |
255 |
|
|
256 |
/** |
/** |
260 |
*/ |
*/ |
261 |
public static Border getBorder(Object key, Locale locale) |
public static Border getBorder(Object key, Locale locale) |
262 |
{ |
{ |
263 |
return (Border) getLookAndFeel().getDefaults().get(key, locale); |
return (Border) getLookAndFeelDefaults().get(key, locale); |
264 |
} |
} |
265 |
|
|
266 |
/** |
/** |
267 |
* Returns a drawing color from the defaults table. |
* Returns a drawing color from the defaults table. |
268 |
*/ |
*/ |
269 |
public static Color getColor(Object key) |
public static Color getColor(Object key) |
270 |
{ |
{ |
271 |
return (Color) getLookAndFeel().getDefaults().get(key); |
return (Color) getLookAndFeelDefaults().get(key); |
272 |
} |
} |
273 |
|
|
274 |
/** |
/** |
275 |
* Returns a drawing color from the defaults table. |
* Returns a drawing color from the defaults table. |
276 |
*/ |
*/ |
277 |
public static Color getColor(Object key, Locale locale) |
public static Color getColor(Object key, Locale locale) |
278 |
{ |
{ |
279 |
return (Color) getLookAndFeel().getDefaults().get(key); |
return (Color) getLookAndFeelDefaults().get(key); |
280 |
} |
} |
281 |
|
|
282 |
/** |
/** |
283 |
* this string can be passed to Class.forName() |
* this string can be passed to Class.forName() |
284 |
*/ |
*/ |
285 |
public static String getCrossPlatformLookAndFeelClassName() |
public static String getCrossPlatformLookAndFeelClassName() |
286 |
{ |
{ |
287 |
return "javax.swing.plaf.metal.MetalLookAndFeel"; |
return "javax.swing.plaf.metal.MetalLookAndFeel"; |
288 |
} |
} |
292 |
*/ |
*/ |
293 |
public static UIDefaults getDefaults() |
public static UIDefaults getDefaults() |
294 |
{ |
{ |
295 |
return getLookAndFeel().getDefaults(); |
return currentUIDefaults; |
296 |
} |
} |
297 |
|
|
298 |
/** |
/** |
300 |
*/ |
*/ |
301 |
public static Dimension getDimension(Object key) |
public static Dimension getDimension(Object key) |
302 |
{ |
{ |
303 |
return (Dimension) getLookAndFeel().getDefaults().get(key); |
return (Dimension) getLookAndFeelDefaults().get(key); |
304 |
} |
} |
305 |
|
|
306 |
/** |
/** |
308 |
*/ |
*/ |
309 |
public static Dimension getDimension(Object key, Locale locale) |
public static Dimension getDimension(Object key, Locale locale) |
310 |
{ |
{ |
311 |
return (Dimension) getLookAndFeel().getDefaults().get(key, locale); |
return (Dimension) getLookAndFeelDefaults().get(key, locale); |
312 |
} |
} |
313 |
|
|
314 |
/** |
/** |
321 |
*/ |
*/ |
322 |
public static Font getFont(Object key) |
public static Font getFont(Object key) |
323 |
{ |
{ |
324 |
return (Font) getLookAndFeel().getDefaults().get(key); |
return (Font) getLookAndFeelDefaults().get(key); |
325 |
} |
} |
326 |
|
|
327 |
/** |
/** |
334 |
*/ |
*/ |
335 |
public static Font getFont(Object key, Locale locale) |
public static Font getFont(Object key, Locale locale) |
336 |
{ |
{ |
337 |
return (Font) getLookAndFeel().getDefaults().get(key ,locale); |
return (Font) getLookAndFeelDefaults().get(key ,locale); |
338 |
} |
} |
339 |
|
|
340 |
/** |
/** |
342 |
*/ |
*/ |
343 |
public static Icon getIcon(Object key) |
public static Icon getIcon(Object key) |
344 |
{ |
{ |
345 |
return (Icon) getLookAndFeel().getDefaults().get(key); |
return (Icon) getLookAndFeelDefaults().get(key); |
346 |
} |
} |
347 |
|
|
348 |
/** |
/** |
350 |
*/ |
*/ |
351 |
public static Icon getIcon(Object key, Locale locale) |
public static Icon getIcon(Object key, Locale locale) |
352 |
{ |
{ |
353 |
return (Icon) getLookAndFeel().getDefaults().get(key, locale); |
return (Icon) getLookAndFeelDefaults().get(key, locale); |
354 |
} |
} |
355 |
|
|
356 |
/** |
/** |
358 |
*/ |
*/ |
359 |
public static Insets getInsets(Object key) |
public static Insets getInsets(Object key) |
360 |
{ |
{ |
361 |
return (Insets) getLookAndFeel().getDefaults().getInsets(key); |
return getLookAndFeelDefaults().getInsets(key); |
362 |
} |
} |
363 |
|
|
364 |
/** |
/** |
366 |
*/ |
*/ |
367 |
public static Insets getInsets(Object key, Locale locale) |
public static Insets getInsets(Object key, Locale locale) |
368 |
{ |
{ |
369 |
return (Insets) getLookAndFeel().getDefaults().getInsets(key, locale); |
return getLookAndFeelDefaults().getInsets(key, locale); |
370 |
} |
} |
371 |
|
|
372 |
public static LookAndFeelInfo[] getInstalledLookAndFeels() |
public static LookAndFeelInfo[] getInstalledLookAndFeels() |
376 |
|
|
377 |
public static int getInt(Object key) |
public static int getInt(Object key) |
378 |
{ |
{ |
379 |
Integer x = (Integer) getLookAndFeel().getDefaults().get(key); |
Integer x = (Integer) getLookAndFeelDefaults().get(key); |
380 |
if (x == null) |
if (x == null) |
381 |
return 0; |
return 0; |
382 |
return x.intValue(); |
return x.intValue(); |
384 |
|
|
385 |
public static int getInt(Object key, Locale locale) |
public static int getInt(Object key, Locale locale) |
386 |
{ |
{ |
387 |
Integer x = (Integer) getLookAndFeel().getDefaults().get(key, locale); |
Integer x = (Integer) getLookAndFeelDefaults().get(key, locale); |
388 |
if (x == null) |
if (x == null) |
389 |
return 0; |
return 0; |
390 |
return x.intValue(); |
return x.intValue(); |
392 |
|
|
393 |
public static LookAndFeel getLookAndFeel() |
public static LookAndFeel getLookAndFeel() |
394 |
{ |
{ |
395 |
return look_and_feel; |
return currentLookAndFeel; |
396 |
} |
} |
397 |
|
|
398 |
/** |
/** |
401 |
*/ |
*/ |
402 |
public static UIDefaults getLookAndFeelDefaults() |
public static UIDefaults getLookAndFeelDefaults() |
403 |
{ |
{ |
404 |
return getLookAndFeel().getDefaults(); |
return currentUIDefaults; |
405 |
} |
} |
406 |
|
|
407 |
/** |
/** |
409 |
*/ |
*/ |
410 |
public static String getString(Object key) |
public static String getString(Object key) |
411 |
{ |
{ |
412 |
return (String) getLookAndFeel().getDefaults().get(key); |
return (String) getLookAndFeelDefaults().get(key); |
413 |
} |
} |
414 |
|
|
415 |
/** |
/** |
417 |
*/ |
*/ |
418 |
public static String getString(Object key, Locale locale) |
public static String getString(Object key, Locale locale) |
419 |
{ |
{ |
420 |
return (String) getLookAndFeel().getDefaults().get(key, locale); |
return (String) getLookAndFeelDefaults().get(key, locale); |
421 |
} |
} |
422 |
|
|
423 |
/** |
/** |
435 |
*/ |
*/ |
436 |
public static ComponentUI getUI(JComponent target) |
public static ComponentUI getUI(JComponent target) |
437 |
{ |
{ |
438 |
return getDefaults().getUI(target); |
return getLookAndFeelDefaults().getUI(target); |
439 |
} |
} |
440 |
|
|
441 |
/** |
/** |
458 |
*/ |
*/ |
459 |
public static Object put(Object key, Object value) |
public static Object put(Object key, Object value) |
460 |
{ |
{ |
461 |
return getLookAndFeel().getDefaults().put(key,value); |
return getLookAndFeelDefaults().put(key,value); |
462 |
} |
} |
463 |
|
|
464 |
/** |
/** |
477 |
if (newLookAndFeel != null && ! newLookAndFeel.isSupportedLookAndFeel()) |
if (newLookAndFeel != null && ! newLookAndFeel.isSupportedLookAndFeel()) |
478 |
throw new UnsupportedLookAndFeelException(newLookAndFeel.getName()); |
throw new UnsupportedLookAndFeelException(newLookAndFeel.getName()); |
479 |
|
|
480 |
LookAndFeel oldLookAndFeel = look_and_feel; |
LookAndFeel oldLookAndFeel = currentLookAndFeel; |
481 |
if (oldLookAndFeel != null) |
if (oldLookAndFeel != null) |
482 |
oldLookAndFeel.uninitialize(); |
oldLookAndFeel.uninitialize(); |
483 |
|
|
484 |
// Set the current default look and feel using a LookAndFeel object. |
// Set the current default look and feel using a LookAndFeel object. |
485 |
look_and_feel = newLookAndFeel; |
currentLookAndFeel = newLookAndFeel; |
486 |
look_and_feel.initialize(); |
if (newLookAndFeel != null) |
487 |
|
{ |
488 |
|
newLookAndFeel.initialize(); |
489 |
|
currentUIDefaults = newLookAndFeel.getDefaults(); |
490 |
|
} |
491 |
|
else |
492 |
|
{ |
493 |
|
currentUIDefaults = null; |
494 |
|
} |
495 |
listeners.firePropertyChange("lookAndFeel", oldLookAndFeel, newLookAndFeel); |
listeners.firePropertyChange("lookAndFeel", oldLookAndFeel, newLookAndFeel); |
496 |
//revalidate(); |
//revalidate(); |
497 |
//repaint(); |
//repaint(); |