This page contains an archived post to the Java Answers Forum made prior to February 25, 2002.
If you wish to participate in discussions, please visit the new
Adding action listeners to JButton
Posted by Hiran on January 25, 2002 at 10:45 AM
How do I add an action listener to JButton? I've done this before, but I must be doing something wrong, because I'm getting an error message. Here's my code:
public class HoursTrackerGUI extends JFrame
private JButton setStartTime = new JButton("Clock in");
Container contents = this.getContentPane();
private class SSTListener implements ActionListener
public void actionPerformed(ActionEvent e)
System.out.println("The button was pressed!");
Thanks in advance.