您的位置:首页 > 编程语言

郭克华手机编程教学视频----我的练习源码(3)按钮显示优先级测试

2009-02-04 17:46 489 查看
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package hello;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import javax.microedition.midlet.*;

/**
* 按钮显示优先级测试
* @author mouyong
*/
public class Midlet3 extends MIDlet {

private Form frm = new Form("请您选择相应的操作");
Display dis;
/**
* Command的类型(CommandType):
* SCREEN:面向整个界面组件进行操作
* BACK:返回上一个操作
* CANCEL:否
* OK:是
* HELP:帮助
* STOP:停止某个操作而不做屏幕切换
* EXIT:退出
* ITEM:面向局部进行操作
* 注意:按钮类型仅作为一种标识,实际的功能实现代码仍然需要自己编写。
*/
Command cmdSCREEN = new Command("SCREEN", Command.SCREEN, 1);
Command cmdBACK = new Command("BACK", Command.BACK, 1);
Command cmdCANCEL = new Command("CANCEL", Command.CANCEL, 1);
Command cmdOK = new Command("OK", Command.OK, 1);
Command cmdHELP = new Command("HELP", Command.HELP, 2);
Command cmdSTOP = new Command("STOP", Command.STOP, 1);
Command cmdEXIT = new Command("EXIT", Command.EXIT, 1);
Command cmdITEM = new Command("ITEM", Command.ITEM, 1);
Command cmdHELP2=new Command("HELP2", Command.HELP, 1);

public Midlet3() {

dis = Display.getDisplay(this);
dis.setCurrent(frm);
//按钮屏幕排序规律
//SCREEN(1),BACK(2),CANCEL(3),OK(4),HELP(5),STOP(6),EXIT(7),ITEM(8)
//规律1:数字越大,排序越靠上方
//规律2:BACK(2),CANCEL(3),EXIT(7),STOP(6)倾向于按优先顺序抢占左方位置
//规律3:按钮类型相同时,看new Command()的第三个参数,数字越小越往前排
//规律3:由于版本的关系,以上优先顺序仅供参考
frm.addCommand(cmdSCREEN);
frm.addCommand(cmdBACK);
frm.addCommand(cmdCANCEL);
frm.addCommand(cmdHELP);
frm.addCommand(cmdSTOP);
frm.addCommand(cmdEXIT);
frm.addCommand(cmdITEM);
frm.addCommand(cmdHELP2);
}

public void startApp() {
}

public void pauseApp() {
}

public void destroyApp(boolean unconditional) {
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐