This patch (committed) fixes some minor bugs in the setMaxWidth() method of the TableColumn class:

2006-03-14  David Gilbert  <[EMAIL PROTECTED]>

        * javax/swing/table/TableColumn.java
        (setMaxWidth): Updated width and preferredWidth if necessary,
        (getMaxWidth): Updated API docs.

A Mauve test backing up this change has been committed to Mauve CVS a few 
minutes ago.

Regards,

Dave Gilbert
Index: javax/swing/table/TableColumn.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/table/TableColumn.java,v
retrieving revision 1.17
diff -u -r1.17 TableColumn.java
--- javax/swing/table/TableColumn.java  14 Mar 2006 17:31:54 -0000      1.17
+++ javax/swing/table/TableColumn.java  14 Mar 2006 21:10:18 -0000
@@ -505,22 +505,37 @@
   }
 
   /**
-   * Sets the maximum width and, if necessary, updates the <code>width</code>
-   * and <code>preferredWidth</code>.
+   * Sets the maximum width for the column and sends a 
+   * [EMAIL PROTECTED] PropertyChangeEvent} (with the property name 
'maxWidth') to all
+   * registered listeners.  If the current <code>width</code> and/or 
+   * <code>preferredWidth</code> are greater than the new maximum width, they 
+   * are adjusted accordingly.
    * 
-   * @param maxWidth the maximum width
+   * @param maxWidth the maximum width.
+   * 
+   * @see #getMaxWidth()
    */
   public void setMaxWidth(int maxWidth)
   {
-    this.maxWidth = maxWidth;
-    setWidth(getWidth());
-    setPreferredWidth(getPreferredWidth());
+    if (this.maxWidth != maxWidth)
+      {
+        if (width > maxWidth)
+          setWidth(maxWidth);
+        if (preferredWidth > maxWidth)
+          setPreferredWidth(maxWidth);
+        int oldValue = this.maxWidth;
+        this.maxWidth = maxWidth;
+        firePropertyChange("maxWidth", oldValue, maxWidth);
+       }
   }
 
   /**
-   * Returns the maximum width.
+   * Returns the maximum width for the column.  The default value is
+   * [EMAIL PROTECTED] Integer#MAX_VALUE}.
+   * 
+   * @return The maximum width for the column.
    * 
-   * @return The maximum width.
+   * @see #setMaxWidth(int)
    */
   public int getMaxWidth()
   {

Reply via email to