Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

cannot find symbol - method addActionListener

807606Mar 16 2007 — edited Mar 17 2007
Hi 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();
}
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 14 2007
Added on Mar 16 2007
11 comments
909 views