This is a newbish question but I'd like to be able to loop through the textboxes, etc on my page and either disable/enable them based on a condition and/or change the background color.
What "collection" of controls do I loop through or where do I look for more information? I've done this in other languages but in Java I'm drawing a blank.
Thanks,
George
Michael Dunn
Rancher
Joined: Jun 09, 2003
Posts: 4041
posted
0
each container/parent has a getComponents() which you can iterate looking for instanceOf's,
or you can add the current textfields to an array, and iterate that array
George Hutto
Greenhorn
Joined: Mar 12, 2003
Posts: 8
posted
0
Michael Dunn wrote:each container/parent has a getComponents() which you can iterate looking for instanceOf's,
or you can add the current textfields to an array, and iterate that array
Michael, thanks for the quick response.
I'm looping through the components and testing instanceof JTextField, etc. Oddly, the components don't seem to have any sort of name I can retrieve. yes, I need to treat some text fields one way and some other text fields another way. Any quick sugggestion on this? Am I stuck using a setName() on each textfield so I have a name to pull?
Michael Dunn
Rancher
Joined: Jun 09, 2003
Posts: 4041
posted
0
alternatively, you can create your own "collection" of controls
see if this thread from the last couple of days makes sense,
then you can access the textfields via their array index number.
I would agree with Michael's suggestion: just keep track of the components you want to work with. Put them in an array or a List or something like that. Much easier than just throwing them into the GUI and then trying to rummage through the GUI and find where they went.