aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Problem with JRadioButton Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Problem with JRadioButton " Watch "Problem with JRadioButton " New topic
Author

Problem with JRadioButton

Mihir Sen
Greenhorn

Joined: Jul 16, 2001
Posts: 2
hi friends,
I am developing one ExamSimulator. at a time one question and three options will display on a screen.
I have three JRadioButtons and i have added those three in one ButtonGroup so that at a time only one will get selected.Now while displaying next question i want all the options should be unchecked. how to achieve this?
i am using setSelected(false) method of JRadioButton. but i am not getting the expected result.
expecting your help
-Mihir
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

I believe that the way a JRadio Button works is one always has to be selected. I may be wrong, but in my experience with them, it seems that one radio button has to be the default answer. I would like to be proven wrong though.


GenRocket - Experts at Building Test Data
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Mihir,
Gregg's logic is correct. However, humans are easily fooled. The following code will perform what you want.

Enjoy,
Manfred.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Problem with JRadioButton