0
有人可以告訴我爲什麼當我輸入錯誤的密碼用戶名時,下面的代碼不會顯示錯誤。由於錯誤警報不會顯示
公共類LoginMIDlet擴展的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);
}
}
如果我刪除那行代碼,程序會自動移到下一個窗體「繼續」。 – Jaron787 2009-12-31 17:06:47