j2me中的Displayable问题

publicclassTranslateCanvasextendsCanvasimplementsCommandListener{privateTextFieldtfMs... public class TranslateCanvas extends Canvas implements CommandListener{
private TextField tfMsg=new TextField("英汉互译","",20,TextField.ANY);
private Form form=new Form("英汉互译");
private Command cmdQuery=new Command("查询",Command.SCREEN,1);
private Command cmdHelp=new Command("帮助",Command.HELP,1);
private Command cmdExit=new Command("退出",Command.EXIT,1);

private TranslateMIDlet tm;
private int type=0;//默认为0,英译汉,为1代表汉译英
public TranslateCanvas(TranslateMIDlet tm) {
this.tm=tm;
form.append(tfMsg);
form.addCommand(cmdQuery);
form.addCommand(cmdHelp);
form.addCommand(cmdExit);
this.setCommandListener(this);
}
protected void paint(Graphics g) {
//由于要从控制器得到页面,但放在构建器控制器还未创建
tm.getDisplay().setCurrent(form);
}
public void commandAction(Command c, Displayable arg1) {
//问题来了,不知道为什么按键没有反映了
if(cmdHelp==c)
{//触发
tm.changeInterface("welcome");
}

}
}
展开
 我来答
zxy_software
2010-04-06 · TA获得超过195个赞
知道答主
回答量:69
采纳率:0%
帮助的人:89.3万
展开全部
this.setCommandListener(this);
改成
cmdQuery.setCommandListener(this);
cmdHelp.setCommandListener(this);
cmdExit.setCommandListener(this);
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式