In JComponent.putClientProperty() we should not fire an event when both
old and new value are == null. This is different from the normal
PropertyChangeSupport behaviour to fire an event in this case too. This
fixes the Mauve regression in JToolTip and is accompanied by additional
Mauve tests for JComponent and PropertyChangeSupport.

2006-11-28  Roman Kennke  <[EMAIL PROTECTED]>

        * javax/swing/JComponent.java
        (putClientProperty): Do not fire event when both old and new
        value are == null.

/Roman

Index: javax/swing/JComponent.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/JComponent.java,v
retrieving revision 1.147
diff -u -1 -5 -r1.147 JComponent.java
--- javax/swing/JComponent.java	14 Oct 2006 13:23:45 -0000	1.147
+++ javax/swing/JComponent.java	28 Nov 2006 12:40:34 -0000
@@ -49,30 +49,31 @@
 import java.awt.Font;
 import java.awt.Graphics;
 import java.awt.Image;
 import java.awt.Insets;
 import java.awt.Point;
 import java.awt.Rectangle;
 import java.awt.Window;
 import java.awt.dnd.DropTarget;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.event.ContainerEvent;
 import java.awt.event.ContainerListener;
 import java.awt.event.FocusEvent;
 import java.awt.event.FocusListener;
 import java.awt.event.KeyEvent;
+import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
 import java.awt.peer.LightweightPeer;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 import java.beans.PropertyVetoException;
 import java.beans.VetoableChangeListener;
 import java.beans.VetoableChangeSupport;
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.EventListener;
 import java.util.Hashtable;
 import java.util.Locale;
 import java.util.Set;
 
 import javax.accessibility.Accessible;
@@ -835,31 +836,36 @@
    * @param key The key of the client property association to add
    * @param value The value of the client property association to add
    *
    * @see #clientProperties
    * @see #getClientProperties
    * @see #getClientProperty
    */
   public final void putClientProperty(Object key, Object value)
   {
     Hashtable t = getClientProperties();
     Object old = t.get(key);
     if (value != null)
       t.put(key, value);
     else
       t.remove(key);
-    firePropertyChange(key.toString(), old, value);
+
+    // When both old and new value are null, no event is fired. This is
+    // different from what firePropertyChange() normally does, so we add this
+    // check here.
+    if (old != null || value != null)
+      firePropertyChange(key.toString(), old, value);
   }
 
   /**
    * Unregister an <code>AncestorListener</code>.
    *
    * @param listener The listener to unregister
    * 
    * @see #addAncestorListener
    */
   public void removeAncestorListener(AncestorListener listener)
   {
     listenerList.remove(AncestorListener.class, listener);
   }
 
   /**

Reply via email to