Java Design Pattern
Introduction to Java 10
Introduction to Java 11
Introduction to Java 12

JTextArea class

The JTextArea class in swing is used to create a text area. It is a multiline area that displays the plain text only. The JTextArea having following constructors.

  1. JTextArea(): creates a text area that displays no text initially.
  2. JTextArea(String s): creates a text area that displays specified text initially.
  3. JTextArea(int row, int column): creates a text area with the specified number of rows and columns that displays no text initially.
  4. JTextArea(String s, int row, int column): creates a text area with the specified number of rows and columns that displays specified text.

Let's see an example of JTextArea class:

Let's see an example of JTextArea class:
import java.awt.Color;  
import javax.swing.*;  
public class JTextAreaDemo {  
	JTextArea area;  
	JFrame f;  
	JTextAreaDemo(){  
		f=new JFrame();  
			  
		area=new JTextArea(200,200);  
		area.setBounds(10,30,200,200);  
		  
		area.setBackground(Color.blue);  
		area.setForeground(Color.white);  
		f.add(area);  
		f.setSize(300,300);  
		f.setLayout(null);  
		f.setVisible(true);  
	}  
	public static void main(String[] args) {  
		new JTextAreaDemo();  
	}
}
Output:

pic


About the Author



Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.


We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc






 PreviousNext