Advertisement
akosiraff

Gui Calculator JAVA

Nov 4th, 2013
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1.  
  2. Download: http://solutionzip.com/downloads/gui-calculator-java/
  3. Task 1. Create a GUI the following way:
  4. You need 3 Text Fileds, placed one under another. Use layouts of your choice, recommendation: use a JPanel for each.
  5. Add a label to each field (on the same panel, with FLowLayout)
  6. Field 1 – First Number
  7. Field 2 – Second Number
  8. Field 3 – Result
  9. Make Result field non-editable
  10. On a separate panel under the Text fields create 5 buttons, “+”, “-“, “*”,“/”, and Reset
  11. (or Add, Subtract, Multiply, and Divide (your choice))
  12. Be assures that GUI looks as you want, snip and submit.
  13. For the time being actionPerformed() is an empty method. (10 points)
  14. Task2. Write actionPerformed() method which reads Fields 1 and 2, calculates the result, and places it into Field 3. Create helper methods
  15. 1.to read an integer from a JTextField, passed as a parameter throwing a NumberFormatException, could be a different, you find it by testing different inputs including an empty string
  16. Result has to be double to handle division.
  17. 2 to perform division, throwing DivideByZeroException, you will need a class DivisionByZeroException for this.
  18. Catch exceptions in the actionPerformed method. Do not exit the program, but clear all the Fields instead and send JOptionPane ERROR_MESSAGE with description of the actual error.
  19. if you push Reset Button, clear the fields.
  20. More interesting scenario: at start and on Reset make Result field invisible; make it visible after pushing operation Button to show the result
  21.  
  22. Download: http://solutionzip.com/downloads/gui-calculator-java/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement