package src;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class TextBoxTest extends MIDlet implements CommandListener{
private TextBox textbox;
private Alert alert;
private Command quit;
private Command go;
public TextBoxTest()
{
textbox = new TextBox("Enter Thy Name","Sir",20,TextField.ANY);
go = new Command("Go", Command.SCREEN, 1);
quit = new Command("Quit", Command.EXIT, 2);
textbox.addCommand(go);
textbox.addCommand(quit);
textbox.setCommandListener(this);
}
protected void destroyApp(boolean b) throws MIDletStateChangeException {
// TODO destroyApp
}
protected void pauseApp() {
// TODO pauseApp
}
protected void startApp() throws MIDletStateChangeException {
// TODO pauseApp
Display.getDisplay(this).setCurrent(textbox);
}
public void commandAction(Command c, Displayable d) {
// TODO commandAction
try
{
if(c==quit)
{
destroyApp(true);
notifyDestroyed();
}
if(c==go)
{
alert = new Alert("", "Greetings "+textbox.getString(),null,AlertType.CONFIRMATION);
Display.getDisplay(this).setCurrent(alert);
}
}
catch (MIDletStateChangeException e)
{
System.out.println(e + "caught.s");
}
}
}