Responding to Button Events
public void actionPerformed(ActionEvent e)
String arg = e.getActionCommand();
//make sure the event source is a button
if (e.getSource() instanceof Button)
//make sure it is the right button
if ("My Button" .equals ( (String) arg)
System.out.println ("Button pressed!");