Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How can I deselect JRadioButtons  RSS feed

 
Ashwin Kumar
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

Can Any suggest how to deselect radio buttons, I am calling button.setSelected(false); this doesn't work ?? Why ??
 
Stuart Gray
Ranch Hand
Posts: 410
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using a ButtonGroup? It is a known feature of these that once a button has been selected, one and only one button must remain selected at all times (you can't have zero selected). Try selecting a different button in the group.
 
William A White
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can get around this by making a hidden dummy button and making it the active button when you want the button group to appear "unselected".
 
Ashwin Kumar
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Thanks William !! .. I really appreciate the idea.. it worked ..great thanks..
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!