Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- import java.awt.*;
- public class Class {
- public static void main(String[] args) {
- JPanel windowContent;
- JTextField displayField;
- JButton button0 = null;
- JButton button1 = null;
- JButton button2 = null;
- JButton button3 = null;
- JButton button4 = null;
- JButton button5 = null;
- JButton button6 = null;
- JButton button7 = null;
- JButton button8 = null;
- JButton button9 = null;
- JButton buttonPoint;
- JButton buttonEqual;
- JPanel pl;
- Calculator() {
- windowContent = new JPanel();
- BorderLayout bl = new BorderLayout();
- windowContent.setLayout(bl);
- displayField = new JTextField(30);
- windowContent.add("North", displayField);
- button0 = new JButton("0");
- button0 = new JButton("1");
- button0 = new JButton("2");
- button0 = new JButton("3");
- button0 = new JButton("4");
- button0 = new JButton("5");
- button0 = new JButton("6");
- button0 = new JButton("7");
- button0 = new JButton("8");
- button0 = new JButton("9");
- buttonPoint = new JButton(".");
- buttonEqual = new JButton("=");
- pl = new JPanel();
- GridLayout gl = new GridLayout(4, 3);
- pl.setLayout(gl);
- pl.add(button1);
- pl.add(button2);
- pl.add(button3);
- pl.add(button4);
- pl.add(button5);
- pl.add(button6);
- pl.add(button7);
- pl.add(button8);
- pl.add(button9);
- pl.add(button0);
- pl.add(buttonPoint);
- pl.add(buttonEqual);
- windowContent.add("Center",pl);
- JFrame frame = new JFrame("Calculator");
- frame.setContentPane(windowContent);
- frame.pack();
- frame.setVisible(true);
- }
- }
- }```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement