This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes JRadioButton Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JRadioButton" Watch "JRadioButton" New topic
Author

JRadioButton

Shanthala Rao
Greenhorn

Joined: Nov 13, 2000
Posts: 8
I have 2 JRadioButtons which I add to a JRadioGroup.
Initially both radiobuttons are not selected.
I have a JButton also.When the user selects a radioButton & presses the JButton I want both the radiobuttons to be not selected.I tried to do this by using
JRadioButton.setSelected(false).But this is
not working. Please help..
Thanx,
Shanthala
Wirianto Djunaidi
Ranch Hand

Joined: Mar 20, 2001
Posts: 210

The problem lays with the ButtonGroup. Once you add your
JRadioButton(s) into the ButtonGroup, the ButtonGroup will
MAKE SURE that once it selected that there will always one
that is selected.
So to clear your JRadioButton you need to do:

  • remove all your JRadioButton from the group
  • do setSelected(false)
  • add them all back into the group

  • I would love to hear if there is another way to do it.
    -Ryo
 
Don't get me started about those stupid light bulbs.
 
subject: JRadioButton
 
Similar Threads
inconsistency in radiobutton
Use of RandomAccessFile class under Swing
jbutton refresh
radiobutton problem and classCastException problem
How can i insert JRadioButton to Cell in JTable