This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

TextAreaHandler  RSS feed

jyothi godavarthy
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, could anyone help me with this code as I am getting compiler error that no addActionListener method in TextAreaHandler class.
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class TextArea extends JFrame {
JTextArea t;
public TextArea(){
super("Testing TextBox");
Container c= getContentPane();
c.setLayout(new FlowLayout());
t=new JTextArea(20,12);
t.setFont(new Font("TimesRoman",Font.ITALIC,24));
t.setToolTipText("this is a TextBox");
t.setText("type here");

TextAreaHandler handler=new TextAreaHandler();
Jim Yingst
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've never heard of a "TextAreaHandler" class - it isn't in the standard jdk as of version 1.3, and you don't show any source code for it, so I have no idea what it does. Probably your compiler doesn't know either. On the other hand, there is a class called "TextArea" already in the java.awt package, so it's probably a bad idea to create a new class with that name, as you are doing.
As for the code "t.addActionListener(handler)": t has been declared as a JTextComponent. If you read the API, a JTextComponent does not have any addActionListener method. It has many other listeners, but ActionListener is not one of them. Without the source code for TextAreaHandler, it's not clear if it implements any type of listener interface.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!