This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Applets and the fly likes For loops... Creating objects... No handles... Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Applets
Reply Bookmark "For loops... Creating objects... No handles..." Watch "For loops... Creating objects... No handles..." New topic
Author

For loops... Creating objects... No handles...

Robbie Harjes
Greenhorn

Joined: Nov 09, 2003
Posts: 22
Hey friends?! How ya'll doin' today? I'm great. So I got me my applet here and it creates a bunch of Checkbox objects using a FOR loop and such; each Checkbox is created by the following code:

Whereas a is an Object of type Words:

But I create these, and then I can't do a cb1.getState() or anything... (Which I need to do.) I've tried some tricky clauses in my event handler, but nothing works. Is there anyway to create a bunch of Objects (the exact number is varying), using a loop, or a new class definition, so that each one has a handle? OR..Getting creative: Is there any "master command" that contains The_first_checkbox_this_program_created, The_second, etc... I need handles to my objects.. please help..
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24057
    
  13

Hi Robbie,
Yes, indeed: use an array of Checkboxes. I'm not sure why you have to ask this as you've already got arrays of words here... Anyway, you can initialize the array using "new" like
Checkbox[] checks = new Checkbox[a.len()];
and then use checks[0] for the first Checkbox, checks[1] to hold the second, etc. In your create loop you should assign each Checkbox to one array element, of course.


[Jess in Action][AskingGoodQuestions]
Robbie Harjes
Greenhorn

Joined: Nov 09, 2003
Posts: 22
Thanks for the help.
I just realized the same thing not too long after that posting, but everything works great now!
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: For loops... Creating objects... No handles...
 
Similar Threads
bitwise logic .. stuff
control flow, factoring out repeating elements
Validate at least one checkbox in a Modal Window.
Extending objects within type-safe List Objects
Vector of string arrays contains same values