Hi, Please refer following example of JTextArea class with it's methods:
Code:
import javax.swing.JTextArea;
public class JTextAreaTestDm {
public static void main(String[] args) {
JFrame.setDefaultLookAndFeelDecorated(true);
JFrame FP = new JFrame("JTextArea Test");
FP.setLayout(new FlowLayout());
FP.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
String text = "A JTextArea object represents a multiline area for displaying text. "
+ "You can also put your JTextArea in a JScrollPane to make it scrollable.";
JTextArea textAreal = new JTextArea(text, 5, 10);
textAreal.setPreferredSize(new Dimension(100, 100));
JTextArea textArea2 = new JTextArea(text, 5, 10);
textArea2.setPreferredSize(new Dimension(100, 100));
JScrollPane scrollPane = new JScrollPane(textArea2, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
textAreal.setLineWrap(true);
FP.add(textAreal);
FP.add(scrollPane);
FP.pack();
FP.setVisible(true);
}
}
Bookmarks