❮ Previous Next ❯

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

❮ Previous Next ❯



  Tutorials

Popular Links

Contact Us

address Plot No-741,2ND Floor
Opp. Bhagabati Temple,Jayadev Vihar
      Bhubaneswar-751013
      Email: info@silantechnology.com
      Phone: 0674-2361252
address
39877, sundale dr, apt#101, Fremont, California 94538, USA
       Phone: +1(262)388-7619

facebook twitter google linked in

© 2018 Silan Technology. All Rights Reserved