Home Java Example Java Awt TextArea Frame in Java



TextArea Frame in Java
Posted on: March 13, 2008 at 12:00 AM
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.

Related Tags for TextArea Frame in Java:
javaccomideclasstextscriptconstructorobjectiostructconstdisplaytextareaipawtfieldreadnameusinglinethisidpackagetarcreatedefineeditframetexiemultilineprogramtoedilearnramlddescriptionearexteilregionitareadesmultisectioncanlispluseulfirstinasmplaytrsidsideoscaosjisppackadclesallagenamedmehowobjproacktorsspctordisplaysatpackisirhallgodiaeaandarconsstrxtwtvausesscrssriripthtextareavstafctodispfinframjeplprndonlyonomogronl


More Tutorials from this section

Ask Questions?    Discuss: TextArea Frame in Java   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.