java - How to use if else to set var value in TextField -
can ask how can instantly equal textfield named txtusername 'aime' , txtpassword equal 'joy' show message "user name , password match!" ? anyone? please me :(
public void actionperformed(actionevent e){ if (e.getsource()== btnclear){ txtusername.settext(""); } if(e.getsource() == btnlogin){ if (txtusername.settext="aime" && txtpassword.settext="joy")){ joptionpane.showmessagedialog(null, "user name , password match!"); } else { joptionpane.showmessagedialog(null, "user name , password invalid!"); }
these small modifications needed.
if (txtusername.gettext().equals("aime") && txtpassword.gettext().equals("joy")){ joptionpane.showmessagedialog(null, "user name , password match!"); }else{ joptionpane.showmessagedialog(null, "user name , password invalid!"); }
for reference : what difference between == vs equals() in java?
Comments
Post a Comment