aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JCheckBox Single Selection Issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JCheckBox Single Selection Issue" Watch "JCheckBox Single Selection Issue" New topic
Author

JCheckBox Single Selection Issue

Ben Jass
Ranch Hand

Joined: Sep 25, 2010
Posts: 76
Hey guys, I'm having an issue setting the JCheckBox so that only one of the options can be selected. I made it so that only one can get selected, that works. But let's say if someone wanted to change there mind and switch to the other option, it won't allow them to do so.

Instance Variables:


The loop that creates every JCheckBox object and adds them to the array list:


This is the part that I worked on to set the selection to only one of them:


If you want further detail it works like this:
~ If I select "public" (accesMod.get(0)), "private" is already unchecked.
~ I have to uncheck "public" in order to check "private"
~ I can't select two at once
~ I CAN switch from "private" to "public" perfectly without having to uncheck anything?

I'd appreciate the help a lot.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39436
    
  28
Did you really mean to post in the Scala forum? Moving thread. [If it really is Scala-related, move it back]

Never, never, write == true or == false.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39436
    
  28
Sounds as if JRadioButtons might be a better bet.
Ben Jass
Ranch Hand

Joined: Sep 25, 2010
Posts: 76
SOLVED, used JRadioButtons instead and combined it with the ButtonGroup.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4642
    
    5

Just for the record, JRadioButton and JCheckBox have identical functionality. Only the appearance, which is determined by the UI delegate, differs.


luck, db
There are no new questions, but there may be new answers.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JCheckBox Single Selection Issue