This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JCheckBox Single Selection Issue

 
Ben Jass
Ranch Hand
Posts: 76
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 47274
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 47274
52
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds as if JRadioButtons might be a better bet.
 
Ben Jass
Ranch Hand
Posts: 76
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SOLVED, used JRadioButtons instead and combined it with the ButtonGroup.
 
Darryl Burke
Bartender
Posts: 5115
11
Java Netbeans IDE Opera
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just for the record, JRadioButton and JCheckBox have identical functionality. Only the appearance, which is determined by the UI delegate, differs.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic