while(correct == false)
{
userCreds tester = new userCreds();
if(Username1.equals(Username) && Password1.equals(Password))
{
correct = true;
thisVar.setVisible(true);
}
else
{
tester.login();
correct = false;
JOptionPane.showMessageDialog(null, "user or password incorrect", "Incorrect Credentials", JOptionPane.ERROR_MESSAGE);
}
The tester.login() method changes the variables Username1 and Password1 so that if they match Username and Password then takes me to the main JFrame of my program.
The only issue I am facing is that I seem to be stuck in an infinite loop of the error part. I am aware that it is due to the fact that correct is always set to be false if they don't match.
I am trying to set correct to true after a match and I also want it to remain false while they don't match.