TextArea
A TextArea is a multi-row text field that displays a single string of
characters, where newline ends each row. The width and height of the field
is set at construction, but the text can be scrolled up/down and left/right.
Corresponding source code:
import java.applet.*;
import java.awt.*;
public class TextAreaWidget extends Applet {
public void init() {
TextArea disp = new TextArea("A TextArea", 3, 30);
add(disp);
}
}
Method(s) of note:
- public TextArea(String text, int rows, int cols)
Create a TextArea with the specified number of rows and columns and some initial text.
- public void appendText(String str)
Add some text to the end of the current text.
- public void insertText(String str, int pos)
Insert some text at a particular String index in the TextArea.
There is no predefined way to set a particular row of text. Carriage returns are used to separate the rows, which must be counted to get to the nth row.
Related Magercise(s):