Assigning a variable through a radio button selection
I think I'm making this harder then it should be. I'm trying to create a shopping project, for my java programming course, that uses a JFrame GUI to input, calculate and display inputs.
The meat and potatoes of the project that I'm having difficulty with deals with the assigning of variables following option inputs of radio buttons, a check box calculated against a quantity from a text field.
I have the components set up graphically as such:
O Blue O Red O Yellow □ Engrave
Now I need to display the following depending on which radio button is selected, if the engrave check box is selected, and a monetary subtotal like the following:
Object Color Quantity Engraved Total
Blue 1 Yes $15.00
Red 2 No $22.00
Yellow 1 No $11.00
Sorry if I had to describe this so poorly, I don't have any experience programming. I just need help figuring out how to assign an int or double like "blueQuantityDouble" after selecting a color, and inputting a quantity, and then hitting a calculate button. Thanks in advance for any help you can throw my way. If you need me to clarify, I can do so.
Re: Assigning a variable through a radio button selection
An ActionListener would allow you to monitor when a radio button is selected and act accordingly. See the following:
How to Write an Action Listener (The Java™ Tutorials > Creating a GUI With JFC/Swing > Writing Event Listeners)