GUI and switch problem

D

DERosenblum

In class1 I have a switch statement that switches on int choice and
defaults to choice = 1 when the program is run. In class2, I have
setup a GUI which includes 2 radio buttons. When someone clicks the
2nd radio button I want the variable that gets switched in class1 to
become 2 and restart the application with that value.

I'm having trouble getting Class1 to read-in the value when the radio
button is pushed and then restart. I'm new to programming so more
details would be useful.

Thanks!
 
R

Roedy Green

When someone clicks the
2nd radio button I want the variable that gets switched in class1 to
become 2 and restart the application with that value.

You want a to write a method of class1 that accepts a boolean.

public setZeugmaState( boolean on )
{
// code to poke the class1 gui the way you want.
// code to invoke the computations based on the change.
}

In your class2 event handler, call setZeugmaState( ... )

Zeugma here stands for the name of the property you seem reluctant to
divulge.

I can't fill in variable names because you did not divulge them.
 
S

Suffocate

In class1 I have a switch statement that switches on int choice and
defaults to choice = 1 when the program is run. In class2, I have
setup a GUI which includes 2 radio buttons. When someone clicks the
2nd radio button I want the variable that gets switched in class1 to
become 2 and restart the application with that value.

Depending on exactly how your app is structured, you could create a
Listener for class2, have class1 listen for specific events and pass
back the value that 'choice' should be set to.

/J.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top