Results 1 to 7 of 7
- 06-27-2009, 06:35 PM #1Member
- Join Date
- Jun 2009
- Rep Power
RadioButton selections in an Exam application
i am trying to create an application for taking online examinations, the Multiple Choice kind of.
i have designed the GUI, a textarea to display the question and then 4 radio buttons for selecting one answer. i have NEXT and PREVIOUS buttons to scroll through all the questions..My problem is on clicking next, the radiobuttons are not getting deselected, in spite of my code of calling
on each of the radio buttons.. is there any other way?? moreover how can i make this easy to always clear off the selected buttons for the next question..?? i mean some group kinda thing for all those buttons...
Are you using a ButtonGroup object here and are all the JRadioButtons added to this object?
If not, please have a look here: How to Use Radio Buttons
If you are using Java 1.6, you can clear the group via a call to the clearSelection() method.
- 06-28-2009, 01:58 AM #3
- 06-29-2009, 04:17 AM #5
I think that another way to clear the selection if using Java 1.5 or prior is to create a dummy JRadioButton that is added to the ButtonGroup but not to a visible component and thus it is never seen. When wanting to clear the selection, just call setVisible(true) on the dummy button. I believe that this is kosher (anyone, please correct me if this is wrong).
- 06-29-2009, 04:41 AM #7
You are correct Fubarable, 100% correct. I comes with this scenario several times, after updating my JDK versions time-to-time with the newer version. Actually this type of things happen several instance in different implementations. I don't know why Suns' people not caring about this.
- By itaipee in forum AWT / SwingReplies: 5Last Post: 05-25-2009, 09:29 AM
- By tiger100plus in forum New To JavaReplies: 1Last Post: 01-05-2009, 09:04 PM
- By Nari in forum New To JavaReplies: 4Last Post: 04-21-2008, 08:47 PM
- By newtojava7 in forum New To JavaReplies: 1Last Post: 03-17-2008, 03:58 AM