This is part of my calculator I'm trying to create. What i want to do is have the text field display the numbers which are being enterested into a the applet, and for them to be either added, multiplied, divided etc. So for example if a user wanted to add 120 to 120 they'd see "120 + 120" as the request, then the answer will be shown as "120 + 120= 240".
How will this be possible from here? All replies will be duely greatful from me, thanks
So what does this code do, then? If it doesn't do what you describe, tell us what it does, and what you're having problems with. Then we can try to help you get going again.
Basically so far it has initiated buttons 0-9 with values, it also has given a clear function
The next part I want it to do is have some sort of key listener to allow multiple presses to bring up multiple numbers, because right now its brining up an int, and then it is just deleting the int when the secogn number is entered. For example it if I press button 1, it will show number one, but if I press button 2 it will clear the original number and then replace it with the number 2
Basically I want to make a simple calculator with key presses from the Jbuttons, but its working out to be a little hard
Now I have the buttons and the text fields sorted out, but now I need to allow the buttons to do their calculations. Thats what Im having troubles with
Bo, Gambles, I am also creating calculator, and I have the same, almost the same problems. You know, my problem is that these buttons that I'm telling get String, I mean, I say if you press that button, set Text "1". So, "1" is string, and I don't know how to make this string double. I did Double.toString and Double.parseDouble to convert it, but it says that it cannot be applied to Buttons.
Bo, Gambles, I am also creating calculator, and I have the same, almost the same problems. You know, my problem is that these buttons that I'm telling get String, I mean, I say if you press that button, set Text "1". So, "1" is string, and I don't know how to make this string double. I did Double.toString and Double.parseDouble to convert it, but it says that it cannot be applied to Buttons.
I think you need to use a double.parsedouble(getText) and use that where you what to get your double from. You cant change a string into a double not using a parse, as far as Im aware
Post by:autobot
Squanch that. And squanch this tiny ad:
a bit of art, as a gift, the permaculture playing cards