Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

TextAreaHandler

 
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.
Thanks.
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.setBackground(Color.cyan);
t.setFont(new Font("TimesRoman",Font.ITALIC,24));
t.setToolTipText("this is a TextBox");
t.setText("type here");
c.add(t);

TextAreaHandler handler=new TextAreaHandler();
t.addActionListener(handler);
setSize(325,100);
show();
}
 
Jim Yingst
Wanderer
Sheriff
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