Incorrect username password 3 times java login form -
this code have. reads text file , compares users input. how add if username , password entered 3 times something. have tried putting counter in many places doesn't work. counter go?
boolean login = false; while(read.nextline() !=null){ string user = read.next(); string pass = read.next(); read.next(); if(usernamet.gettext().equals(user) && passwordt.gettext().equals(pass)){ login = true; break; } } if(login) new menu(); else { joptionpane.showmessagedialog(null, "incorrect username or password"); usernamet.settext(""); passwordt.settext(""); }
int counter = 3; boolean login = false; while(counter > 0 && read.nextline() !=null){ string user = read.next(); string pass = read.next(); read.next(); if(usernamet.gettext().equals(user) && passwordt.gettext().equals(pass)){ login = true; break; } --counter; }
Comments
Post a Comment