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

Our Services:

Java Training | Python Training | Machine Learning with Python Training | Deep Learning with Python Training | Data Science with Python Training | Projects

SILAN Technology, BBSR
Call to: 9439202111  |  9658317757  |  0674-2361252

Comment