There's a number of things you'll need to get right. I'll just list a few you will need to look into (not necessarily in this order):
You can retrieve the values from a JTextField or a JTextArea using the getText method. getText returns a String; you can use Double.parseDouble to convert that to a number. (Since you're building a calculator, I think it would be more natural to use JTextField, not JTextArea).
You can set the value of a JTextField using the setText method. A number can be converted to a String by prepending the empty string to it, like ""+3.5 .
You'll need to keep track of where you are in the sequence of keystrokes. E.g. if the user just clicked the plus button, you'll need to store the current value of the display somewhere, remember that the operation to be done once "=" is clicked is addition, and clear the display as soon as the next digit is clicked.
Does this help? Or am I misunderstanding where you're stuck?
Joined: Jun 04, 2007
I haven't tried your advice yet, but it sounds like the best I have received. I'll let you know when I get it right. Thanks.