How to code a very simple login system with java -


i need create system checks file username , password , if correct, says whether or not in label. far have been able make 1 username , password equal variable, need link file somehow. noob programmer lots of appreciated. here have under authenticate button.

string pass; string user; user = txtuser.gettext(); pass = txtpass.gettext();  if(pass.equals("blue") && user.equals("bob") ){     lbldisplay.settext("credentials accepted."); } else{     lbldisplay.settext("please try again."); }      

you need use java.util.scanner issue.

here login program console:

import java.util.scanner; // use scanner because it's command line.  public class login { public void run() {     scanner scan = new scanner (new file("the\\dir\\myfile.extension"));     scanner keyboard = new scanner (system.in);     string user = scan.nextline();     string pass = scan.nextline(); // looks @ selected file in scan      string inpuser = keyboard.nextline();     string inppass = keyboard.nextline(); // gets input user      if (inpuser.equals(user) && inppass.equals(pass)) {         system.out.print("your login message");     } else {         system.out.print("your error message");     } } }  

of course, use scanner scanner = new scanner (file toscan); not user input.

happy coding!

as last note, @ least decent programmer if can make swing components.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -