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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -