每当我尝试实施时,我都会收到以下消息CommandListener
。请让我知道我需要做什么?
Midlet 不是抽象的,不会覆盖 CommandListener 中的抽象方法 commandAction(Command,Displayable)
package displaytest;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import javax.microedition.midlet.MIDlet;
import javax.microedition.lcdui.*;
public class Midlet extends MIDlet implements CommandListener {
private Display display = null;
private Form form;
public void startApp() {
form = new Form("Hello World");
String msg = "Hello World! DisplayTest 12";
form.addCommand(screen);
form.addCommand(ok);
form.append(msg);
display = Display.getDisplay(this);
display.setCurrent(form);
}
private Command screen, ok;
public Midlet(){
form = new Form("Command Form");
screen = new Command("SCREEN", Command.SCREEN, 1);
ok = new Command("OK", Command.OK, 4);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
notifyDestroyed();
}
public void okCom(){
Alert ok = new Alert("OK Command", "OK Command Executed!", null, AlertType.INFO);
ok.setTimeout(5000);
display.setCurrent(ok, form);
}
}