java - Adding selected check box to arraylist -
i'm pretty new/bad @ java , new gui. how add selected checkboxs arraylist? i've tried looking around can't find helps. appreicated. keep in mind i'm new java code more pretty bad.
http://tinypic.com/r/11b6pno/8 not sure if might give idea because might have worded wrong, when click procedure want, outputs procedure onto screen , want put arraylist
public class testprocedures extends jpanel { private static jlabel procedurelabel; private static jbutton orderbutton, resetbutton, quitbutton; private static jtextarea orderdetails; private static jcheckbox[] procedure; private static int num_procedures= 5; static jtextfield patientidfield; public testprocedures() { super(); patientidfield = new jtextfield("enter patient id number", 25); add(patientidfield); setpreferredsize(new dimension(350,300)); setlayout(new gridlayout(1,1)); add(pane, new dimension(1,1)); setvisible(true); jframe frame = new jframe("procedures"); frame.setcontentpane(split); frame.pack(); frame.setvisible(true);*/ } public void selectprocedures() { procedurelabel = new jlabel("select procedures"); procedure= new jcheckbox[num_procedures]; procedure[0] = new jcheckbox("extraction",false); procedure[1] = new jcheckbox("filling",false); procedure[2] = new jcheckbox("cleaning",false); procedure[3] = new jcheckbox("crown",false); procedure[4] = new jcheckbox("x-ray",false); orderbutton = new jbutton("set procedures"); orderbutton.addactionlistener(new actionlistener() { public void actionperformed(actionevent event){ processorder(); } }); resetbutton = new jbutton("reset patient procedures form"); resetbutton.addactionlistener(new actionlistener() { public void actionperformed(actionevent event){ resetform(); } }); quitbutton = new jbutton("quit program"); quitbutton.addactionlistener(new actionlistener() { public void actionperformed(actionevent event){ system.exit(0); } }); orderdetails = new jtextarea("awaiting procedures....",5,40); add(procedurelabel); (int index=0; index < num_procedures;++index) add(procedure[index]); add(orderbutton); add(resetbutton); add(quitbutton); add(orderdetails); } static void processorder() { string order = "procedures selected:"; boolean proceduresselected= false; string patientid = patientidfield.gettext(); int patientnumb = integer.parseint(patientid); arraylist<patient> patientlist = dentisttabbed.getpatientlist(); arraylist <procedure> proclist = new arraylist<procedure>(); (int index=0; index < num_procedures;++index) if (procedure[index].isselected()) { //here for(patient pat: patientlist) { if(pat.getpatientnumber()==patientnumb) { //pat.addprocedure(procedure); //proclist.add(procedure); } } //here proceduresselected = true; order += "\n"+ procedure[index].getlabel(); } if (!proceduresselected) order += "no procedure selected."; order += "."; orderdetails.settext(order); } }
a general solution:
checkbox.setselected(true); list.add(checkbox);
Comments
Post a Comment