Hi,
Yesterday I've committed the attached patch. It fixes
javax.swing.UIDefaults put() and putDefaults() methods. These should (in
contrast to Hashtable) accept null values and treat them as remove(key).
This is documented in put() but not explicitly in putDefaults(). A mauve
testcase that I've also committed yester confirms that this behaviour is
correct for putDefaults().
2005-04-06 Roman Kennke <[EMAIL PROTECTED]>
* javax/swing/UIDefaults.java
(put): Now uses new checkAndPut method instead of checking
directly.
(putDefaults): Fixed so that it accepts null-values and
treats them like remove(key).
(checkAndPut): Added. This checks for null-values and calls
put or remove.
Regards,
Roman
Index: javax/swing/UIDefaults.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/UIDefaults.java,v
retrieving revision 1.17
diff -u -r1.17 UIDefaults.java
--- javax/swing/UIDefaults.java 11 Jan 2005 22:46:39 -0000 1.17
+++ javax/swing/UIDefaults.java 6 Apr 2005 20:41:25 -0000
@@ -286,11 +286,8 @@
public Object put(Object key, Object value)
{
- Object old;
- if (value != null)
- old = super.put(key, value);
- else
- old = super.remove(key);
+ Object old = checkAndPut(key, value);
+
if (key instanceof String && old != value)
firePropertyChange((String) key, old, value);
return old;
@@ -300,11 +297,33 @@
{
for (int i = 0; (2 * i + 1) < entries.length; ++i)
{
- super.put(entries[2 * i], entries[2 * i + 1]);
+ checkAndPut(entries[2 * i], entries[2 * i + 1]);
}
firePropertyChange("UIDefaults", null, null);
}
+ /**
+ * Checks the value for <code>null</code> and put it into the Hashtable, if
+ * it is not <code>null</code>. If the value is <code>null</code> then
+ * remove the corresponding key.
+ *
+ * @param key the key to put into this UIDefauls table
+ * @param value the value to put into this UIDefaults table
+ *
+ * @return the old value for <code>key</code>
+ */
+ private Object checkAndPut(Object key, Object value)
+ {
+ Object old;
+
+ if (value != null)
+ old = super.put(key, value);
+ else
+ old = super.remove(key);
+
+ return old;
+ }
+
public Font getFont(Object key)
{
Object o = get(key);
_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches