import java.awt.*; import java.awt.event.*; /** A class to which a command object can be added. The button executes the connected command when clicked. */ public class MyButton extends Button implements ActionListener { protected Command command; public MyButton() { addActionListener(this); command = null; } public MyButton(String s) { addActionListener(this); setLabel(s); } public void actionPerformed(ActionEvent e) { if (command != null) command.Execute(); } public void setCommand(Command c) { command = c; } }