[cp-patches] FYI: DefaultTableColumnModel - small update

David Gilbert david.gilbert at object-refinery.com
Wed Jun 28 09:45:08 UTC 2006


This patch (committed) removes a FIXME from the DefaultTableColumnModel class.  The 
changeEvent field should be instantiated the first time it is actually needed - I 
have a Mauve test for this, which I wrote some time ago:

2006-06-28  David Gilbert  <david.gilbert at object-refinery.com>

	* javax/swing/table/DefaultTableColumnModel.java
	(changeEvent): Don't initialize yet, removed FIXME,
	(fireColumnModelChanged): Initialize changeEvent if necessary.

Regards,

Dave
-------------- next part --------------
Index: javax/swing/table/DefaultTableColumnModel.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/table/DefaultTableColumnModel.java,v
retrieving revision 1.18
diff -u -r1.18 DefaultTableColumnModel.java
--- javax/swing/table/DefaultTableColumnModel.java	25 Apr 2006 10:03:09 -0000	1.18
+++ javax/swing/table/DefaultTableColumnModel.java	28 Jun 2006 09:38:08 -0000
@@ -91,10 +91,10 @@
   /**
    * A change event used when notifying listeners of a change to the 
    * <code>columnMargin</code> field.  This single event is reused for all
-   * notifications.
+   * notifications (it is lazily instantiated within the 
+   * {@link #fireColumnMarginChanged()} method).
    */
-  // FIXME: use lazy instantiation
-  protected transient ChangeEvent changeEvent = new ChangeEvent(this);
+  protected transient ChangeEvent changeEvent;
 
   /**
    * A flag that indicates whether or not columns can be selected. 
@@ -580,7 +580,9 @@
    */
   protected void fireColumnMarginChanged()
   {
-    EventListener [] listeners = getListeners(TableColumnModelListener.class);
+    EventListener[] listeners = getListeners(TableColumnModelListener.class);
+    if (changeEvent == null && listeners.length > 0)
+      changeEvent = new ChangeEvent(this);
     for (int i = 0; i < listeners.length; ++i)
       ((TableColumnModelListener) listeners[i]).columnMarginChanged(changeEvent);
   }


More information about the Classpath-patches mailing list