• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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..
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Robbie Harjes
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the help.
I just realized the same thing not too long after that posting, but everything works great now!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic