Java Swing is a GUI (graphical user Interface) widget toolkit for Java. Java Swing is a part of Oracle’s Java foundation classes . Java Swing is an API for providing graphical user interface elements to Java Programs.Swing was created to provide more powerful and flexible components than Java AWT (Abstract Window Toolkit).
In this article we will use Java Swing components to create a simple calculator with only +, -, /, * operations.
methods used :
- add(Component c) : adds component to container.
- addActionListenerListener(ActionListener d) : add actionListener for specified component
- setBackground(Color c) : sets the background color of the specified container
- setSize(int a, int b) : sets the size of container to specified dimensions.
- setText(String s) : sets the text of the label to s.
- getText() : returns the text of the label.
Java program to create a simple calculator with basic +, -, /, * using java swing elements.
Note : this program might not run in an online compiler please use an offline IDE.
Attention reader! Don’t stop learning now. Get hold of all the important Java and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.
- Student Grade Calculator using Java Swing
- Java Swing | Create a simple text editor
- Java Swing | Simple User Registration Form
- Simple Calculator using TCP in Java
- Simple Calculator via UDP in Java
- How to build a simple Calculator app using Android Studio?
- Java Swing | Translucent and shaped Window in Java
- Java Swing | ScrollPaneLayout Class
- Java Swing | JPanel with examples
- Java Swing | Internal Frame with examples
- Java Swing | JMenuBar
- Java Swing | JFileChooser
- Java Swing | Look and Feel
- Java Swing | JTextField
- Java Swing | JProgressBar
- Java Swing | JPasswordField
- Java Swing | JSpinner
- Java Swing | JPopupMenu
- Java Swing | JTextArea
- JLabel | Java Swing
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.