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?
>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.
Jerre Snow - 20 Dec 2006 15:16 GMT
>>I have 150 checkboxes named jCB001...jCB150.
>> How would I loop through them in a for/next loop performing actions on
[quoted text clipped - 6 lines]
>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];