Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Java Example Java Awt TextArea Frame in Java

Related Tutorials


 
 

Share on Google+Share on Google+

TextArea Frame in Java

Advertisement
In this section, you will learn how to create TextArea on the frame. This program uses the TextArea class of java.awt package. Here, we are going to create TextArea object. TextArea object is a multiline region. It displays text only. You can read and

TextArea Frame in Java

     

Introduction

In this section, you will learn how to create TextArea on the frame. This program uses the TextArea class of  java.awt package. Here, we are going to create  TextArea object. TextArea object is a multiline region. It displays text only. You can  read and edit the text only.

Description of this program:

This java program displays the text area  using java AWT package. First of all, We have to define class named "TextAreaFrame" under the java awt package. Inside this class  we are going to create TextArea field by using  "TextArea("Welcome Roseindia",10,20)" constructor. 

TextArea("Welcome Roseindia",10,20): This  constructs a new text area with "Welcome Roseindia" string as text. Both vertical  and horizontal scrollbars will be visible for this text area according to the size specified in the above constructor i.e.10 for horizontal and 20 for vertical.

Here is the code of this Program:

import java.awt.*;
import java.awt.event.*;

public class TextAreaFrame{
  public static void main(String[] args) {
  Frame frame=new Frame("Text Frame");
  TextArea textArea=new TextArea("Welcome Roseindia",10,20);
  frame.add(textArea);
  frame.setLayout(new FlowLayout());
  frame.setSize(250,250);
  frame.setVisible(true);
  frame.addWindowListener(new WindowAdapter(){
  public void windowClosing(WindowEvent e){
  System.exit(0);
  }
  });
  }
}

 Output this program:

Download this Example.

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: March 13, 2008

Related Tutorials

Discuss: TextArea Frame in Java   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:1
Usman Hamza
August 5, 2012
How could i Display??

How can i display the same codes of my program on the textArea, please??? thank you very much!
DMCA.com