By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,034 Members | 822 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,034 IT Pros & Developers. It's quick & easy.

literal string expansion

P: n/a
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?
Dec 18 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
kn
>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.
Dec 19 '06 #2

P: n/a
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];
Dec 20 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.