Pages

Create text area using JTextArea

Source code below will show you how to create text area in java using JTextArea class.

**********************************************************************
COMPLETE SOURCE CODE FOR : CreateTextAreaUsingJTextArea.java
**********************************************************************


import javax.swing.JTextArea;
import javax.swing.JFrame;

public class CreateTextAreaUsingJTextArea
{
public static void main(String[]args)
{
//Create text area without initial text using JTextArea
JTextArea textArea=new JTextArea();

//Create a JFrame that will be use to place JTextArea
JFrame frame=new JFrame("Create text area using JTextArea");

//Add text area into JFrame
frame.add(textArea);

//set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//set JFrame size
//WIDTH = 500 pixels
//HEIGHT = 500 pixels
frame.setSize(500,500);

//make JFrame visible. So we can see it
frame.setVisible(true);
}
}


**********************************************************************
JUST COMPILE AND EXECUTE IT
**********************************************************************
Related Posts Plugin for WordPress, Blogger...