Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with JRadioButton

 
Mihir Sen
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mihir,
Gregg's logic is correct. However, humans are easily fooled. The following code will perform what you want.

Enjoy,
Manfred.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic