Back to index

moin  1.9.0~rc2
CommandChoice.java
Go to the documentation of this file.
00001 /*
00002  * @(#)CommandChoice.java 5.1
00003  *
00004  */
00005 
00006 package CH.ifa.draw.util;
00007 
00008 import java.awt.*;
00009 import java.awt.event.ItemEvent;
00010 import java.awt.event.ItemListener;
00011 import java.util.*;
00012 
00021 public  class CommandChoice
00022         extends Choice implements ItemListener {
00023 
00024     private Vector   fCommands;
00025 
00026     public CommandChoice() {
00027         fCommands = new Vector(10);
00028         addItemListener(this);
00029     }
00030 
00034     public synchronized void addItem(Command command) {
00035         addItem(command.name());
00036         fCommands.addElement(command);
00037     }
00038 
00042     public void itemStateChanged(ItemEvent e) {
00043         Command command = (Command)fCommands.elementAt(getSelectedIndex());
00044         command.execute();
00045     }
00046 }
00047 
00048