Home | » | Java | » | Advance Java | » | » | Swing | » | JTextArea |
---|
A text area is a text control that lets the user enter multiple lines of text.
Text areas are implemented in Swing with the JTextArea class. It takes the following constructor methods:
- JTextAread(int, int) A text area with the specified number of rows and columns.
- JTextArea(String, int, int) A text field with the specified text , rows and columns.
Example:
The following example creates a text area object of 10 rows and 20 columns.
The following table describes some of the methods provided by the JTextArea class
Methods | Description |
---|---|
append(String) | Appends the given string to the end of the document. |
void getColumns(int) int getRows(int) | Returns the number of columns and rows in the text area. |
insert(String, int) | Insert a specified text at the specified position in the text area. |
void setRows(int) void setFont(Font) | The setRows() methods sets the number of rows for the text area and the setFont() method sets a specific font for the text. |
The following example displayed one text field and one password field.
C:\>jdk1.4\bin>javac TextAreaDemo.java
C:\>jdk1.4\bin>java TextAreaDemo
|
||
Download Complete Program |
Java Swing-1
JFrame | JPanel | JApplet |
JButtons | JLabels | JTextFields |
JPasswordField | JTextAreas | JCheckBoxes |
JRadioButtons | JList | JComboBox |
No comments:
Post a Comment