课外天地 李树青学习天地JavaME移动开发课件 → 程序代码——表单导航


  共有15544人关注过本帖树形打印复制链接

主题:程序代码——表单导航

帅哥哟,离线,有人找我吗?
admin
  1楼 博客 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信 管理员
等级:管理员 帖子:1949 积分:26803 威望:0 精华:34 注册:2003/12/30 16:34:32
程序代码——表单导航  发帖心情 Post By:2008/9/22 22:57:46 [只看该作者]

/*
* Midlet.java
*
* Created on 2008年9月17日, 上午10:49
*/

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;

/**
*
* @author Administrator
* @version
*/
public class Exec extends MIDlet implements CommandListener {
        Display display = Display.getDisplay(this);
        Form form1 = new Form("表单1");
        Form form2 = new Form("表单2");
        Command cmd11 = new Command("退出", Command.EXIT, 1);
        Command cmd12 = new Command("下一个", Command.BACK, 1);
        Command cmd21 = new Command("退出", Command.EXIT, 1);
        Command cmd22 = new Command("上一个", Command.BACK, 1);

        public void startApp() {
                form1.addCommand(cmd11);
                form1.addCommand(cmd12);
                form1.setCommandListener(this);
                display.setCurrent(form1);
        }

        public void pauseApp() {
        }

        public void destroyApp(boolean unconditional) {
        }

        public void commandAction(Command cmd, Displayable arg1) {
                if (cmd.equals(cmd11) || cmd.equals(cmd21)) {
                        display.setCurrent(new Form("Null"));
                } else if (cmd.equals(cmd12)) {
                        form2.addCommand(cmd21);
                        form2.addCommand(cmd22);
                        form2.setCommandListener(this);
                        display.setCurrent(form2);
                } else if (cmd.equals(cmd22)) {
                        display.setCurrent(form1);
                }
        }
}

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

 回到顶部