package cn.edu.zucc.exp1;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class MyMidlet extends MIDlet implements CommandListener {
private Display display;
private Form form = null;
private Command exit;
private Command ok;
private Command clear;
private TextBox textbox;
public MyMidlet() {
display = Display. getDisplay_r(this);
}
public void startApp() {
exit = new Command("exit", Command.EXIT, 1);
ok = new Command("ok", Command.SCREEN, 2);
clear = new Command("clear", Command.SCREEN, 2);
textbox = new TextBox("TextBox", "", 30, TextField.ANY);
textbox.addCommand(ok);
textbox.addCommand(clear);
textbox.setCommandListener(this);
form = new Form("MyMidlet");
form.addCommand(exit);
form.setCommandListener(this);
display.setCurrent(textbox);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
notifyDestroyed();
}
public void commandAction(Command c, Displayable d) {
if (c == ok) {
String str = textbox. getString_r();
form.append(str);
display.setCurrent(form);
} else if (c == clear) {
textbox.setString(null);
} else {
destroyApp(true);
}
}
}