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

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

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

revision 1.10 by mkoch, Thu Apr 29 07:00:34 2004 UTC revision 1.11 by mark, Thu Jul 22 19:45:39 2004 UTC
# Line 43  import java.awt.Font; Line 43  import java.awt.Font;
43  import java.awt.Insets;  import java.awt.Insets;
44  import java.beans.PropertyChangeEvent;  import java.beans.PropertyChangeEvent;
45  import java.beans.PropertyChangeListener;  import java.beans.PropertyChangeListener;
46    import java.beans.PropertyChangeSupport;
47  import java.lang.reflect.Method;  import java.lang.reflect.Method;
 import java.util.HashSet;  
48  import java.util.Hashtable;  import java.util.Hashtable;
 import java.util.Iterator;  
49  import java.util.LinkedList;  import java.util.LinkedList;
50  import java.util.ListIterator;  import java.util.ListIterator;
51  import java.util.Locale;  import java.util.Locale;
# Line 66  import javax.swing.plaf.ComponentUI; Line 65  import javax.swing.plaf.ComponentUI;
65   */   */
66  public class UIDefaults extends Hashtable  public class UIDefaults extends Hashtable
67  {  {
68      private LinkedList bundles;
69      private Locale defaultLocale;
70      private PropertyChangeSupport propertyChangeSupport;
71    
72    LinkedList bundles;    public interface ActiveValue
   Set listeners;  
   Locale defaultLocale;  
   
   interface ActiveValue  
73    {    {
74      Object createValue(UIDefaults table);      Object createValue(UIDefaults table);
75    } // interface ActiveValue    }
76    
77    public static class LazyInputMap implements LazyValue    public static class LazyInputMap implements LazyValue
78    {    {
# Line 93  public class UIDefaults extends Hashtabl Line 91  public class UIDefaults extends Hashtabl
91          }          }
92        return im;        return im;
93      }      }
94    } // class LazyInputMap    }
95    
96    interface LazyValue    public interface LazyValue
97    {    {
98      Object createValue(UIDefaults table);      Object createValue(UIDefaults table);
99    } // interface LazyValue    }
100    
101    public static class ProxyLazyValue implements LazyValue    public static class ProxyLazyValue implements LazyValue
102    {    {
# Line 209  public class UIDefaults extends Hashtabl Line 207  public class UIDefaults extends Hashtabl
207      {      {
208        return inner.createValue (table);        return inner.createValue (table);
209      }      }
210    } // class ProxyLazyValue    }
211    
212    private static final long serialVersionUID = 7341222528856548117L;    private static final long serialVersionUID = 7341222528856548117L;
213    
214    public UIDefaults()    public UIDefaults()
215    {    {
216      bundles = new LinkedList ();      bundles = new LinkedList ();
     listeners = new HashSet ();  
217      defaultLocale = Locale.getDefault ();      defaultLocale = Locale.getDefault ();
218        propertyChangeSupport = new PropertyChangeSupport(this);
219    }    }
220    
221    public UIDefaults(Object[] entries)    public UIDefaults(Object[] entries)
222    {    {
223      bundles = new LinkedList ();      this();
     listeners = new HashSet ();  
     defaultLocale = Locale.getDefault ();  
224    
225      for (int i = 0; (2*i+1) < entries.length; ++i)      for (int i = 0; (2*i+1) < entries.length; ++i)
       {  
226          put (entries[2*i], entries[2*i+1]);          put (entries[2*i], entries[2*i+1]);
227        }        }
   }  
228    
229    public Object get(Object key)    public Object get(Object key)
230    {    {
# Line 472  public class UIDefaults extends Hashtabl Line 466  public class UIDefaults extends Hashtabl
466          getUIError ("InvocationTargetException ("+ ite.getTargetException()          getUIError ("InvocationTargetException ("+ ite.getTargetException()
467                      +") calling createUI(...) on " + cls.toString ());                      +") calling createUI(...) on " + cls.toString ());
468          return null;                  return null;        
   
469          }          }
470      catch (Exception e)      catch (Exception e)
471    {    {
# Line 481  public class UIDefaults extends Hashtabl Line 474  public class UIDefaults extends Hashtabl
474        }        }
475    }    }
476    
477    void addPropertyChangeListener(PropertyChangeListener listener)    public void addPropertyChangeListener(PropertyChangeListener listener)
478    {    {
479      listeners.add (listener);      propertyChangeSupport.addPropertyChangeListener(listener);
480    }    }
481    
482    void removePropertyChangeListener(PropertyChangeListener listener)    void removePropertyChangeListener(PropertyChangeListener listener)
483    {    {
484      listeners.remove (listener);      propertyChangeSupport.removePropertyChangeListener(listener);
485    }    }
486    
487    public PropertyChangeListener[] getPropertyChangeListeners()    public PropertyChangeListener[] getPropertyChangeListeners()
488    {    {
489      return (PropertyChangeListener[]) listeners.toArray ();      return propertyChangeSupport.getPropertyChangeListeners();
490    }    }
491    
492    protected void firePropertyChange(String property, Object o, Object n)    protected void firePropertyChange(String property,
493                                        Object oldValue, Object newValue)
494    {    {
495      Iterator i = listeners.iterator ();      propertyChangeSupport.firePropertyChange(property, oldValue, newValue);
     PropertyChangeEvent pce = new PropertyChangeEvent (this, property, o, n);  
     while (i.hasNext ())  
       {  
         PropertyChangeListener pcl = (PropertyChangeListener) i.next ();  
         pcl.propertyChange (pce);  
       }  
496    }    }
497    
498    void addResourceBundle(String name)    public void addResourceBundle(String name)
499    {    {
500      bundles.addFirst (name);      bundles.addFirst (name);
501    }    }
502    
503    void removeResourceBundle(String name)    public void removeResourceBundle(String name)
504    {    {
505      bundles.remove (name);      bundles.remove (name);
506    }    }
507    
508    void setDefaultLocale(Locale loc)    public void setDefaultLocale(Locale loc)
509    {    {
510      defaultLocale = loc;      defaultLocale = loc;
511    }    }
# Line 526  public class UIDefaults extends Hashtabl Line 514  public class UIDefaults extends Hashtabl
514    {    {
515      return defaultLocale;      return defaultLocale;
516    }    }
517  } // class UIDefaults  }

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

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