This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes deselecting radio button Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "deselecting radio button" Watch "deselecting radio button" New topic

deselecting radio button

Ikram Soomro
Ranch Hand

Joined: Oct 20, 2001
Posts: 42
If we select a radio button than can we deselect it? just like in check box if we select a checkbox than we can deselect it by again click it.
My question is that how can i deselect radio button? When I click on selected radio button than its selection should clear.
Darin Niard
Ranch Hand

Joined: Jun 08, 2004
Posts: 118
That isn't really how they work... If you need to deselect a radio button, then you probably shouldn't be using radio buttons, but checkboxes instead.

If you really want to do this, just attach a listener to the buttons and .setSelected(false) on the source.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
Ikram Soomro
Ranch Hand

Joined: Oct 20, 2001
Posts: 42
Thank You Michael Dunn!
Perfect solution!
subject: deselecting radio button
Similar Threads
radio button & button
setState() with JRadioButton
Allow users to desect from SELECT?
Deactivating an Option Button
How can I deselect JRadioButtons