[cp-patches] RFA: TextField

Thomas Fitzsimmons fitzsim at redhat.com
Fri Jun 23 17:16:23 UTC 2006


Tania Bento wrote:
> Hey,
> 
> One of the constructors of this class takes a string and then sets the
> number of columns to be equal to the length of that string.  If the
> string passed was null, this would cause a NPE.  I have fixed this.
> Now, it checks if the string is null and if it is, it will set the
> number of columns to 0.  
> 
> This patch is based on Harmony's
> testTextFieldString(test.java.awt.TextFieldTest).
> 
> Could someone please approve this.  Thanks.

Approved.

Tom

> 
> Tania
> 
> 2006-06-23  Tania Bento  <tbento at redhat.com>
> 
>         * java/awt/TextField.java
>         (TextField): Check if the string passed is null. If it is,
>         set columns to 0, else columns is set to the length of
>         the string.
> 
> 
> 
> ------------------------------------------------------------------------
> 
> Index: java/awt/TextField.java
> ===================================================================
> RCS file: /cvsroot/classpath/classpath/java/awt/TextField.java,v
> retrieving revision 1.17
> diff -u -r1.17 TextField.java
> --- java/awt/TextField.java	24 Feb 2006 18:50:36 -0000	1.17
> +++ java/awt/TextField.java	23 Jun 2006 15:29:15 -0000
> @@ -96,7 +96,7 @@
>  public
>  TextField()
>  {
> -  this("", 1);
> +  this("", 0);
>  }
>  
>  /*************************************************************************/
> @@ -113,7 +113,7 @@
>  public
>  TextField(String text)
>  {
> -  this(text, text.length());
> +  this(text, (text == null) ? 0 : text.length());
>  }
>  
>  /*************************************************************************/
> @@ -147,7 +147,11 @@
>  TextField(String text, int columns)
>  {
>    super(text);
> -  this.columns = columns;
> +  
> +  if (columns < 0)
> +    this.columns = 0;
> +  else
> +    this.columns = columns;
>  
>    if (GraphicsEnvironment.isHeadless())
>      throw new HeadlessException ();




More information about the Classpath-patches mailing list