Java TextArea Multiple Lines Text

Java TextArea Multiple Lines Text

Java TextArea overcomes the limitation of TextField and is used to display or take input in multiple lines of text. Following list illustrates the limitations.

Differences between TextField and TextArea
  1. TextField displays only one line of text of any length. TextArea displays multiple lines of text of any length.
  2. TextField generates ActionEvent handled by ActionListener and TextArea generates TextEvent handled by TextListener.

Following is the hierarchy of TextArea component

Java TextArea Multiple Lines Text

As can be observed from the above figure, both TextField and TextArea are descendents of TextComponent. Both can utilize the methods of TextComponent like setEditable() and getText() etc. This is the advantage of learning super class methods.

Any action, like typing, in TextArea generates TextEvent. TextEvent handler is TextListener. TextListener includes only one abstract method textValueChanged(TextEvent) and should be overridden with the event handling code.

The following program creates two Java TextArea Multiple Lines Text. What is typed in one text area is displayed in the other.

Two TextArea objects typeText and displayText are created one for typing into and the other to display what is typed in the earlier.

4 thoughts on “Java TextArea Multiple Lines Text

  1. SangeetaVaidya

    Respected Sir,

    Am a working parent of 3 kids so in class tuition is not possible.

    Do you teach online via Skype or GotoMeeting ?

    OR

    Can we BUY CD/DVD of ALL your classes ?

    If no then is there any institute in Hyderabad that does ONLINE JAVA coaching?

    Please help.

    Thanks

    Sangeeta Vaidya

Leave a Reply

Your email address will not be published. Required fields are marked *