aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes How to get actionPerformed to return a value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to get actionPerformed to return a value" Watch "How to get actionPerformed to return a value" New topic
Author

How to get actionPerformed to return a value

Anudeep Pat
Greenhorn

Joined: Apr 09, 2010
Posts: 10
Ranchers, need some help.

I am creating a Multiple choice Questionnaire using Java Swings connected to MySql.

And am trying to get actionPerformed return the value selected from a Radio Buttongroup because I am trying to validate if the chosen value of the radio button is right.

I put the answer field from the database into a label(if that helps). I dont even know if this is the right way to do it.

Suggestions please!!!
Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 650
Have you seen the tutorial on Radio Buttons? http://java.sun.com/docs/books/tutorial/uiswing/components/button.html#radiobutton.

The actionPerformed method is a void type, so it cannot return values. However, you can set program variables from within the actionPerformed method, so this should do what you want.

Anudeep Pat
Greenhorn

Joined: Apr 09, 2010
Posts: 10
I know that actionPerformed wouldnt return any value but I was wondering if there's a way around that.

Anyways, my concern here is that I want to compare the value selected from radio buttons against the one in the database!
Anudeep Pat
Greenhorn

Joined: Apr 09, 2010
Posts: 10
Just got it, by declaring a String variable in the class and putting the answer into it and then sending it to the actionPerformed function where it can be compared to the selected value!!!

Here's the link that'll give you a rough idea!!!

http://forums.sun.com/thread.jspa?threadID=372477
 
jQuery in Action, 2nd edition
 
subject: How to get actionPerformed to return a value