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

📄 itemcommandlistenerdemo.java

📁 J2ME手机游戏开发技术详解,适合初学者阅读使用
💻 JAVA
字号:
import javax.microedition.lcdui.*;import javax.microedition.midlet.MIDlet;public class ItemCommandListenerDemo extends MIDlet {    private final static Command CMD_STOP = new Command("暂停",                                                         Command.ITEM, 1);    private final static Command CMD_RESTART = new Command("重新开始",                                                         Command.ITEM, 2);    private final static Command CMD_EXIT = new Command("退出",                                                         Command.ITEM, 3);    private Display display;    private NonInteractiveGaugeRunnable nonInteractive;    private Form mainForm;    private Thread mThread;        public ItemCommandListenerDemo() {        display = Display.getDisplay(this);        mainForm = new Form("Gauge演示");                        nonInteractive = new NonInteractiveGaugeRunnable(                                 "非交互模式", 10, 0);        mThread = new Thread(nonInteractive);        mThread.start();        mainForm.append(nonInteractive);        nonInteractive.addCommand(CMD_STOP);        nonInteractive.addCommand(CMD_RESTART);        nonInteractive.addCommand(CMD_EXIT);        ItemCommandListener listener = new ItemCommandListener(){        public void commandAction(Command command, Item item) {        if(item == nonInteractive){        if(command == CMD_STOP)nonInteractive.stop();        if(command == CMD_RESTART)nonInteractive.reStart();        if(command == CMD_EXIT){                destroyApp(false);                notifyDestroyed();        }        }        }        };        nonInteractive.setItemCommandListener(listener);    }    /**     * Signals the MIDlet to start and enter the Active state.     */    protected void startApp() {                display.setCurrent(mainForm);    }    /**     * Signals the MIDlet to terminate and enter the Destroyed state.     */    protected void destroyApp(boolean unconditional) {        nonInteractive.setDone();    }    /**     * Signals the MIDlet to stop and enter the Paused state.     */    protected void pauseApp() {    }}

⌨️ 快捷键说明

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