A simple, graphical user interface (GUI) calculator application built using Java Swing and AWT. This project was created to understand the basics of Java desktop application development, event handling, and UI layout.
- Basic Arithmetic: Perform Addition (+), Subtraction (-), Multiplication (X), and Division (/).
- Decimal Support: Handles floating-point calculations.
- Clear Functionality: A "Clear" button to reset the input.
- Interactive UI: Built using
JFrame,JButton, andJLabel.
- Language: Java
- Libraries:
javax.swing(for UI components),java.awt(for events and styling).
To run this project on your local machine, ensure you have the Java Development Kit (JDK) installed.
-
Clone the repository (or download the files):
git clone https://github.com/mrraul010/java-swing-calculator.git cd java-swing-calculator -
Compile the Java file: Open your terminal or command prompt and run:
javac calculator.java
-
Run the application:
java calculator
calculator.java: The main source code containing the logic and UI design.
This project helped in understanding:
- How to create a
JFramewindow. - Implementing the
ActionListenerinterface to handle button clicks. - Using
floatfor mathematical operations. - Manual layout management using
.setBounds().
Feel free to fork this repository and submit pull requests if you want to improve the design or functionality. I welcome any corrections regarding flaws or logic errors. You are also free to use this code for your own studies or as a base for your own mini-projects.
