How to Make a Calculator in Java Using Swing

This tutorial is about how to make a calculator in Java. Below I have shared the simple calculator program in java using swing. It is a simple calculator in Java which can perform basic arithmetic operations like addition, subtraction, multiplication and division of two numbers. If you are getting any difficulty to understand or run this program then comment below, I will try to solve problem.
Program to Create Calculator Using Java Swing


Program to Make a Calculator in Java Using Swing


40 thoughts on “How to Make a Calculator in Java Using Swing

  1. Nahida

    Everything worked nicely but when I click on any of the numbers, nothing appears in the text field. And if I click on the operators there are lots of errors. Please help.

    1. Admin Post author

      Yes there was some problem in it, now I fixed. Please run it and let me know it is working or not.

  2. Maaz Ali

    Very Nice and simple code…..
    the first program i run and it give zero errors… rockzzzzzzzzzzzzzzzzz

  3. vishal

    addition of more than 3 nos not is considering last 2 nos only for all arthematic operations

  4. khan

    Error: could not find or load main class cal
    it give only this option nothing else

  5. ANON

    Thanks alot, this helped me and taught me exactly the things i was looking to learn

  6. sanchita khadka

    simple and understanding code. helped me to understand how it worked thanks a loads. looking forward for other codes as well.

  7. abdizhakur

    thanks you
    i went to help me the button of point
    and other additionalbuttons

  8. Harjot Singh

    run time error will come “could not find or load main class calc”

    1. Admin Post author

      Class name is case sensitive while running. Use Calc instead of calc.

  9. Aayana

    this program is running bt this is showing null screen

  10. Aditya

    If I hit any operator without entering any values, I want the program to show a message “Enter values”. How can I achieve that?

  11. Ak

    By clicking on any of operators,number entered gets deleted instead of respective operations to be performed


Leave a Reply

Your email address will not be published. Required fields are marked *