/[classpath]/classpath/javax/swing/UIManager.java
ViewVC logotype

Diff of /classpath/javax/swing/UIManager.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.23 by trebligd, Tue Aug 23 14:30:05 2005 UTC revision 1.24 by trebligd, Tue Aug 23 14:55:27 2005 UTC
# Line 100  public class UIManager implements Serial Line 100  public class UIManager implements Serial
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
# Line 123  public class UIManager implements Serial Line 125  public class UIManager implements Serial
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.
# Line 205  public class UIManager implements Serial Line 211  public class UIManager implements Serial
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    /**    /**
# Line 223  public class UIManager implements Serial Line 229  public class UIManager implements Serial
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        
# Line 235  public class UIManager implements Serial Line 241  public class UIManager implements Serial
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            
# Line 244  public class UIManager implements Serial Line 250  public class UIManager implements Serial
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    /**    /**
# Line 254  public class UIManager implements Serial Line 260  public class UIManager implements Serial
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    }    }
# Line 286  public class UIManager implements Serial Line 292  public class UIManager implements Serial
292     */     */
293    public static UIDefaults getDefaults()    public static UIDefaults getDefaults()
294    {    {
295      return getLookAndFeel().getDefaults();      return currentUIDefaults;
296    }    }
297    
298    /**    /**
# Line 294  public class UIManager implements Serial Line 300  public class UIManager implements Serial
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    /**    /**
# Line 302  public class UIManager implements Serial Line 308  public class UIManager implements Serial
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    /**    /**
# Line 315  public class UIManager implements Serial Line 321  public class UIManager implements Serial
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    /**    /**
# Line 328  public class UIManager implements Serial Line 334  public class UIManager implements Serial
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    /**    /**
# Line 336  public class UIManager implements Serial Line 342  public class UIManager implements Serial
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    /**    /**
# Line 344  public class UIManager implements Serial Line 350  public class UIManager implements Serial
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    /**    /**
# Line 352  public class UIManager implements Serial Line 358  public class UIManager implements Serial
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    /**    /**
# Line 360  public class UIManager implements Serial Line 366  public class UIManager implements Serial
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()
# Line 370  public class UIManager implements Serial Line 376  public class UIManager implements Serial
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();
# Line 378  public class UIManager implements Serial Line 384  public class UIManager implements Serial
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();
# Line 386  public class UIManager implements Serial Line 392  public class UIManager implements Serial
392    
393    public static LookAndFeel getLookAndFeel()    public static LookAndFeel getLookAndFeel()
394    {    {
395      return look_and_feel;      return currentLookAndFeel;
396    }    }
397    
398    /**    /**
# Line 395  public class UIManager implements Serial Line 401  public class UIManager implements Serial
401     */     */
402    public static UIDefaults getLookAndFeelDefaults()    public static UIDefaults getLookAndFeelDefaults()
403    {    {
404      return getLookAndFeel().getDefaults();      return currentUIDefaults;
405    }    }
406    
407    /**    /**
# Line 403  public class UIManager implements Serial Line 409  public class UIManager implements Serial
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    /**    /**
# Line 411  public class UIManager implements Serial Line 417  public class UIManager implements Serial
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    /**    /**
# Line 429  public class UIManager implements Serial Line 435  public class UIManager implements Serial
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    /**    /**
# Line 452  public class UIManager implements Serial Line 458  public class UIManager implements Serial
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    /**    /**
# Line 471  public class UIManager implements Serial Line 477  public class UIManager implements Serial
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();

Legend:
Removed from v.1.23  
changed lines
  Added in v.1.24

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26