-
Notifications
You must be signed in to change notification settings - Fork 4
/
Calculator_Design.java
78 lines (63 loc) · 1.55 KB
/
Calculator_Design.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import java.awt.*;
import javax.swing.*;
class Calculator_Design extends JFrame {
JTextField input;
JButton zero,one,two,three,four,five,six,seven,eight,nine,plus,minus,mul,div,equ,dec,clear,percent,root,square;
Calculator_Design(){
setSize(200,300);
setTitle("Calculator");
setDefaultCloseOperation(EXIT_ON_CLOSE);
setResizable(false);
input = new JTextField(10);
input.setEnabled(false);
input.setHorizontalAlignment(JTextField.RIGHT);
input.setFont(new Font("Bookman Old Style", Font.BOLD,25));
zero = new JButton("0");
one = new JButton("1");
two = new JButton("2");
three = new JButton("3");
four = new JButton("4");
five = new JButton("5");
six = new JButton("6");
seven = new JButton("7");
eight = new JButton("8");
nine = new JButton("9");
dec = new JButton(".");
plus = new JButton("+");
minus = new JButton("-");
mul = new JButton("*");
div = new JButton("/");
equ = new JButton("=");
clear = new JButton("C");
percent = new JButton("%");
root = new JButton("√");
square = new JButton("²");
JPanel p = new JPanel(new GridLayout(5,4));
p.add(clear);
p.add(root);
p.add(square);
p.add(percent);
p.add(one);
p.add(two);
p.add(three);
p.add(div);
p.add(four);
p.add(five);
p.add(six);
p.add(mul);
p.add(seven);
p.add(eight);
p.add(nine);
p.add(minus);
p.add(zero);
p.add(dec);
p.add(plus);
p.add(equ);
add(input, BorderLayout.NORTH);
add(p, BorderLayout.CENTER);
setVisible(true);
}
public static void main(String[] args) {
new Calculator_Design();
}
}