Hey guys,

This patch fixes a failing Harmony Test (TextAreaTest.testReplaceText).
These changes follow the reference implementation. Can someone please
approve and/or comment on this patch. 

Thanks,
Tania

2006-06-28  Tania Bento  <[EMAIL PROTECTED]>
        
        *java/awt/TextArea.java
        (replaceText): Implemented case when peer == null.
        (TextArea): Doesn't throw Exception in constructor if rows
        or columns < 0. It just sets them to 0.
        (TextArea): Doesn't throw Exception if scrollbarVisibility
        < 0 and > 4. It just sets it to 0.
Index: java/awt/TextArea.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/awt/TextArea.java,v
retrieving revision 1.20
diff -u -r1.20 TextArea.java
--- java/awt/TextArea.java	20 Sep 2005 01:05:28 -0000	1.20
+++ java/awt/TextArea.java	28 Jun 2006 17:31:34 -0000
@@ -192,18 +192,20 @@
     if (GraphicsEnvironment.isHeadless ())
       throw new HeadlessException ();
 
-    if (rows < 0 || columns < 0)
-      throw new IllegalArgumentException ("Bad row or column value");
-
-    if (scrollbarVisibility != SCROLLBARS_BOTH
-        && scrollbarVisibility != SCROLLBARS_VERTICAL_ONLY
-        && scrollbarVisibility != SCROLLBARS_HORIZONTAL_ONLY
-        && scrollbarVisibility != SCROLLBARS_NONE)
-      throw new IllegalArgumentException ("Bad scrollbar visibility value");
-
-    this.rows = rows;
-    this.columns = columns;
-    this.scrollbarVisibility = scrollbarVisibility;
+    if (rows < 0)
+      this.rows = 0;
+    else
+      this.rows = rows;
+    
+    if (columns < 0)
+      this.columns = 0;
+    else
+      this.columns = columns;
+
+    if (scrollbarVisibility < 0 || scrollbarVisibility > 4)
+      this.scrollbarVisibility = SCROLLBARS_BOTH;
+    else
+      this.scrollbarVisibility = scrollbarVisibility;
 
     // TextAreas need to receive tab key events so we override the
     // default forward and backward traversal key sets.
@@ -544,10 +546,17 @@
    */
   public void replaceText (String str, int start, int end)
   {
+    String tmp1 = null;
+    String tmp2 = null;
+    
     TextAreaPeer peer = (TextAreaPeer) getPeer ();
-
+   
     if (peer != null)
       peer.replaceRange (str, start, end);
+    else
+      tmp1 = getText().substring(0, start);
+      tmp2 = getText().substring(end, getText().length());    
+      setText(tmp1 + str + tmp2);
   }
 
   /**

Reply via email to