This patch (committed) fixes some failures in the Mauve tests that I committed earlier today. Note that the only code change is in the setMinWidth() method, everything else is just (sort of related) API doc updates:

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

        * javax/swing/table/TableColumn.java
        (COLUMN_WIDTH_PROPERTY): Updated API docs,
        (isResizable): Likewise,
        (setWidth): Likewise,
        (getWidth): Likewise,
        (setPreferredWidth): Likewise,
        (getPreferredWidth): Likewise,
        (setMinWidth): Check for negative argument and update width and
        preferredWidth if necessary,
        (getMinWidth): Updated API docs.

Regards,

Dave
Index: javax/swing/table/TableColumn.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/table/TableColumn.java,v
retrieving revision 1.16
diff -u -r1.16 TableColumn.java
--- javax/swing/table/TableColumn.java  14 Mar 2006 15:51:59 -0000      1.16
+++ javax/swing/table/TableColumn.java  14 Mar 2006 17:30:22 -0000
@@ -56,8 +56,9 @@
   static final long serialVersionUID = -6113660025878112608L;
 
   /**
-   * The name for the <code>columnWidth</code> property.  Note that the typo
-   * in the name value is deliberate, to match the specification.
+   * The name for the <code>columnWidth</code> property.  This field is
+   * obsolete and no longer used.  Note also that the typo in the value 
+   * string is deliberate, to match the specification.
    */
   public static final String COLUMN_WIDTH_PROPERTY = "columWidth";
 
@@ -127,7 +128,8 @@
   protected TableCellEditor cellEditor;
 
   /**
-   * isResizable
+   * A flag that determines whether or not the column is resizable (the default
+   * is <code>true</code>).
    */
   protected boolean isResizable = true;
 
@@ -383,9 +385,14 @@
   }
 
   /**
-   * setWidth
+   * Sets the width for the column and sends a [EMAIL PROTECTED] 
PropertyChangeEvent} 
+   * (with the property name 'width') to all registered listeners.  If the new
+   * width falls outside the range getMinWidth() to getMaxWidth() it is 
+   * adjusted to the appropriate boundary value.
    * 
-   * @param newWidth the width
+   * @param newWidth the width.
+   * 
+   * @see #getWidth()
    */
   public void setWidth(int newWidth)
   {
@@ -409,9 +416,11 @@
   }
 
   /**
-   * getWidth
+   * Returns the width for the column (the default value is <code>75</code>).
    * 
-   * @return int
+   * @return The width.
+   *
+   * @see #setWidth(int)
    */
   public int getWidth()
   {
@@ -419,9 +428,14 @@
   }
 
   /**
-   * setPreferredWidth
+   * Sets the preferred width for the column and sends a 
+   * [EMAIL PROTECTED] PropertyChangeEvent} to all registered listeners.  If 
necessary,
+   * the supplied value will be adjusted to fit in the range 
+   * [EMAIL PROTECTED] #getMinWidth()} to [EMAIL PROTECTED] #getMaxWidth()}.
+   * 
+   * @param preferredWidth  the preferred width.
    * 
-   * @param preferredWidth the preferred width
+   * @see #getPreferredWidth()
    */
   public void setPreferredWidth(int preferredWidth)
   {
@@ -438,9 +452,12 @@
   }
 
   /**
-   * getPreferredWidth
+   * Returns the preferred width for the column (the default value is 
+   * <code>75</code>).
    * 
-   * @return the preferred width
+   * @return The preferred width.
+   * 
+   * @see #setPreferredWidth(int)
    */
   public int getPreferredWidth()
   {
@@ -448,22 +465,39 @@
   }
 
   /**
-   * Sets the minimum width for the column and, if necessary, updates the
-   * <code>width</code> and <code>preferredWidth</code>.
+   * Sets the minimum width for the column and sends a 
+   * [EMAIL PROTECTED] PropertyChangeEvent} (with the property name 
'minWidth') to all
+   * registered listeners.  If the current <code>width</code> and/or 
+   * <code>preferredWidth</code> are less than the new minimum width, they are
+   * adjusted accordingly.
+   * 
+   * @param minWidth  the minimum width (negative values are treated as 0).
    * 
-   * @param minWidth the minimum width
+   * @see #getMinWidth()
    */
   public void setMinWidth(int minWidth)
   {
-    this.minWidth = minWidth;
-    setWidth(getWidth());
-    setPreferredWidth(getPreferredWidth());
+    if (minWidth < 0)
+      minWidth = 0;
+    if (this.minWidth != minWidth)
+      {
+        if (width < minWidth)
+          setWidth(minWidth);
+        if (preferredWidth < minWidth)
+          setPreferredWidth(minWidth);
+        int oldValue = this.minWidth;
+        this.minWidth = minWidth;
+        firePropertyChange("minWidth", oldValue, minWidth);
+      }
   }
 
   /**
-   * Returns the <code>TableColumn</code>'s minimum width.
+   * Returns the <code>TableColumn</code>'s minimum width.  The default value
+   * is <code>15</code>.
    * 
    * @return The minimum width.
+   * 
+   * @see #setMinWidth(int)
    */
   public int getMinWidth()
   {

Reply via email to