Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // By: Sammy Samkough
- package com.samkough.calculator.main;
- import javax.swing.*;
- import java.awt.*;
- import java.awt.event.*;
- public class Calc
- {
- private static final int WIDTH = 400;
- private static final int HEIGHT = 400;
- JFrame frame;
- JPanel p1;
- JPanel p2;
- JTextField tf1;
- JButton b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12;
- public Calc()
- {
- frame = new JFrame("Calc");
- p1 = new JPanel();
- p2 = new JPanel();
- frame.setContentPane(p1);
- p1.setLayout(new BorderLayout());
- p2.setLayout(new GridLayout(4, 3));
- tf1 = new JTextField(" ");
- b7 = new JButton("7");
- b8 = new JButton("8");
- b9 = new JButton("9");
- b4 = new JButton("4");
- b5 = new JButton("5");
- b6 = new JButton("6");
- b1 = new JButton("1");
- b2 = new JButton("2");
- b3 = new JButton("3");
- b10 = new JButton("0");
- b11 = new JButton("+");
- b12 = new JButton("=");
- p1.add(tf1, BorderLayout.NORTH);
- p1.add(p2, BorderLayout.CENTER);
- p2.add(b1);
- p2.add(b2);
- p2.add(b3);
- p2.add(b4);
- p2.add(b5);
- p2.add(b6);
- p2.add(b7);
- p2.add(b8);
- p2.add(b9);
- p2.add(b10);
- p2.add(b11);
- p2.add(b12);
- frame.setSize(WIDTH, HEIGHT);
- frame.setLocationRelativeTo(null);
- frame.setResizable(false);
- // frame.setTitle("Sammy");
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.setVisible(true);
- }
- public void actionPerformed(ActionEvent e)
- {
- }
- }
- -------------------------------------------------------------------------------------------------------------------------------------
- package com.samkough.calculator.main;
- public class CalcTester
- {
- public static void main(String args[])
- {
- Calc c1 = new Calc();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment