SimpleButton2 (other files are same as before)

MyButton.java  [download]

import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class MyButton extends JButton implements ActionListener { //*1 MyButton will BE the listener
    public MyButton (String label) {
	setText (label);
	addActionListener (this); //*2 Add this button as its own listener
    }

    public void actionPerformed (ActionEvent e) { //*3 Callback routine
	System.out.println ("Button was pushed"); //*3
    }
}