JTextArea

The JTextArea class defines a component that allows editing of multiline text that is contained within a given area.

JTextArea (String text, int rows, int cols )

Here, text is the string to be displayed within the textarea. Here, rows is the number of rows in the textarea. Here, cols is the number of cols in the textarea.

Program

vgfxdgg

 

 

 

Program Source

import javax.swing.JFrame;
import javax.swing.JTextArea;
import java.awt.FlowLayout;

class Frame extends JFrame {
   
    Frame()
    {
        setTitle("JTextArea");
        setLayout(new FlowLayout());
        setJTextArea();
        setSize(700,250);
        setVisible(true);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
    
    private void setJTextArea()
    {
        String data = "Java is a computer programming language that is n"
                     +"concurrent, class-based, object-oriented, and n"
                     +"specifically designed to have as few implementation n"
                     +"dependencies as possible. It is intended to let n"
                     +"application developers write once, run anywhere n"
                     +"(WORA), meaning that code that runs on one n"
                     +"platform does not need to be recompiled to run on another.nn" 
                     +"Java applications are typically compiled to bytecode n"
                     +"(class file) that can run on any Java virtual machine n"
                     +"(JVM) regardless of computer architecture.";
        JTextArea jt = new JTextArea(data,12,40);
        add(jt);
    }
}

public class Javaapp {
   
    public static void main(String[] args) {
        
       Frame fr = new Frame();
    }
}

Leave a Comment