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; //*1 Common to all our buttons
protected Square.ButtonAction action; //*1
public Button (Square square, Square.ButtonAction action) {
this.square = square; //*1
this.action = action; //*1
setBorder (new LineBorder(Color.GREEN, 2)); //*1
addActionListener (this); //*2 Shared routine, parameterized by "action" supplied by subclass
}
public void actionPerformed (ActionEvent e) { //*2
square.doAction (action); //*2
}
}