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 JRadioButton : Deselecting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JRadioButton : Deselecting" Watch "JRadioButton : Deselecting" New topic
Author

JRadioButton : Deselecting

Vikram Deshmukh
Greenhorn

Joined: Apr 22, 2000
Posts: 29
Hi Group,
I have a button group. Within that, I am having 2 JRadioButtons. One of them is selected. On click of some JButton, i want to de-select that radio button.
On handler of JButton i wrote, but it doesnt work.
Does anyone has any remedy over this ?
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

At least one button in a ButtonGroup must be selected. If you read the API for ButtonGroup it gives you this workaround...


Initially, all buttons in the group are unselected. Once any button is selected, one button is always selected in the group. There is no way to turn a button programmatically to "off", in order to clear the button group. To give the appearance of "none selected", add an invisible radio button to the group and then programmatically select that button to turn off all the displayed radio buttons. For example, a normal button with the label "none" could be wired to select the invisible radio button.


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Chantal Ackermann
Ranch Hand

Joined: Sep 28, 2000
Posts: 508
wouldn't it be possible to add the "some JButton" to the button group?
cheers
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JRadioButton : Deselecting
 
Similar Threads
What is MVC
linking files using java
Controlling Button Focus with Arrow Keys
How to get the specify source of the array of jbutton
java code for round rectangle java swing button