• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

i need help with a simple add, subtract, cal. applet

 
J Fox
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i'm having a bit of a problem with the class part of the program....
it says to first create a class called CalculatorPanel
and private int operand1, operand2, and result....and make get methods for all of these.....

then says to make another class called Calculator and create all the buttons shown in the output....

________________________________________

enter first operand : | text field "512"|
enter second operand : | text field "11" |

select operation: |button 1 " + "| or |button 2 " - "| result: "501"

________________________________________
**imagine the above as a GUI

then the third step is to create another class called CalculatorGUI
and it says to create the actual frame and stuff of the gui...

this is what i have so far...help if you can i would really appreciate it



i tried to inter-twin the 1st and 3rd step into one big class....i need imediate help lol its due at 9:30 this morning so if you have any suggestions plz...do tell..i dont know if every listener is supposed to have a implemented actionlistener or if two can use the same one.....

i know every button has to have a separate listener ....
but in the code

can the "ButtonListener" in the code be anything you want it to be named or is there a pre-defined set of words for text fields and buttons...
well if you can help

thanks,
Justin
 
Joe Ess
Bartender
Posts: 9314
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by J Fox:

i tried to inter-twin the 1st and 3rd step into one big class....i need imediate help lol its due at 9:30 this morning so if you have any suggestions plz


I'd suggest that you should get an early start so if you have problems you'll have time to figure them out, but it seems a little late for that.



...do tell..i dont know if every listener is supposed to have a implemented actionlistener or if two can use the same one.....


It seems like you are asking if you need a seperate instance of a listener for every GUI object you want to assign a listener to. The answer is no. You can have different listeners for each GUI object or you can use the same one (in which case you have to differentiate between the different objects which can fire that event).


can the "ButtonListener" in the code be anything you want it to be named or is there a pre-defined set of words for text fields and buttons...
well if you can help


It has to be an instance of a class which implements the interface ActionListener. How do I know? The Java Documentation for JButton told me.
 
Jeff Bosch
Ranch Hand
Posts: 805
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It has to be an instance of a class which implements the interface ActionListener. How do I know? The Java Documentation for JButton told me.


Read the documentation? NOOOOOOO! Anything but that!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic