here are my codes
Code:
int counter = 0;
int i = 0;
// for (int i = 0; i <= 3; i++) {
while (i < 3) {
String au = ausernametxt.getText();
String ap = apasswordtxt.getText();
String pass = "111";
String user = "zsa";
if (user.equals(ausernametxt.getText()) && (pass.equals(apasswordtxt.getText()))) {
JOptionPane.showMessageDialog(null, "Successfully log in!");
new menu().setVisible(true);
}
if (user != (ausernametxt.getText()) && (pass.equals(apasswordtxt.getText()))) {
JOptionPane.showMessageDialog(null, "Invalid User No", "LOG IN", JOptionPane.ERROR_MESSAGE);
counter += 1;
System.out.println(counter);
}
if (user.equals(ausernametxt.getText()) && (pass != (apasswordtxt.getText()))) {
JOptionPane.showMessageDialog(null, "Invalid Password", "LOG IN", JOptionPane.ERROR_MESSAGE);
counter++;
System.out.println(counter);
} else {
JOptionPane.showMessageDialog(null, "You Inputed 3 wrong password/Username", "LOG IN", JOptionPane.ERROR_MESSAGE);
System.exit(0);
}
}
Comment