Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2006

Tip: Looking for answers? Try searching our database.

literal string expansion

Thread view: 
Jerre Snow - 18 Dec 2006 19:24 GMT
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?
kn - 19 Dec 2006 09:32 GMT
>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];


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.