954,554 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Help with a radio button program

Hi, I am new to Java and just learning GUI's. I was wondering if someone could help me with a project? I am trying to create a questionnaire. It will was the user a question and have radio button answers. After the answer is selected, they will hit the "next" button and depending on the answer selected will direct them to a related follow up question with it's own answers. For example: Prompted a question - user selects answer A and hits "next" - because he selected A it would go to class2 with another question - answer. If the customer selected answer B instead - it would of gone to class3...and so fourth. I am familar with making radio buttons, I'm just not sure how to make it determine what class to go to based on the answer selected and hitting the "next" button.

Any help would greatly help me learn!

Thank you in advance!

hessian26
Newbie Poster
2 posts since Sep 2011
Reputation Points: 10
Solved Threads: 0
 

Hi, I am new to Java and just learning GUI's. I was wondering if someone could help me with a project? I am trying to create a questionnaire. It will was the user a question and have radio button answers. After the answer is selected, they will hit the "next" button and depending on the answer selected will direct them to a related follow up question with it's own answers. For example: Prompted a question - user selects answer A and hits "next" - because he selected A it would go to class2 with another question - answer. If the customer selected answer B instead - it would of gone to class3...and so fourth. I am familar with making radio buttons, I'm just not sure how to make it determine what class to go to based on the answer selected and hitting the "next" button.

Any help would greatly help me learn!

Thank you in advance!

Did you attempt writing any code at all?

Syrne
Junior Poster
100 posts since Sep 2010
Reputation Points: 30
Solved Threads: 0
 

Add an ActionListener to the "next" button. In the listener you test each radio button to see if it's checked and, if it is, take the appropriate action (eg create a new instance of the appropriate class)
Now write some code...

JamesCherrill
Posting Genius
Moderator
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
 
Did you attempt writing any code at all?

I have only wrote simple radio button code to change a picture. I have began to write this out yet because I wasnt sure how to make it work the way I wanted it to.

hessian26
Newbie Poster
2 posts since Sep 2011
Reputation Points: 10
Solved Threads: 0
 
mKorbel
Veteran Poster
1,141 posts since Feb 2011
Reputation Points: 480
Solved Threads: 224
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: