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

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

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

android - How to create dynamically Fragment pager adapter -