diff options
author | Tania Bento <tbento@redhat.com> | 2006-06-30 20:43:27 +0000 |
---|---|---|
committer | Tania Bento <tbento@redhat.com> | 2006-06-30 20:43:27 +0000 |
commit | 859a1b21d21c49320f3b78db9129ab5b980f0a14 (patch) | |
tree | eb30f51d19c3a998d8ff0747f0e61ef94f49f90f /java | |
parent | a4f5a56b4dcc4003baaecb7c0ea20ea142eb5241 (diff) | |
download | classpath-859a1b21d21c49320f3b78db9129ab5b980f0a14.tar.gz |
2006-06-30 Tania Bento <tbento@redhat.com>
* java/awt/TextArea.java
(TextArea(String, int, int, int)): No longer throws
IllegalArgumentException if rows, columns, or scrollbarVisibility
values are invalid.
(TextArea(String, int, int, int)): If rows or columns are < 0,
they get set to 0. If scrollbarVisibility is < 0 or > 4, it
gets set to the default value of 0 (SCROLLBARS_BOTH).
(appendText): Added case when peer = null.
(insertText): Added case when peer == null.
(replaceText): Added case when peer == null.
* java/awt/TextComponent.java
(TextComponent(String)): If text == null, set it to "".
Diffstat (limited to 'java')
-rw-r--r-- | java/awt/Component.java | 2 | ||||
-rw-r--r-- | java/awt/TextArea.java | 64 | ||||
-rw-r--r-- | java/awt/TextComponent.java | 6 |
3 files changed, 51 insertions, 21 deletions
diff --git a/java/awt/Component.java b/java/awt/Component.java index b3512c43a..f61cc24e8 100644 --- a/java/awt/Component.java +++ b/java/awt/Component.java @@ -4697,7 +4697,7 @@ p * <li>the set of backward traversal keys Object newValue) { if (changeSupport != null) - changeSupport.firePropertyChange(propertyName, oldValue, newValue); + changeSupport.firePropertyChange(propertyName, oldValue, newValue); } /** diff --git a/java/awt/TextArea.java b/java/awt/TextArea.java index b04cdc892..7e3463ab8 100644 --- a/java/awt/TextArea.java +++ b/java/awt/TextArea.java @@ -125,9 +125,11 @@ public class TextArea extends TextComponent implements java.io.Serializable * the specified text. Conceptually the <code>TextArea</code> has 0 * rows and 0 columns but its initial bounds are defined by its peer * or by the container in which it is packed. Both horizontal and - * veritcal scrollbars will be displayed. + * veritcal scrollbars will be displayed. The TextArea initially contains + * the specified text. If text specified as <code>null<code>, it will + * be set to "". * - * @param text The text to display in this text area. + * @param text The text to display in this text area (<code>null</code> permitted). * * @exception HeadlessException if GraphicsEnvironment.isHeadless () is true */ @@ -156,9 +158,10 @@ public class TextArea extends TextComponent implements java.io.Serializable * Initialize a new instance of <code>TextArea</code> that can * display the specified number of rows and columns of text, without * the need to scroll. The TextArea initially contains the - * specified text. + * specified text. If text specified as <code>null<code>, it will + * be set to "". * - * @param text The text to display in this text area. + * @param text The text to display in this text area (<code>null</code> permitted). * @param rows The number of rows in this text area. * @param columns The number of columns in this text area. * @@ -174,9 +177,10 @@ public class TextArea extends TextComponent implements java.io.Serializable * contains the specified text. The TextArea can display the * specified number of rows and columns of text, without the need to * scroll. This constructor allows specification of the scroll bar - * display policy. + * display policy. The TextArea initially contains the specified text. + * If text specified as <code>null<code>, it will be set to "". * - * @param text The text to display in this text area. + * @param text The text to display in this text area (<code>null</code> permitted). * @param rows The number of rows in this text area. * @param columns The number of columns in this text area. * @param scrollbarVisibility The scroll bar display policy. One of @@ -192,18 +196,20 @@ public class TextArea extends TextComponent implements java.io.Serializable 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"); + if (rows < 0) + this.rows = 0; + else + this.rows = rows; + + if (columns < 0) + this.columns = 0; + else + this.columns = columns; - this.rows = rows; - this.columns = columns; - this.scrollbarVisibility = scrollbarVisibility; + 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 +484,8 @@ public class TextArea extends TextComponent implements java.io.Serializable if (peer != null) peer.insert (str, peer.getText().length ()); + else + setText(getText() + str); } /** @@ -504,10 +512,19 @@ public class TextArea extends TextComponent implements java.io.Serializable */ 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 +561,19 @@ public class TextArea extends TextComponent implements java.io.Serializable */ 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); + } } /** diff --git a/java/awt/TextComponent.java b/java/awt/TextComponent.java index 51a5bd5c1..ebdb9a257 100644 --- a/java/awt/TextComponent.java +++ b/java/awt/TextComponent.java @@ -312,7 +312,11 @@ public class TextComponent extends Component TextComponent(String text) { - this.text = text; + if (text == null) + this.text = ""; + else + this.text = text; + this.editable = true; } |