aboutsummaryrefslogtreecommitdiff
path: root/libjava/javax/swing/UIDefaults.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/javax/swing/UIDefaults.java')
-rw-r--r--libjava/javax/swing/UIDefaults.java128
1 files changed, 66 insertions, 62 deletions
diff --git a/libjava/javax/swing/UIDefaults.java b/libjava/javax/swing/UIDefaults.java
index c32cebd5a81..a2deae4978d 100644
--- a/libjava/javax/swing/UIDefaults.java
+++ b/libjava/javax/swing/UIDefaults.java
@@ -1,5 +1,5 @@
/* UIDefaults.java -- database for all settings and interface bindings.
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -57,8 +57,8 @@ import javax.swing.plaf.ComponentUI;
/**
* UIDefaults is a database where all settings and interface bindings are
- * stored into. An PLAF implementation fills one of these (see for example
- * plaf/basic/BasicLookAndFeel.java) with "ButtonUI" -> new BasicButtonUI().
+ * stored into. A PLAF implementation fills one of these (see for example
+ * plaf/basic/BasicLookAndFeel.java) with "ButtonUI" -> new BasicButtonUI().
*
* @author Ronald Veldema (rveldema@cs.vu.nl)
*/
@@ -68,7 +68,7 @@ public class UIDefaults extends Hashtable
private Locale defaultLocale;
private PropertyChangeSupport propertyChangeSupport;
- public interface ActiveValue
+ public static interface ActiveValue
{
Object createValue(UIDefaults table);
}
@@ -92,7 +92,7 @@ public class UIDefaults extends Hashtable
}
}
- public interface LazyValue
+ public static interface LazyValue
{
Object createValue(UIDefaults table);
}
@@ -110,9 +110,9 @@ public class UIDefaults extends Hashtable
try
{
return Class
- .forName (className)
- .getConstructor (new Class[] {})
- .newInstance (new Object[] {});
+ .forName(className)
+ .getConstructor(new Class[] {})
+ .newInstance(new Object[] {});
}
catch (Exception e)
{
@@ -145,54 +145,54 @@ public class UIDefaults extends Hashtable
};
}
- public ProxyLazyValue (String c, Object[] os)
+ public ProxyLazyValue(String c, Object[] os)
{
final String className = c;
final Object[] objs = os;
final Class[] clss = new Class[objs.length];
for (int i = 0; i < objs.length; ++i)
{
- clss[i] = objs[i].getClass ();
+ clss[i] = objs[i].getClass();
}
- inner = new LazyValue ()
+ inner = new LazyValue()
{
- public Object createValue (UIDefaults table)
+ public Object createValue(UIDefaults table)
{
try
{
return Class
- .forName (className)
- .getConstructor (clss)
- .newInstance (objs);
- }
+ .forName(className)
+ .getConstructor(clss)
+ .newInstance(objs);
+ }
catch (Exception e)
- {
+ {
return null;
}
}
};
}
- public ProxyLazyValue (String c, String m, Object[] os)
+ public ProxyLazyValue(String c, String m, Object[] os)
{
final String className = c;
final String methodName = m;
final Object[] objs = os;
final Class[] clss = new Class[objs.length];
for (int i = 0; i < objs.length; ++i)
- {
- clss[i] = objs[i].getClass ();
- }
- inner = new LazyValue ()
+ {
+ clss[i] = objs[i].getClass();
+ }
+ inner = new LazyValue()
{
- public Object createValue(UIDefaults table)
- {
+ public Object createValue(UIDefaults table)
+ {
try
{
return Class
- .forName (className)
- .getMethod (methodName, clss)
- .invoke (null, objs);
+ .forName(className)
+ .getMethod(methodName, clss)
+ .invoke(null, objs);
}
catch (Exception e)
{
@@ -202,9 +202,9 @@ public class UIDefaults extends Hashtable
};
}
- public Object createValue (UIDefaults table)
+ public Object createValue(UIDefaults table)
{
- return inner.createValue (table);
+ return inner.createValue(table);
}
}
@@ -212,46 +212,46 @@ public class UIDefaults extends Hashtable
public UIDefaults()
{
- bundles = new LinkedList ();
- defaultLocale = Locale.getDefault ();
+ bundles = new LinkedList();
+ defaultLocale = Locale.getDefault();
propertyChangeSupport = new PropertyChangeSupport(this);
}
public UIDefaults(Object[] entries)
{
this();
-
- for (int i = 0; (2*i+1) < entries.length; ++i)
- put (entries[2*i], entries[2*i+1]);
- }
+
+ for (int i = 0; (2 * i + 1) < entries.length; ++i)
+ put(entries[2 * i], entries[2 * i + 1]);
+ }
public Object get(Object key)
{
- return this.get (key, getDefaultLocale ());
+ return this.get(key, getDefaultLocale());
}
- public Object get (Object key, Locale loc)
+ public Object get(Object key, Locale loc)
{
Object obj = null;
- if (super.containsKey (key))
+ if (super.containsKey(key))
{
- obj = super.get (key);
+ obj = super.get(key);
}
else if (key instanceof String)
{
String keyString = (String) key;
- ListIterator i = bundles.listIterator (0);
- while (i.hasNext ())
- {
- String bundle_name = (String) i.next ();
+ ListIterator i = bundles.listIterator(0);
+ while (i.hasNext())
+ {
+ String bundle_name = (String) i.next();
ResourceBundle res =
- ResourceBundle.getBundle (bundle_name, loc);
+ ResourceBundle.getBundle(bundle_name, loc);
if (res != null)
{
try
{
- obj = res.getObject (keyString);
+ obj = res.getObject(keyString);
break;
}
catch (MissingResourceException me)
@@ -271,14 +271,14 @@ public class UIDefaults extends Hashtable
if (obj instanceof LazyValue)
{
- Object resolved = ((LazyValue)obj).createValue (this);
- super.remove (key);
- super.put (key, resolved);
+ Object resolved = ((LazyValue) obj).createValue(this);
+ super.remove(key);
+ super.put(key, resolved);
return resolved;
}
else if (obj instanceof ActiveValue)
{
- return ((ActiveValue)obj).createValue (this);
+ return ((ActiveValue) obj).createValue(this);
}
return obj;
@@ -286,19 +286,23 @@ public class UIDefaults extends Hashtable
public Object put(Object key, Object value)
{
- Object old = super.put (key, value);
+ Object old;
+ if (value != null)
+ old = super.put(key, value);
+ else
+ old = super.remove(key);
if (key instanceof String && old != value)
- firePropertyChange ((String) key, old, value);
+ firePropertyChange((String) key, old, value);
return old;
}
public void putDefaults(Object[] entries)
{
- for (int i = 0; (2*i+1) < entries.length; ++i)
+ for (int i = 0; (2 * i + 1) < entries.length; ++i)
{
- super.put (entries[2*i], entries[2*i+1]);
+ super.put(entries[2 * i], entries[2 * i + 1]);
}
- firePropertyChange ("UIDefaults", null, null);
+ firePropertyChange("UIDefaults", null, null);
}
public Font getFont(Object key)
@@ -454,20 +458,20 @@ public class UIDefaults extends Hashtable
{
getUIError ("failed to locate createUI method on " + cls.toString ());
return null;
- }
+ }
try
- {
+ {
return (ComponentUI) factory.invoke (null, new Object[] { target });
- }
+ }
catch (java.lang.reflect.InvocationTargetException ite)
- {
+ {
getUIError ("InvocationTargetException ("+ ite.getTargetException()
+") calling createUI(...) on " + cls.toString ());
return null;
- }
+ }
catch (Exception e)
- {
+ {
getUIError ("exception calling createUI(...) on " + cls.toString ());
return null;
}
@@ -496,12 +500,12 @@ public class UIDefaults extends Hashtable
public void addResourceBundle(String name)
{
- bundles.addFirst (name);
+ bundles.addFirst(name);
}
public void removeResourceBundle(String name)
{
- bundles.remove (name);
+ bundles.remove(name);
}
public void setDefaultLocale(Locale loc)