Error Alert won't display
Can somebody tell me why the below code will not display an error when i enter the wrong username of password. Thanks
public class LoginMIDlet extends MIDlet implements 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,开发者_JAVA技巧 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);
}
}
In the "else":
switchDisplayable(null, getSignIn());
Maybe this line doesn't allow the process reach the "Alert" line.
Good luck!
精彩评论