Olá pessoa!
Não consigo fazer com que o Java releia minhas novas tentativas, quando ele pega o texto, mostra a mensagem de erro até que o while (t<c) seja verdadeiro, ou seja, mostra 3 vezes. Alguém pode me ajudar?
if(txtUsu.getText().isEmpty() || new String (txtSenha.getPassword()).isEmpty()) {
JOptionPane.showMessageDialog(this, "Preencha todos os campos", "ERRO", JOptionPane.ERROR_MESSAGE);
}
else{
String usu = txtUsu.getText();
String senha = new String(txtSenha.getPassword());
int t = 0;
int c = 3;
do{
String newusu = txtUsu.getText();
String newsenha = new String(txtSenha.getPassword());
if(usu.equals("adm") && senha.equals("123")){
JOptionPane.showMessageDialog(this, "Bem-vindo!", "WELCOME", JOptionPane.INFORMATION_MESSAGE);
Principal n = new Principal();
dispose();
n.setVisible(true);
break;
}
else{
JOptionPane.showMessageDialog(this, "Usuário ou senha inválidos!", "ERRO", JOptionPane.ERROR_MESSAGE);
limpar();
t++;
}
}
while(t < c);
if(t > c){
JOptionPane.showMessageDialog(this, "Você ultrapassou as "+t+"tentativas restantes.","ERRO", JOptionPane.ERROR_MESSAGE);
}
}