I would like to have 6 checkboxes, and do some stuff after a botton is pressed do you have an example?
Also can an array of checkboxes be used?
I want to avoid:<
Yes, have an array of JCheckBox
, example:
JCheckBox[] checkBoxes = {new JCheckBox("1"), new JCheckBox("2"), new JCheckBox("3"), new JCheckBox("4"), new JCheckBox("5"), new JCheckBox("6")};
or
JCheckBox[] checkBoxes = new JCheckBox[6];
Then you will have to iterate through checkBoxes.length
and instantiate it (if you didn't) and add your listener through addItemListener()
and finally adding each checkbox to your JFrame
.
I hope this helps.