/Mini-Calculator

Simple Calculator build with eclipse window builder

Primary LanguageJavaApache License 2.0Apache-2.0

Simple-Calculator

  • Simple Calculator built with Eclipse window builder

Image

  • After optimizing the app, updated image is as following:

Image

  • Made some UI changes, result as following:

Image

  • Java Swing application for a mini calculator. It creates a GUI window with various buttons and a text field to perform basic arithmetic calculations.

  • Here's a breakdown of the code:

    • The class Optimization extends JFrame to create the main frame for the calculator.
    • The constructor sets up the frame by setting its size, title, and default close operation.
    • The contentPane panel is created and set as the content pane for the frame.
    • Various Swing components such as buttons, labels, and text fields are created and added to the content pane.
    • Action listeners are added to the buttons to perform specific operations when clicked.
    • The btnPlus, btnMinus, btnMultiply, btnDivide, and btnSquare_1 buttons set the operation variable to the respective operation symbol (+, -, *, /, <html>x<sup>y</sup></html>).
    • The btnEqual button calculates the result based on the selected operation and displays it in the text field (tfNumber) and a label (lbCalculation).
    • Other buttons (btnSqrt, btnSquare, btnClear, btnOne, btnTwo, ..., btnNine, btnZero) handle specific actions such as square root, square, clearing the text field, and entering numeric values.
    • The Optimization class represents the main window of the calculator application.
  • To run this code, we need to have the necessary dependencies for Java Swing and compile and execute the code using a Java development environment.