• Post Reply Bookmark Topic Watch Topic
  • New Topic

JButton & Event Handling question.  RSS feed

 
Brad Dwan
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I'm trying to achieve is a basic calculator. Simple for most...

I obviously know how to do the maths although I'm having trouble retaining the data. I was just wondering if you could explain how to get and retain the second "set" of data. ie.

1+2 = 3
^this part.

Maybe its the the structures I'm using or maybe its the logics.


edit:
the code is pretty straight forward. Reading actions from JButtons, Conditionals for add/subtract/equals etc. The problem is I stalemate at this point. I think its the logics behind it, but a expert opinion can't be bad.

The answerField.setText(); methods are just their for clarity.

Any help would be appreciated, no matter how blunt.
 
Brad Dwan
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And if i can help it I would rather not look at other Java calc's source code, I want to 'try' and achieve it on my own with minimal external input.
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No matter what the solution will be I want to advise you not to use == for String comparison. Use the equals method instead.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!