Back to index

moin  1.9.0~rc2
CommandButton.java
Go to the documentation of this file.
00001 /*
00002  * @(#)CommandButton.java 5.1
00003  *
00004  */
00005 
00006 package CH.ifa.draw.util;
00007 
00008 import java.awt.*;
00009 import java.awt.event.ActionListener;
00010 import java.awt.event.ActionEvent;
00011 import java.util.*;
00012 
00019 public  class CommandButton
00020         extends Button implements ActionListener {
00021 
00022     private Command   fCommand;
00023 
00028     public CommandButton(Command command) {
00029        super(command.name());
00030        fCommand = command;
00031        addActionListener(this);
00032     }
00033 
00039     public void actionPerformed(ActionEvent e) {
00040         fCommand.execute();
00041         if (!getLabel().equals(fCommand.name()) ) {
00042             setLabel(fCommand.name());
00043         }
00044     }
00045 }
00046 
00047