};
boolean[] checkedItems= {
true, false, true, true,
false, false, true, false,
};
final CheckBoxList list = new CheckBoxList(listItems, checkedItems);
// show list
JScrollPane scroller =
new JScrollPane (list,
ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
JFrame frame = new JFrame (CheckBoxListTest.class.getName());
frame.getContentPane().add (scroller);
frame.pack();
frame.setVisible(true);
frame.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e) {
boolean[] res=list.getCheckedItems();
for(int i=0;i<listItems.length;i++){
System.out.println(listItems[i]+" "+res[i]);
}
System.exit(0);
}