To extend from Darryl's advice, another option you may wish to take advantage of is the action command of the ActionEvent



public void actionPerformed(ActionEvent e){
String command =...