错误警报将不会显示

时间:2009-12-31 16:56:45

标签: java-me login alert

当我输入错误的密码用户名时,有人可以告诉我为什么以下代码不会显示错误。感谢

public class LoginMIDlet extends MIDlet实现了CommandListener {

private boolean midletPaused = false;
private Display display;

//<editor-fold defaultstate="collapsed" desc=" Generated Fields ">                      
private Form SignIn;
private TextField userName;
private TextField password;
private StringItem sim_Result;
private Form Continue;
private Command _login;
private Command _cancel;
private Command okCommand;
//</editor-fold>                    

/**
 * The LoginMIDlet constructor.
 */
public LoginMIDlet() {
}


 public void validateUser(String user, String Password) {
 if (user.equals("N0203251") && Password.equals("DBTYPX")) {
     switchDisplayable(null, getContinue());
 }

 else {
     switchDisplayable(null, getSignIn());
 Alert error = new Alert("Login Incorrect", "Please try again", null, AlertType.ERROR);
 error.setTimeout(Alert.FOREVER);
 userName.setString("");
 password.setString("");
 display.setCurrent(error);
 }

}

1 个答案:

答案 0 :(得分:0)

在“其他”中:

switchDisplayable(null, getSignIn());

也许这一行不允许进程到达“警报”行。

祝你好运!