This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Swing / AWT / SWT and the fly likes Calculations Based on Selected Radio Button Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Calculations Based on Selected Radio Button" Watch "Calculations Based on Selected Radio Button" New topic
Author

Calculations Based on Selected Radio Button

Melinda Deering
Greenhorn

Joined: Apr 19, 2009
Posts: 11
Hello All,

I am working on an assignment which calculates different pay rates based on the selection of a radio button. I'm okay with the default one (FIRST), but am unsure of how to base a different calculation on the other two radio buttons (SECOND and THIRD). I'll include what I have below...if anyone could point me in the right direction I would appreciate it.


Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19674
    
  18

Please Use Code Tags. I've added them for you this time.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Melinda Deering
Greenhorn

Joined: Apr 19, 2009
Posts: 11
I apologize!

-Melinda
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
click the various radioButtons to see the textfiled background change color



if you want to set it up for the radioButtons to determine the pay rate, do it similar to what I've done for colors
double[] payRates = {15.1,25.2,35.3};etc
double payRate = payRates[0];//to match 'FIRST' being selected at startup

then in actionPerformed
payRate = payRates[index];
Melinda Deering
Greenhorn

Joined: Apr 19, 2009
Posts: 11
Wow! You made me think of that in a completely different way. Thanks very much!

Melinda
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Calculations Based on Selected Radio Button