【发布时间】:2011-03-17 19:51:53
【问题描述】:
在 J2me 应用程序中,我使用了带有 yes, no 命令的警报。如果用户单击是命令将显示窗体屏幕,如果单击否命令将显示文本框屏幕。但是代码不起作用。对于两个命令,只会显示文本框屏幕。
这是我的代码:
public Login(){
yes=new Command("Yes",Command.OK,1);
no=new Command("No",Command.CANCEL,1);
alert=new Alert("","Save The Changes?",null,AlertType.CONFIRMATION);
alert.setTimeout(Alert.FOREVER);
alert.addCommand(yes);
alert.addCommand(no);
textbox.setCommandListener(this);
alert.setCommanListener(this);
}
public void commandAction(Command command, Displayable displayable) {
if(displayable==textbox)
{
if(command==exit)
{
switchDisplayable(null,alert);
}
}
else if(displayable==alert)
{
if(command==no)
{
switchDisplayable(alert,getForm());
}
else if(command==yes)
{
switchDisplayable(alert,getTextbox());
}
}
}
我的错在哪里?
【问题讨论】:
-
是其他类,继承自该类。我简化了我的代码并忘记了那行。我编辑它