package fun;

import javax.microedition.lcdui.*;

import java.util.*;

public class T3Choice extends List {

	public T3Choice(final T3MIDlet midlet, final Vector v){
		super("Vali m6istatus", List.EXCLUSIVE);

		{
			append("<UUS>", null);
		}

		for(Enumeration e = v.elements(); e.hasMoreElements(); ){
			Integer id = (Integer)e.nextElement();
			append(id.toString(), null);
		}
		
		final Command ok = new Command("OK", Command.OK, 0);
		addCommand(ok);

		setCommandListener(new CommandListener(){
			public void commandAction(Command c, Displayable d){
			
				if(c.equals(ok) || c.equals(List.SELECT_COMMAND)){
					Integer id = null;
					if(getSelectedIndex() > 0){
						id = (Integer)v.elementAt(getSelectedIndex() - 1);
					}

					midlet.initPuzzle(id != null ? id.intValue() : 0);
				}
			}
		});
	}
}