Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JRadioButton

 
Shanthala Rao
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 210
Ruby Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic