import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.TextBox;
import javax.microedition.midlet.MIDlet;
public class FewCommandsMIDlet extends MIDlet implements CommandListener {
private Command exitCommand = new Command("A", Command.SCREEN, 1);
private Command infoCommand = new Command("B", Command.SCREEN, 2);
private Command aboutCommand = new Command("C", Command.SCREEN, 2);
private Display display;
public FewCommandsMIDlet() {
display = Display.getDisplay(this);
}
public void startApp() {
TextBox t = new TextBox("sdf", "Welcome to MIDP Programming", 256, 0);
t.addCommand(infoCommand);
t.addCommand(exitCommand);
t.addCommand(aboutCommand);
t.setCommandListener(this);
display.setCurrent(t);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c, Displayable s) {
if (c == exitCommand) {
destroyApp(false);
notifyDestroyed();
}
}
}
|