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; //*1 Same as previous, except saves model not square protected Square.ButtonAction action; public Button (Model model, Square.ButtonAction action) { //*1 this.model = model; //*1 this.action = action; setBorder (new LineBorder(Color.GREEN, 2)); addActionListener (this); } public void actionPerformed (ActionEvent e) { //*2 Gets current square from model, then calls it model.getCurrent().doAction (action); //*2 } }