⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 firstmidlet.java

📁 J2ME程序设计实例教程的源码
💻 JAVA
字号:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class FirstMIDlet extends MIDlet implements CommandListener {
    protected void startApp() {
        Display display = Display.getDisplay(this);
        TextBox text = new TextBox("第一个MIDlet",
                          "我们开始学是MIDP编程!", 127, TextField.ANY);
        Command cmdExit = new Command("退出", Command.EXIT, 0);
        text.addCommand(cmdExit);
        text.setCommandListener(this);
        display.setCurrent(text);
    }

    protected void pauseApp() {
    }

    protected void destroyApp(boolean undicational) {
    }
    
    //当用户触发“退出”命令时,系统会自动调用这个方法
    public void commandAction(Command cmd, Displayable d) {
        if(cmd.getCommandType() == Command.EXIT) {
            notifyDestroyed();
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -