java - How do i make a JPassword Field launch an application -
jpanel p = new jpanel(); jtextfield username = new jtextfield(10); jpasswordfield password = new jpasswordfield(10); p.add(new jlabel("username:")); p.add(username); p.add(new jlabel("password: ")); p.add(password); joptionpane.showconfirmdialog(null, p, "username , password: ", joptionpane.ok_cancel_option);
my question how make username username , password password , if type in correct username , password launches application if not closes it?
in gui,
int selectedoption = joptionpane.showconfirmdialog(null, p, "username , password: ", joptionpane.yes_no_option); if (selectedoption == joptionpane.yes_option) { if (username.gettext().equals("abc") && password.gettext().equals("abc")) { //do action, login success } else { //do action, login fail } }//end if else { //do action, means user cancel login }
Comments
Post a Comment