Hey,

This patch fixes a bug that was exposed by Intel tests.  I have
committed also committed a mauve test.  The bug was in
java.awt.TextArea.minimizeSize(int, int) and
java.awt.TextArea.preferredSize(int, int).  

We weren't checking if the minimum size and the preferred size had been
set.  If they are, we have to return a new dimension with the values of
minSize and prefSize, respectively.  Also, if peer == null, then a new
Dimension with the width and height as its values is returned in both
methods.

I also changed the documentation we had for a few methods because it
stated that "a text area's minimum size depends on the number of rows 
and columns of text it would prefer to display, and on the size of the
font in which the text would be displayed" and that "a text area's
preferred size depends on the number of rows and columns of text it
would prefer to display, and on the size of the font in which the text
would be displayed."  This is not the case.  I have written mauve test
that shows this.

Cheers,
Tania
2006-11-03  Tania Bento  <[EMAIL PROTECTED]>

        * java/awt/TextArea.java
        (getMinimumSize): Changed documentation.
        (getPreferredSize): Changed documentation.
        (getMinimumSize(int,int)): Changed documenation.
        (getPreferredSize(int,int)): Changed documenation.
        (minimumSize): Changed documentation.
        (preferredSize): Changed documenation.
        (minimumSize(int,int)): Changed documentation.  Checked if
        minimum size had been previously set and changed values of
        Dimension returned if peer == null.
        (preferredSize(int, int)): Checked if preferred size had been
        previously set and changed values of Dimension returned if
        peer = null.

Index: java/awt/TextArea.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/awt/TextArea.java,v
retrieving revision 1.21
diff -u -r1.21 TextArea.java
--- java/awt/TextArea.java	30 Jun 2006 20:43:27 -0000	1.21
+++ java/awt/TextArea.java	3 Nov 2006 21:09:35 -0000
@@ -284,11 +284,7 @@
   }
 
   /**
-   * Retrieve the minimum size for this text area, considering the
-   * text area's current row and column values.  A text area's minimum
-   * size depends on the number of rows and columns of text it would
-   * prefer to display, and on the size of the font in which the text
-   * would be displayed.
+   * Retrieve the minimum size for this text area.
    *
    * @return The minimum size for this text field.
    */
@@ -298,11 +294,8 @@
   }
 
   /**
-   * Retrieve the minimum size that this text area would have if its
-   * row and column values were equal to those specified.  A text
-   * area's minimum size depends on the number of rows and columns of
-   * text it would prefer to display, and on the size of the font in
-   * which the text would be displayed.
+   * Retrieve the minimum size for this text area.  If the minimum
+   * size has been set, then rows and columns are used in the calculation.
    *
    * @param rows The number of rows to use in the minimum size
    * calculation.
@@ -317,12 +310,8 @@
   }
 
   /**
-   * Retrieve the minimum size for this text area, considering the
-   * text area's current row and column values.  A text area's minimum
-   * size depends on the number of rows and columns of text it would
-   * prefer to display, and on the size of the font in which the text
-   * would be displayed.
-   *
+   * Retrieve the minimum size for this text area.
+   * 
    * @return The minimum size for this text area.
    *
    * @deprecated This method is deprecated in favor of
@@ -334,11 +323,8 @@
   }
 
   /**
-   * Retrieve the minimum size that this text area would have if its
-   * row and column values were equal to those specified.  A text
-   * area's minimum size depends on the number of rows and columns of
-   * text it would prefer to display, and on the size of the font in
-   * which the text would be displayed.
+   * Retrieve the minimum size for this text area.  If the minimum
+   * size has been set, then rows and columns are used in the calculation.
    *
    * @param rows The number of rows to use in the minimum size
    * calculation.
@@ -352,21 +338,18 @@
    */
   public Dimension minimumSize (int rows, int columns)
   {
+    if (isMinimumSizeSet())
+      return new Dimension(minSize);
+    
     TextAreaPeer peer = (TextAreaPeer) getPeer ();
-
-    // Sun returns Dimension (0,0) in this case.
     if (peer == null)
-      return new Dimension (0, 0);
+      return new Dimension (getWidth(), getHeight());
 
     return peer.getMinimumSize (rows, columns);
   }
 
   /**
-   * Retrieve the preferred size for this text area, considering the
-   * text area's current row and column values.  A text area's preferred
-   * size depends on the number of rows and columns of text it would
-   * prefer to display, and on the size of the font in which the text
-   * would be displayed.
+   * Retrieve the preferred size for this text area.
    *
    * @return The preferred size for this text field.
    */
@@ -376,11 +359,8 @@
   }
 
   /**
-   * Retrieve the preferred size that this text area would have if its
-   * row and column values were equal to those specified.  A text
-   * area's preferred size depends on the number of rows and columns
-   * of text it would prefer to display, and on the size of the font
-   * in which the text would be displayed.
+   * Retrieve the preferred size for this text area.  If the preferred
+   * size has been set, then rows and columns are used in the calculation.
    *
    * @param rows The number of rows to use in the preferred size
    * calculation.
@@ -395,11 +375,7 @@
   }
 
   /**
-   * Retrieve the preferred size for this text area, considering the
-   * text area's current row and column values.  A text area's preferred
-   * size depends on the number of rows and columns of text it would
-   * prefer to display, and on the size of the font in which the text
-   * would be displayed.
+   * Retrieve the preferred size for this text area.
    *
    * @return The preferred size for this text field.
    *
@@ -412,11 +388,8 @@
   }
 
   /**
-   * Retrieve the preferred size that this text area would have if its
-   * row and column values were equal to those specified.  A text
-   * area's preferred size depends on the number of rows and columns
-   * of text it would prefer to display, and on the size of the font
-   * in which the text would be displayed.
+   * Retrieve the preferred size for this text area.  If the preferred
+   * size has been set, then rows and columns are used in the calculation.
    *
    * @param rows The number of rows to use in the preferred size
    * calculation.
@@ -430,11 +403,12 @@
    */
   public Dimension preferredSize (int rows, int columns)
   {
+    if (isPreferredSizeSet())
+      return new Dimension(prefSize);
+    
     TextAreaPeer peer = (TextAreaPeer) getPeer ();
-
-    // Sun returns Dimension (0,0) in this case.
     if (peer == null)
-      return new Dimension (0, 0);
+      return new Dimension (getWidth(), getHeight());
 
     return peer.getPreferredSize (rows, columns);
   }

Reply via email to