2009-12-31 71 views
0

有人可以告訴我爲什麼當我輸入錯誤的密碼用戶名時,下面的代碼不會顯示錯誤。由於錯誤警報不會顯示

公共類LoginMIDlet擴展的MID​​let實現的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); 
} 

}

回答

0

在 「其他」:

switchDisplayable(null, getSignIn()); 

也許此行不允許過程達到「警報「行。

祝你好運!

+0

如果我刪除那行代碼,程序會自動移到下一個窗體「繼續」。 – Jaron787 2009-12-31 17:06:47