• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 808
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
reply
    Bookmark Topic Watch Topic
  • New Topic