• Post Reply Bookmark Topic Watch Topic
  • New Topic

GUI calculator  RSS feed

 
Ian Cockcroft
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have developed a little GUI the calculates square root of a number. The GUI has a text field for the entry number and a text field for the answer. It then has 2 buttons one for "calculate" and an "Exit" button. All it does is takes a number in the 1st text field, calculates the square root and displays it in the 2nd text box when calculate button is pressed. How do i do this ? My code so far is below.

 
Don Kiddick
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you need to add an ActionListener to your JButton objects using the addActionListener method. Check out how to Use Buttons, Check Boxes, and Radio Buttons in The Java Tutorial for information and examples of using buttons.
[ June 04, 2003: Message edited by: Don Kiddick ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!