code:
HelloWorld.java
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class HelloWorld extends MIDlet implements CommandListener {
private Command exitCommand;
private TextBox tb;
public HelloWorld() {
exitCommand = new Command("Exit", Command.EXIT, 1);
tb = new TextBox("Hello 向东", "Hello,World!", 15, 0);
tb.addCommand(exitCommand);
tb.setCommandListener(this);
}
protected void startApp() throws MIDletStateChangeException {
Display.getDisplay(this).setCurrent(tb);
System.out.println("startApp");
}
protected void pauseApp() {
System.out.println("pauseApp");
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
System.out.println("destroyApp");
}
public void commandAction(Command c, Displayable d) {
if (c == exitCommand) {
try {
destroyApp(false);
} catch (MIDletStateChangeException exception) {
System.out.println("MIDletStateChangeException");
}
notifyDestroyed();
}
}
}
HelloWorld.java
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class HelloWorld extends MIDlet implements CommandListener {
private Command exitCommand;
private TextBox tb;
public HelloWorld() {
exitCommand = new Command("Exit", Command.EXIT, 1);
tb = new TextBox("Hello 向东", "Hello,World!", 15, 0);
tb.addCommand(exitCommand);
tb.setCommandListener(this);
}
protected void startApp() throws MIDletStateChangeException {
Display.getDisplay(this).setCurrent(tb);
System.out.println("startApp");
}
protected void pauseApp() {
System.out.println("pauseApp");
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
System.out.println("destroyApp");
}
public void commandAction(Command c, Displayable d) {
if (c == exitCommand) {
try {
destroyApp(false);
} catch (MIDletStateChangeException exception) {
System.out.println("MIDletStateChangeException");
}
notifyDestroyed();
}
}
}
作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:https://jackxiang.com/post/175/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!
评论列表