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 J2MECommandGetter extends MIDlet implements CommandListener {
private Command exitCommand = new Command("EXIT", Command.EXIT, 1);
private Command infoCommand = new Command("info", Command.SCREEN, 1);
TextBox t= new TextBox("Hello MIDP", "Welcome to MIDP Programming", 256, 0);
private Display display;
public J2MECommandGetter() {
display = Display.getDisplay(this);
}
public void startApp() {
t.addCommand(exitCommand);
t.addCommand(infoCommand);
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();
}
if (c == infoCommand) {
((TextBox) s).setString(infoCommand.getLabel() + " " + infoCommand.getCommandType()
+ infoCommand.getPriority());
}
}
}
|