File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes values changed, math didnt. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "values changed, math didnt." Watch "values changed, math didnt." New topic

values changed, math didnt.

ken zemaitis
Ranch Hand

Joined: Sep 26, 2005
Posts: 42
Hi everyone, I've made a calculator that calculates the amount of calories burned during a workout, and body mass index. Most of the calculations work well, however, when the user changes their body weight, the calories burned calculation doesn't change. The JButtons I am using work fine the first time, however if you go back and change the weight value you input after the first calculation, the calculation doesn't change. Any help would be greatly appreciated as this is due very soon. Thank you very much.

[ UD: edited to break long lines into two for better formatting ]
[ April 25, 2007: Message edited by: Ulf Dittmer ]
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
The variable 'amount' (where you indicate the problem is) only depends on the type of exercise and the length, not body weight and height, so it's not surprising that it doesn't change. The value of the weight shown in the line above that should change if the button is clicked, though.

As an aside, what are the ActionListeners supposed to do that are attached to the TextFields? It seems that all actions are handled by the buttons (which is a more intuitive way to do it, too).

Since, there is nothing applet-specific in this question, I'm moving it the AWT/Swing forum.
ken zemaitis
Ranch Hand

Joined: Sep 26, 2005
Posts: 42
Figured it out, nevermind!
I agree. Here's the link:
subject: values changed, math didnt.
It's not a secret anymore!