File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "deselecting radio button" Watch "deselecting radio button" New topic
Author

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!
 
Don't get me started about those stupid light bulbs.
 
subject: deselecting radio button
 
Similar Threads
Deactivating an Option Button
How can I deselect JRadioButtons
radio button & button
setState() with JRadioButton
Allow users to desect from SELECT?