swing - How Do I display info from my database to a jtable in java? -


java code:

private void adduseractionperformed(java.awt.event.actionevent evt) {                                             try{         class.forname("com.mysql.jdbc.driver");         conn = drivermanager.getconnection("jdbc:mysql://localhost/mypos","root","");         statement stmt = (statement)conn.createstatement();          string fname = fld_fname.gettext();         string lname = fld_lname.gettext();         string role = cmb_role.getselecteditem().tostring();         string uname = fld_username.gettext();         string pass = fld_password.gettext();          string add = "insert admin (firstname, lastname, role, username, password) values('"+fname+"', '"+lname+"', '"+role+"', '"+uname+"', '"+pass+"');";         stmt.executeupdate(add);         conn.close();         joptionpane.showmessagedialog(this,"personnel added","add personnel",joptionpane.ok_option);      }catch(exception e){         joptionpane.showmessagedialog(null, e.getmessage(), "error",joptionpane.error_message);         system.out.println(e.getmessage());     } 

i have java code pos system, im wondering why there in joptionpane.showmessagedialog(this,...,...)

also, how display on table corresponding columns?

as described javadocs

parameters:
parentcomponent - determines frame in dialog displayed; if null, or if parentcomponent has no frame, default frame used

this allows joptionpane find parent frame of component showing dialog, helps with, among other things, allow dialog positioned relative component. in cases, don't have component reference, in case, it's fine use null


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -