java - Enable to display jcombobox after filling some jtextfields -
i've form wich contains textfields , jcomboxes. first jcombox contains names of groups ( libelle_groupe in code) , other 1 : status value ( valeur in code). after choosing jcombobox value, try id of both group , status database insert table : compte_utilisateur. jcomboboxes last ones in form. before touching of textfields, can choose comboboxes values. onces, 1 of textfields touched, can't choose anymore values both jcomboboxes. 1 know why? here code fill combo box database:
private void fillcombo(){ preparedstatement pst=null; resultset rs=null; try{ string sql="select * groupe"; pst= (preparedstatement) maconnexion.obtenirconnexion().preparestatement(sql); rs=pst.executequery(); while(rs.next()){ string libelle_groupe=rs.getstring("id_groupe"); combo_name.additem(libelle_groupe); } } catch(exception e){ joptionpane.showmessagedialog(null, e);} }
code insert data db :
private void jbutton3actionperformed(java.awt.event.actionevent evt) { preparedstatement pst=null; try { string requete="insert compte_utilisateur(id_compte, nom, prenom, matricule, id_groupe, id_statut) values (?,?,?,?,?,?)"; pst=maconnexion.obtenirconnexion().preparestatement(requete); pst.setstring(1, jtidf.gettext()); pst.setstring(2, jtnom.gettext()); pst.setstring(3, jtprenom.gettext()); pst.setstring(4, jtmatricule.gettext()); string comb1=combo_name.getselecteditem().tostring(); pst.setstring(5, comb1); string comb2=jcombobox1.getselecteditem().tostring(); pst.setstring(6, comb2); pst.execute(); } catch(exception e){e.printstacktrace(); } }
Comments
Post a Comment