passing data types after an action event

I have created a java questionnaire that stores integer values once a selection of radio buttons have been clicked.

I am then thinking to retrieve the integer values from the buttons clicked using the button groups through the action event.

An example of the code is as follows:

public void actionPerformedQuestion2(ActionEvent event2)

{

//This line will get the selected button in group2 and from that button get the 'value' assigned to that particular radiobutton

int valueForGroup2=((katbutton) group2.getSelection()).getValue();

}

The value stored in the button group is passed and stored in the variable "valueForGroup2".

I need to use this value in another method but i am unsure as to how this can be done as the void method in the ActionEvent doesnt return values.

Does anybody know how this can be done?

their are also other values to be passed over at the same time as the above button group. I want to be able to pass them all at once, when a submit button is pressed.

can anybody help please?

Kat

[1098 byte] By [kateulemba] at [2007-10-3 2:45:44]
# 1
Move the declaration of int valueForGroup2 out of the actionPerformed method to make it an instance variable.
PhHeina at 2007-7-14 20:34:24 > top of Java-index,Java Essentials,Java Programming...
# 2

Usually what I do is to have a single method which checks and combines all the variable fields, radio buttons etc. on the form and I call it whenever any control that might effect whether the form state is valid or not gets changed. The submit button is then enabled or disabled accordingly. The same method is then called to load the form values when the form is submitted.

When you program is waiting for user input anyway there's no point in worrying about extra code being executed.

malcolmmca at 2007-7-14 20:34:24 > top of Java-index,Java Essentials,Java Programming...
# 3
Take present that when you use ActionListener inside a class, you are in reality use a nested class in a special syntax that is not the mean sintax of java. So i like to use another class... You have to call an external method and create, here, an instance variable.Bye
UBERTI84a at 2007-7-14 20:34:24 > top of Java-index,Java Essentials,Java Programming...
# 4

> Take present that when you use ActionListener inside

> a class, you are in reality use a nested class in a

> special syntax that is not the mean sintax of java.

> So i like to use another class... You have to call an

> external method and create, here, an instance

> variable.

>

Gesundheit!

PhHeina at 2007-7-14 20:34:24 > top of Java-index,Java Essentials,Java Programming...
# 5
?
UBERTI84a at 2007-7-14 20:34:24 > top of Java-index,Java Essentials,Java Programming...
# 6
Exactly!
PhHeina at 2007-7-14 20:34:24 > top of Java-index,Java Essentials,Java Programming...