0

I have a GUI in eclipse where I enter username and password and if they are correct when I press a Jbutton, the GUI should close. Else say "Wrong username and password". My code is:

if(name == username.getText() && pass == Password.getText()){
                    //allow access
                    System.exit(0);
                }
                else{
                    //deny
                    btnLogIn.setText("Wrong username or password");
                }

I keep getting the "Wrong username or password" although the username and password are 100% correct. Where am I going wrong?

Variables: private JPasswordField Password; private JTextField username;

private String id = "username";
private String pass = "pass";
E-Riz
  • 31,431
  • 9
  • 97
  • 134
joe
  • 45
  • 7

0 Answers0