Hey, This patch fixes a couple of Harmony's Tests that were failing on Classpath:
- In the InsertText and AppendTextMethod, I added the case where peer == null. - In the constructor, if the text specified by the user is null, it should be changed to "". Could someone please approve/comment on this patch so that I can commit it. Thanks, Tania 2006-06-29 Tania Bento <[EMAIL PROTECTED]> *java/awt/TextArea.java (TextArea): If text == null, change it to "". (InsertText): Added the case when peer == null. (AppendText): Added the case when peer == null.
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 29 Jun 2006 14:34:04 -0000 @@ -187,23 +187,25 @@ */ public TextArea (String text, int rows, int columns, int scrollbarVisibility) { - super (text); + super ((text == null) ? "" : text); 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. @@ -478,6 +481,10 @@ if (peer != null) peer.insert (str, peer.getText().length ()); + else + setText(getText() + str); + + } /** @@ -504,10 +511,17 @@ */ public void insertText (String str, int pos) { + String tmp1 = null; + String tmp2 = null; + TextAreaPeer peer = (TextAreaPeer) getPeer (); if (peer != null) peer.insert (str, pos); + else + tmp1 = getText().substring(0, pos); + tmp2 = getText().substring(pos, getText().length()); + setText(tmp1 + str + tmp2); } /** @@ -544,10 +558,19 @@ */ public void replaceText (String str, int start, int end) { - TextAreaPeer peer = (TextAreaPeer) getPeer (); + String tmp1 = null; + String tmp2 = null; + + TextAreaPeer peer = (TextAreaPeer) getPeer(); if (peer != null) - peer.replaceRange (str, start, end); + peer.replaceRange(str, start, end); + else + { + tmp1 = getText().substring(0, start); + tmp2 = getText().substring(end, getText().length()); + setText(tmp1 + str + tmp2); + } } /**