import javax.microedition.lcdui.*;
import window.*;

public class TextInput extends TextBox implements CommandListener {
	private WinText wt;
	private WinForm wf;
	private Command ok, can;
	
	public TextInput(WinText wt, WinForm wf){
		super("Введите текст:",wt.caption,wt.max,TextField.ANY);
		this.wt = wt;
		this.wf = wf;
		ok = new Command("Ок",Command.OK,1);
		can = new Command("Назад",Command.CANCEL,1);
		addCommand(ok);
		addCommand(can);
		setCommandListener(this);
	}
	
	public void commandAction(Command c,Displayable d){
		if(c==ok){
			wt.caption = getString();
			wt.resize(wt.caption, wt.wid, wt.hei);
			wf.refresh();
			Main.midlet.dis.setCurrent(Main.midlet.mw);
			Main.midlet.mw.setFullScreenMode(true);
		}
		if(c==can){
			Main.midlet.dis.setCurrent(Main.midlet.mw);
			Main.midlet.mw.setFullScreenMode(true);
		}
	}
	
}