Skip to content

Commit db83187

Browse files
authored
Update Calculator.java
1 parent e537c02 commit db83187

File tree

1 file changed

+74
-34
lines changed

1 file changed

+74
-34
lines changed

Diff for: Calculator.java

+74-34
Original file line numberDiff line numberDiff line change
@@ -1,123 +1,163 @@
11
import java.awt.Color;
2+
import java.awt.Font;
23

34
import javax.swing.JButton;
45
import javax.swing.JFrame;
56
import javax.swing.JLabel;
67
import javax.swing.SwingConstants;
78

9+
10+
811
public class Calc {
9-
12+
1013
Calc(){
11-
12-
JFrame jf=new JFrame("Calculator");
13-
jf.setSize(450,450);
14+
JFrame jf=new JFrame("Java Calculator");
15+
jf.setSize(450,510);
1416
jf.setLocation(350, 80);
1517
jf.setLayout(null);
1618
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
1719
jf.setVisible(true);
1820

1921
JLabel Displaylabel=new JLabel("Sample Display");
2022
Displaylabel.setHorizontalAlignment(SwingConstants.RIGHT);
21-
Displaylabel.setBounds(20,20,440,50);
22-
Displaylabel.setBackground(Color.white);
23-
Displaylabel.setForeground(Color.black);
23+
Displaylabel.setBounds(20,20,400,70);
24+
Displaylabel.setBackground(Color.gray);
25+
Displaylabel.setForeground(Color.white);
2426
Displaylabel.setOpaque(true);
2527
jf.add(Displaylabel);
2628

2729
JButton Mcbutton = new JButton("MC");
2830
Mcbutton.setBounds(20,120,60,60);
2931
jf.add(Mcbutton);
3032

33+
34+
JButton Percentagebutton = new JButton("%");
35+
Percentagebutton.setBounds(20,190,60,60);
36+
jf.add(Percentagebutton);
37+
Percentagebutton.setFont(new Font("Arial", Font.PLAIN, 20));
38+
39+
JButton Mrbutton = new JButton("MR");
40+
Mrbutton.setBounds(100,120,60,60);
41+
jf.add(Mrbutton);
42+
3143
JButton Sevenbutton = new JButton("7");
32-
Sevenbutton.setBounds(100,120,60,60);
44+
Sevenbutton.setBounds(100,190,60,60);
3345
jf.add(Sevenbutton);
46+
Sevenbutton.setFont(new Font("Arial", Font.PLAIN, 30));
47+
48+
JButton Mminusbutton = new JButton("M-");
49+
Mminusbutton.setBounds(180,120,60,60);
50+
jf.add(Mminusbutton);
3451

3552
JButton Eightbutton = new JButton("8");
36-
Eightbutton.setBounds(180,120,60,60);
53+
Eightbutton.setBounds(180,190,60,60);
3754
jf.add(Eightbutton);
55+
Eightbutton.setFont(new Font("Arial", Font.PLAIN, 30));
56+
57+
JButton Mplusbutton = new JButton("M+");
58+
Mplusbutton.setBounds(260,120,60,60);
59+
jf.add(Mplusbutton);
3860

3961
JButton Ninebutton = new JButton("9");
40-
Ninebutton.setBounds(260,120,60,60);
62+
Ninebutton.setBounds(260,190,60,60);
4163
jf.add(Ninebutton);
64+
Ninebutton.setFont(new Font("Arial", Font.PLAIN, 30));
65+
66+
JButton Rootbutton = new JButton("Root");
67+
Rootbutton.setBounds(340,120,60,60);
68+
jf.add(Rootbutton);
69+
Rootbutton.setFont(new Font("Arial", Font.PLAIN, 30));
70+
4271

4372
JButton Divisionbutton = new JButton("/");
44-
Divisionbutton.setBounds(340,120,60,60);
73+
Divisionbutton.setBounds(340,190,60,60);
4574
jf.add(Divisionbutton);
75+
Divisionbutton.setFont(new Font("Arial", Font.PLAIN, 30));
76+
4677

4778
JButton Plusorminusbutton = new JButton("+/-");
48-
Plusorminusbutton.setBounds(20,190,60,60);
79+
Plusorminusbutton.setBounds(20,260,60,60);
4980
jf.add(Plusorminusbutton);
81+
Plusorminusbutton.setFont(new Font("Arial", Font.PLAIN,20));
5082

5183
JButton Fourbutton = new JButton("4");
52-
Fourbutton.setBounds(100,190,60,60);
84+
Fourbutton.setBounds(100,260,60,60);
5385
jf.add(Fourbutton);
86+
Fourbutton.setFont(new Font("Arial", Font.PLAIN, 30));
5487

5588
JButton Fivebutton = new JButton("5");
56-
Fivebutton.setBounds(180,190,60,60);
89+
Fivebutton.setBounds(180,260,60,60);
5790
jf.add(Fivebutton);
91+
Fivebutton.setFont(new Font("Arial", Font.PLAIN, 30));
5892

5993

6094

6195
JButton Sixbutton = new JButton("6");
62-
Sixbutton.setBounds(260,190,60,60);
96+
Sixbutton.setBounds(260,260,60,60);
6397
jf.add(Sixbutton);
98+
Sixbutton.setFont(new Font("Arial", Font.PLAIN, 30));
6499

65100
JButton Multibutton = new JButton("X");
66-
Multibutton.setBounds(340,190,60,60);
101+
Multibutton.setBounds(340,260,60,60);
67102
jf.add(Multibutton);
103+
Multibutton.setFont(new Font("Arial", Font.PLAIN, 30));
68104

69105

70106
JButton Cebutton = new JButton("CE");
71-
Cebutton.setBounds(20,260,60,60);
107+
Cebutton.setBounds(20,330,60,60);
72108
jf.add(Cebutton);
73109

74110

75111
JButton Onebutton = new JButton("1");
76-
Onebutton.setBounds(100,260,60,60);
112+
Onebutton.setBounds(100,330,60,60);
77113
jf.add(Onebutton);
114+
Onebutton.setFont(new Font("Arial", Font.PLAIN, 30));
115+
78116

79117
JButton Twobutton = new JButton("2");
80-
Twobutton.setBounds(180,260,60,60);
118+
Twobutton.setBounds(180,330,60,60);
81119
jf.add(Twobutton);
120+
Twobutton.setFont(new Font("Arial", Font.PLAIN, 30));
82121

83122
JButton Threebutton = new JButton("3");
84-
Threebutton.setBounds(260,260,60,60);
123+
Threebutton.setBounds(260,330,60,60);
85124
jf.add(Threebutton);
125+
Threebutton.setFont(new Font("Arial", Font.PLAIN, 30));
126+
86127

87128
JButton Subtractbutton = new JButton("-");
88-
Subtractbutton.setBounds(340,260,60,60);
129+
Subtractbutton.setBounds(340,330,60,60);
89130
jf.add(Subtractbutton);
131+
Subtractbutton.setFont(new Font("Arial", Font.PLAIN, 30));
90132

91133
JButton Acbutton = new JButton("AC");
92-
Acbutton.setBounds(20,330,60,60);
134+
Acbutton.setBounds(20,400,60,60);
93135
jf.add(Acbutton);
94136

95137
JButton Zerobutton = new JButton("0");
96-
Zerobutton.setBounds(100,330,60,60);
138+
Zerobutton.setBounds(100,400,60,60);
97139
jf.add(Zerobutton);
140+
Zerobutton.setFont(new Font("Arial", Font.PLAIN, 30));
98141

99142
JButton Pointbutton = new JButton(".");
100-
Pointbutton.setBounds(180,330,60,60);
143+
Pointbutton.setBounds(180,400,60,60);
101144
jf.add(Pointbutton);
145+
Pointbutton.setFont(new Font("Arial", Font.PLAIN, 30));
146+
102147

103148
JButton Equalbutton = new JButton("=");
104-
Equalbutton.setBounds(260,330,60,60);
149+
Equalbutton.setBounds(260,400,60,60);
105150
jf.add(Equalbutton);
151+
Equalbutton.setFont(new Font("Arial", Font.PLAIN, 30));
152+
106153

107154
JButton Plusbutton = new JButton("+");
108-
Plusbutton.setBounds(340,330,60,60);
155+
Plusbutton.setBounds(340,400,60,60);
109156
jf.add(Plusbutton);
157+
Plusbutton.setFont(new Font("Arial", Font.PLAIN, 30));
110158

111-
112-
113-
114159
}
115-
116160
public static void main(String[] args) {
117-
118-
/*Calc C=new Calc();*/
119-
120161
new Calc();
121162
}
122-
123163
}

0 commit comments

Comments
 (0)