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 Model model; protected Square.ButtonAction action; public Button (Model model, Square.ButtonAction action) { this.model = model; this.action = action; setBorder (new LineBorder(Color.GREEN, 2)); addActionListener (this); } public void actionPerformed (ActionEvent e) { model.getCurrent().doAction (action); } }