java - Saving Checklist Selection -


i having trouble figuring out how following. trying enable user check books wants using checklist, cannot figure out how save selections (the checked books) in order determine price has pay. here checklist code:

for(int k=0;k<catalogue.getcatalogue().size();k++)     {         frame.add(new jcheckbox(catalogue.cat.get(k).tostring()));     }       frame.setlayout(new flowlayout());     frame.setsize(900,900);     frame.setvisible(true);     frame.addwindowlistener(new windowadapter(){ public void windowclosing(windowevent e){system.exit(0);}}); 

it shows list of books (catalogue arraylist containing books, read file) checkbox beside it. need in figuring out how "save" selections can store in arraylist of books.

you should use array/arraylist of jchecklists. example:

jcheckbox[] checkboxes = new jcheckbox[catalogue.getcatalogue().size()]; 

and then:

for(int k=0;k<catalogue.getcatalogue().size();k++) {     checkboxes[k] = new jcheckbox(catalogue.cat.get(k).tostring()));     frame.add(checkboxes[k]); } 

now can check state of each checkbox, example, can reference first 1 checkboxes[0]


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -