ItemListener « JCheckBox « Java Swing Q&A





1. JCheckBox itemListener    coderanch.com

jcb = new JCheckBox((String) i.next()); jcb.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent ie) { JCheckBox source = (JCheckBox) ie.getItemSelectable(); user = source.getText(); System.out.println("listener " + user); } }); I hope I can explain this properly, but the inner class instance of ItemListener that you have attached to jcb does not execute its itemStateChanged method until you change the value of a check ...