以文本方式查看主题

-  课外天地 李树青  (http://njcie.com/bbs/index.asp)
--  JavaME移动开发课件  (http://njcie.com/bbs/list.asp?boardid=18)
----  程序代码——MIDLET发出的主动暂停操作  (http://njcie.com/bbs/dispbbs.asp?boardid=18&id=511)

--  作者:admin
--  发布时间:2008/9/18 20:51:44
--  程序代码——MIDLET发出的主动暂停操作

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.midlet.MIDlet;

public class Exec extends MIDlet implements CommandListener {
        private Display display;
        Form f = new Form("HelloTest");
        private Command cmd;

        // 构造函数
        public Exec() {
                display = Display.getDisplay(this);
                cmd = new Command("暂停", Command.SCREEN, 2);
                f.addCommand(cmd);
                f.setCommandListener(this);
                display.setCurrent(f);
                System.out.println("Constructor");
        }

        public void startApp() {
                System.out.println("startApp is called.");

        }

        public void pauseApp() {
                System.out.println("pauseApp is called.");
        }

        public void destroyApp(boolean unconditional) {
                System.out.println("destroyApp is called.");

        }

        public void commandAction(Command c, Displayable s) {
                System.out.println("commandAction");
                pauseApp();
                notifyPaused();
        }
}

[此贴子已经被作者于2010-12-12 18:23:08编辑过]