This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gui][patch] fyi: property change listeners for JComponents


Hi,

Committing this to gui branch.

Cheers,

Kim

2004-02-18  Kim Ho  <kho@redhat.com>

	* javax/swing/JSlider.java: Re-order
	modifiers.
	* javax/swing/JLabel.java: Re-order
	modifiers.
	* javax/swing/JComponent.java: 
	(addPropertyChangeListener):
	Implement.
	(removePropertyChangeListener):
	ditto.
	(firePropertyChangeEvent):
	ditto.
Index: javax/swing/JSlider.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/JSlider.java,v
retrieving revision 1.3.18.3
diff -u -r1.3.18.3 JSlider.java
--- javax/swing/JSlider.java	17 Feb 2004 17:32:44 -0000	1.3.18.3
+++ javax/swing/JSlider.java	18 Feb 2004 14:36:31 -0000
@@ -209,34 +209,34 @@
   }
 
   /** Fired in a PropertyChangeEvent when the "inverted" property changes. */
-  public final static String INVERTED_CHANGED_PROPERTY = "inverted";
+  public static final String INVERTED_CHANGED_PROPERTY = "inverted";
 
   /** Fired in a PropertyChangeEvent when the "labelTable" property changes. */
-  public final static String LABEL_TABLE_CHANGED_PROPERTY = "labelTable";
+  public static final String LABEL_TABLE_CHANGED_PROPERTY = "labelTable";
 
   /**
    * Fired in a PropertyChangeEvent when the "majorTickSpacing" property
    * changes.
    */
-  public final static String MAJOR_TICK_SPACING_CHANGED_PROPERTY = "majorTickSpacing";
+  public static final String MAJOR_TICK_SPACING_CHANGED_PROPERTY = "majorTickSpacing";
 
   /**
    * Fired in a PropertyChangeEvent when the "minorTickSpacing" property
    * changes.
    */
-  public final static String MINOR_TICK_SPACING_CHANGED_PROPERTY = "minorTickSpacing";
+  public static final String MINOR_TICK_SPACING_CHANGED_PROPERTY = "minorTickSpacing";
 
   /** Fired in a PropertyChangeEvent when the "model" property changes. */
-  public final static String MODEL_CHANGED_PROPERTY = "model";
+  public static final String MODEL_CHANGED_PROPERTY = "model";
 
   /** Fired in a PropertyChangeEvent when the "orientation" property changes. */
-  public final static String ORIENTATION_CHANGED_PROPERTY = "orientation";
+  public static final String ORIENTATION_CHANGED_PROPERTY = "orientation";
 
   /** Fired in a PropertyChangeEvent when the "paintLabels" property changes. */
-  public final static String PAINT_LABELS_CHANGED_PROPERTY = "paintLabels";
+  public static final String PAINT_LABELS_CHANGED_PROPERTY = "paintLabels";
 
   /** Fired in a PropertyChangeEvent when the "paintTicks" property changes. */
-  public final static String PAINT_TICKS_CHANGED_PROPERTY = "paintTicks";
+  public static final String PAINT_TICKS_CHANGED_PROPERTY = "paintTicks";
   
   /** Whether or not this slider paints its ticks. */
   private transient boolean paintTicks = false;
Index: javax/swing/JLabel.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/JLabel.java,v
retrieving revision 1.4.2.2
diff -u -r1.4.2.2 JLabel.java
--- javax/swing/JLabel.java	17 Feb 2004 17:29:41 -0000	1.4.2.2
+++ javax/swing/JLabel.java	18 Feb 2004 14:36:31 -0000
@@ -95,54 +95,54 @@
   /**
    * Fired in a PropertyChangeEvent when the "disabledIcon" property changes.
    */
-  public final static String DISABLED_ICON_CHANGED_PROPERTY = "disabledIcon";
+  public static final String DISABLED_ICON_CHANGED_PROPERTY = "disabledIcon";
 
   /**
    * Fired in a PropertyChangeEvent when the "displayedMnemonic" property
    * changes.
    */
-  public final static String DISPLAYED_MNEMONIC_CHANGED_PROPERTY = "displayedMnemonic";
+  public static final String DISPLAYED_MNEMONIC_CHANGED_PROPERTY = "displayedMnemonic";
   
   /**
    * Fired in a PropertyChangeEvent when the "displayedMnemonicIndex"
    * property changes. */
-  public final static String DISPLAYED_MNEMONIC_INDEX_CHANGED_PROPERTY = "displayedMnemonicIndex";
+  public static final String DISPLAYED_MNEMONIC_INDEX_CHANGED_PROPERTY = "displayedMnemonicIndex";
 
   /**
    * Fired in a PropertyChangeEvent when the "horizontalAlignment" property
    * changes.
    */
-  public final static String HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY = "horizontalAlignment";
+  public static final String HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY = "horizontalAlignment";
 
   /**
    * Fired in a PropertyChangeEvent when the "horizontalTextPosition" property
    * changes.
    */
-  public final static String HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY = "horizontalTextPosition";
+  public static final String HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY = "horizontalTextPosition";
 
   /** Fired in a PropertyChangeEvent when the "icon" property changes. */
-  public final static String ICON_CHANGED_PROPERTY = "icon";
+  public static final String ICON_CHANGED_PROPERTY = "icon";
 
   /** Fired in a PropertyChangeEvent when the "iconTextGap" property changes. */
-  public final static String ICON_TEXT_GAP_CHANGED_PROPERTY = "iconTextGap";
+  public static final String ICON_TEXT_GAP_CHANGED_PROPERTY = "iconTextGap";
 
   /** Fired in a PropertyChangeEvent when the "labelFor" property changes. */
-  public final static String LABEL_FOR_CHANGED_PROPERTY = "labelFor";
+  public static final String LABEL_FOR_CHANGED_PROPERTY = "labelFor";
 
   /** Fired in a PropertyChangeEvent when the "text" property changes. */
-  public final static String TEXT_CHANGED_PROPERTY = "text";
+  public static final String TEXT_CHANGED_PROPERTY = "text";
 
   /**
    * Fired in a PropertyChangeEvent when the "verticalAlignment" property
    * changes.
    */
-  public final static String VERTICAL_ALIGNMENT_CHANGED_PROPERTY = "verticalAlignment";
+  public static final String VERTICAL_ALIGNMENT_CHANGED_PROPERTY = "verticalAlignment";
 
   /**
    * Fired in a PropertyChangeEvent when the "verticalTextPosition" property
    * changes.
    */
-  public final static String VERTICAL_TEXT_POSITION_CHANGED_PROPERTY = "verticalTextPosition";
+  public static final String VERTICAL_TEXT_POSITION_CHANGED_PROPERTY = "verticalTextPosition";
 
   /**
    * Creates a new horizontally and vertically centered JLabel object with no text and no
Index: javax/swing/JComponent.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/JComponent.java,v
retrieving revision 1.7
diff -u -r1.7 JComponent.java
--- javax/swing/JComponent.java	12 Feb 2004 00:17:23 -0000	1.7
+++ javax/swing/JComponent.java	18 Feb 2004 14:36:32 -0000
@@ -75,6 +75,7 @@
 import javax.swing.event.EventListenerList;
 import javax.swing.border.Border;
 import javax.swing.plaf.ComponentUI;
+import javax.swing.event.SwingPropertyChangeSupport;
 
 /**
  * Every component in swing inherits from this class (JLabel, JButton, etc).
@@ -101,6 +102,7 @@
 	String tool_tip_text;
 	boolean use_double_buffer, opaque;
 	protected ComponentUI ui;
+	private SwingPropertyChangeSupport changeSupport;
 
 	Hashtable prop_hash;
 
@@ -195,7 +197,7 @@
 		 * addPropertyChangeListener
 		 * @param listener TODO
 		 */
-		public void addPropertyChangeListener(PropertyChangeListener listener) {
+		public void addPropertyChangeListener(PropertyChangeListener listener) { 
 			// TODO
 		} // addPropertyChangeListener()
 
@@ -318,7 +320,8 @@
    */
   public void removePropertyChangeListener(PropertyChangeListener listener)
   {
-    listenerList.remove(PropertyChangeListener.class, listener);
+    if (changeSupport != null)
+      changeSupport.removePropertyChangeListener(listener);
   }
 
   /**
@@ -350,7 +353,9 @@
    */
   public void addPropertyChangeListener(PropertyChangeListener listener)
   {
-    listenerList.add(PropertyChangeListener.class, listener);
+    if (changeSupport == null)
+      changeSupport = new SwingPropertyChangeSupport(this);
+    changeSupport.addPropertyChangeListener(listener);
   }
 
   /**
@@ -404,45 +409,68 @@
 		//Returns the Component's "visible rect rectangle" - the intersection of the visible rectangles for this component and all of its ancestors.
 		//super.computeVisibleRect(rect);
 	}
+	
+        public PropertyChangeListener[] getPropertyChangeListeners(String property)
+        {
+          return changeSupport == null ? new PropertyChangeListener[0]
+                 : changeSupport.getPropertyChangeListeners(property);
+        }	
 
 	public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue)
 	{
-		//Reports a bound property change.
+          if (changeSupport != null)
+            changeSupport.firePropertyChange(propertyName, new Boolean(oldValue), 
+	                                     new Boolean(newValue));
 	}
 	public void firePropertyChange(String propertyName, byte oldValue, byte newValue)
 	{
-		//    Reports a bound property change.
+          if (changeSupport != null)
+            changeSupport.firePropertyChange(propertyName, new Byte(oldValue), 
+	                                     new Byte(newValue));
 	}
 	public void firePropertyChange(String propertyName, char oldValue, char newValue)
 	{
-		//Reports a bound property change.
+          if (changeSupport != null)
+            changeSupport.firePropertyChange(propertyName, new Character(oldValue), 
+	                                     new Character(newValue));
 	}
 
 	public void firePropertyChange(String propertyName, double oldValue, double newValue)
 	{
-		//Reports a bound property change.
+          if (changeSupport != null)
+            changeSupport.firePropertyChange(propertyName, new Double(oldValue), 
+	                                     new Double(newValue));
 	}
 
 	public void firePropertyChange(String propertyName, float oldValue, float newValue)
 	{
-		//       Reports a bound property change.
+          if (changeSupport != null)
+            changeSupport.firePropertyChange(propertyName, new Float(oldValue), 
+	                                     new Float(newValue));
 	}
 	public void firePropertyChange(String propertyName, int oldValue, int newValue)
 	{
-		//       Reports a bound property change.
+          if (changeSupport != null)
+            changeSupport.firePropertyChange(propertyName, new Integer(oldValue), 
+	                                     new Integer(newValue));
 	}
 	public void firePropertyChange(String propertyName, long oldValue, long newValue)
 	{
-		//Reports a bound property change. protected
+          if (changeSupport != null)
+            changeSupport.firePropertyChange(propertyName, new Long(oldValue), 
+	                                     new Long(newValue));
 	}
 
-  protected void firePropertyChange(String propertyName, Object oldValue, Object newValue)
+        protected void firePropertyChange(String propertyName, Object oldValue, Object newValue)
 	{
-		//       Support for reporting bound property changes.
+          if (changeSupport != null)
+            changeSupport.firePropertyChange(propertyName, oldValue, newValue);
 	}
 	public void firePropertyChange(String propertyName, short oldValue, short newValue)
 	{
-		//       Reports a bound property change.
+          if (changeSupport != null)
+            changeSupport.firePropertyChange(propertyName, new Short(oldValue), 
+	                                     new Short(newValue));
 	}
 
 	protected  void fireVetoableChange(String propertyName, Object oldValue, Object newValue)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]