import javax.swing.*; /** * Simple button demonstration - first example of event handling. * CSE 143 Sp03 demo. * * @author Hal Perkins * @version 4/17/03 */ public class ButtonDemo extends JPanel { /** * Construct a new ButtonDemo by creating a button in the panel and * registering a new ButtonListener to respond to clicks on the button */ public ButtonDemo() { JButton button = new JButton("Hit me!"); button.setActionCommand("OUCH!"); // optional - default is button text button.addActionListener(new ButtonListener()); add(button); } }