views:

16

answers:

1

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, 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);
 }

}

A: 

In the "else":

switchDisplayable(null, getSignIn());

Maybe this line doesn't allow the process reach the "Alert" line.

Good luck!

Drewen
If i remove that line of code the program just moves onto the next form "continue" automatically.
Jaron787