On Tue, 19 Dec 2006 10:32:02 +0100, "kn" <ne******@necuspam.hrwrote:
>>I have 150 checkboxes named jCB001...jCB150.
How would I loop through them in a for/next loop performing actions on
them. If I held their names in an array, how would I make use of that
String in the array to reference the checkbox object? Is there a way
to do this?
That's not a proper way to do it. You should create a combobox array and
then iterate through it. Alternatively, you can put your comboboxes onto a
JPanel and then use
JPanel.getComponents() to get your comboboxes as an array.
It hadn't occurred to me to look for methods in the underlying jpanel.
JPanel.getComponents() solved the problem.
Component[] c = jPanel.getComponents();
JCheckBox jc = (JCheckBox) c[i];