Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-27-2009, 07:35 PM
Member
 
Join Date: Jun 2009
Posts: 1
Rep Power: 0
riddhikarnik is on a distinguished road
Question RadioButton selections in an Exam application
Hi,
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

setSelected(false)

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...
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 06-27-2009, 08:12 PM
Fubarable's Avatar
Moderator
 
Join Date: Jun 2008
Posts: 6,504
Rep Power: 8
Fubarable is on a distinguished road
Default
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.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 06-28-2009, 02:58 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,523
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
Originally Posted by Fubarable View Post
If you are using Java 1.6, you can clear the group via a call to the clearSelection() method.
Working with the ButtonGroup is the most suitable way in UI designing.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 06-28-2009, 03:13 AM
Fubarable's Avatar
Moderator
 
Join Date: Jun 2008
Posts: 6,504
Rep Power: 8
Fubarable is on a distinguished road
Default
Originally Posted by Eranga View Post
Working with the ButtonGroup is the most suitable way in UI designing.
yes, clearSelection is called on the ButtonGroup object, but it won't work if you compile with 1.5 or previous.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 06-29-2009, 05:17 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,523
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
ya, clearSelection introduce in JDK 1.6, and the ButtonGroup introduced in 1.3
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 06-29-2009, 05:33 AM
Fubarable's Avatar
Moderator
 
Join Date: Jun 2008
Posts: 6,504
Rep Power: 8
Fubarable is on a distinguished road
Default
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).
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 06-29-2009, 05:41 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,523
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
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.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
freeze radioButton without disable them itaipee AWT / Swing 5 05-25-2009 10:29 AM
RadioButton tiger100plus New To Java 1 01-05-2009 09:04 PM
please help with exam problems Nari New To Java 4 04-21-2008 09:47 PM
radiobutton selection newtojava7 New To Java 1 03-17-2008 03:58 AM


All times are GMT +2. The time now is 08:52 AM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org