This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes JCheckBox[ ] Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "JCheckBox[ ]" Watch "JCheckBox[ ]" New topic
Author

JCheckBox[ ]

Jesse Walker
Ranch Hand

Joined: Aug 18, 2004
Posts: 50
I am trying to create an array of JCheckboxes called check, I can declare it fine but how do you intialize the checkboxes with different strings??
Thanks,
Jesse
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
As with any array of object types, when you initialize the array you just make a number of empty slots. (Or Cups if you read the recommended campfire stories.)

You haven't made any checkboxes yet. You'll need to create some and put them into the array:

Then you can see whichones are checked

Does that makes sense?


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Jesse Walker
Ranch Hand

Joined: Aug 18, 2004
Posts: 50
Yes, that explains alot, I was also wondering if there is a way to initialize and declare in the same statement?
John Bartlett
Ranch Hand

Joined: Jan 25, 2006
Posts: 116
Hi,

Do you mean doing something like this:



John
[ December 13, 2006: Message edited by: John Bartlett ]
Jesse Walker
Ranch Hand

Joined: Aug 18, 2004
Posts: 50
Yes, that is exactly what I was looking for. One more question, other then the paint and repaint methods is there a way to refresh a frame using an Action Event to add components?
Thank you,
Jesse
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Jesse Walker:
Yes, that is exactly what I was looking for. One more question, other then the paint and repaint methods is there a way to refresh a frame using an Action Event to add components?
Thank you,
Jesse


It probably would be a good idea to start a new thread in the Swing forum for this question.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: JCheckBox[ ]
 
Similar Threads
Cant use object from another class
WA #1.....word association
Posting to bump up my count...
Text box value is not being completely filled with request attribute
The x900 effect ?