1. Put options in the reciprocating box (added according to the database)
(1) First, the default Item1234 in attribute->model is emptied
(2) Get the data in the database and put it in.
Selectcourseview scv=NewSelectcourseview (); intSelectindex=-1; Syscoursedao SCD=NewSyscoursedaoimpl (); List<CourseView> courselist =Scd.queryallcourse ();
Get a table that holds the view, and then put in
Add excuses to your DAO package to get all the course names PublicTeascoreframe () {initcomponents (); INITDEP (); This method must be placed after initcomponents (), initialize the component first, and then put the content. } Public voidInitdep () { for(Courseview cs:courselist) { This. Comcourseid.additem (Cs.getid ()); Iterate through the entire table and put it in one place}}
2. Get the current contents of the check box
Private voidBtnsearchactionperformed (java.awt.event.ActionEvent evt) {
First, empty the contents of the table and put the DefaultTableModel DTM= (DefaultTableModel) This. Tblteasearchselect.getmodel (); while(Dtm.getrowcount () >0) {Dtm.removerow (0); } //1. Get DefaultTableModel//2. Remove content from current table//3. Display data in table by vector object intSs= Integer.parseint (( This. Comcourseid.getselecteditem ()). ToString ());
//Comcourseid.getselecteditem () obtains an int, but cannot be directly equal, converted to a string and converted to int
Teacherdao TS New
List<SelectCourseView> scvlist=
For
New
3. Select the item that you want to display according to the check box in the table
This is a relatively simple
1 for(inti=0;i< This. Cbdep.getmodel (). GetSize (); i++) {2 //traverse each item in the drop-down box to find the item that matches the selected item3Department dept= (Department) This. Cbdep.getitemat (i);4 if(Depa.equals (Dept.getdepname ()))5 {6 This. Cbdep.setselectedindex (i);7 }8}
About JComboBox in NetBeans (check box)