import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.border.*; /** * Base class for all our buttons */ public abstract class Button extends JButton implements ActionListener { protected Square square; protected Square.ButtonAction action; public Button (Square square, Square.ButtonAction action) { this.square = square; this.action = action; setBorder (new LineBorder(Color.GREEN, 2)); addActionListener (this); } public void actionPerformed (ActionEvent e) { square.doAction (action); } }