Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

novice seeking help with Calculator program

 
Charles Woods
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am a newby taking my first Java class. I have to create an Applet of a working Calculator. So far, all I know how to do is create buttons and JTextArea. I don't know how to set up any functionality among the components. I don't even know which is better to use; JTextField or TextArea. If anyone out there can help, I will be happy to wash your car and maybe even do some free yard work if you could give me some pointers.
Thanks.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, welcome to the ranch!

This is a big subject area, but fortunately Sun has pretty good tutorials on almost everything Java. See if the Swing Tutorial covers the right kinds of things.

For adding functionality to the widgets, what you're looking for is probably in the EventListener and ActionListener family. You add these objects to your UI components and Swing calls them when interesting things like mouse clicks and keystrokes happen.

If this seems like the right direction, you might wander over to the Swing forum with further questions.
[ July 05, 2007: Message edited by: Stan James ]
 
Charles Woods
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the help. I know how to set up the event handlers (sorry I didn't mention that). I guess I need to figure out which events to use. I have managed to get numbers to show up in the JTextArea, but I don't know how to get any results from the numbers.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic