cannot find symbol - method addActionListener
807606Mar 16 2007 — edited Mar 17 2007Hi i read up several thread on similar but most of them are careless mistake such as typo error. Sigh~ i check thru my spelling, arrangement of my classes etc but still can't get the code to work. any expert can that can help me debug? thx
----------------------------------------------------------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Test extends JFrame {
JPanel panel;
JLabel lblTitle = new JLabel("Test");
JLabel lblTestScore = new JLabel("Test Score");
JTextArea taTestScore = new JTextArea("0");
public Test() {
ActionHandler actionhandler = new ActionHandler();
panel = (JPanel) getContentPane();
panel.setLayout(null);
lblTitle.setBounds(85,20,250,20);
panel.add(lblTitle);
lblTestScore.setBounds(10,65,80,20);
panel.add(lblTestScore);
taTestScore.setBounds(85,65,30,20);
panel.add(taTestScore);
taTestScore.addActionListener(actionhandler);
setTitle("Test");
setSize(300,250);
setVisible(true);
}
private class ActionHandler implements ActionListener {
public void actionPerformed(ActionEvent e){
//do something
}
}
public static void main(String[] args) {
new Test();
}
}