FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Java-Programs/GUI_java/Mycalculator.java at main · VirajPatidar/Java-Programs · GitHub
VirajPatidar
/
Java-Programs
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Java-Programs
/
GUI_java
/
Mycalculator.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
96 lines (77 loc) · 2.58 KB
Breadcrumbs
Java-Programs
/
GUI_java
/
Mycalculator.java
Copy path
File metadata and controls
96 lines (77 loc) · 2.58 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import
java
.
awt
.*;
import
javax
.
swing
.*;
import
java
.
awt
.
event
.*;
class
Mycalculator
implements
ActionListener
{
Frame
f
=
new
Frame
();
Label
l1
=
new
Label
(
"FIRST NUMBER"
);
Label
l2
=
new
Label
(
"SECOND NUMBER"
);
Label
l3
=
new
Label
(
"RESULT"
);
TextField
t1
=
new
TextField
();
TextField
t2
=
new
TextField
();
TextField
t3
=
new
TextField
();
Button
b1
=
new
Button
(
"+"
);
Button
b2
=
new
Button
(
"-"
);
Button
b3
=
new
Button
(
"*"
);
Button
b4
=
new
Button
(
"/"
);
Button
b5
=
new
Button
(
"%"
);
Button
b6
=
new
Button
(
"exp"
);
Button
b7
=
new
Button
(
"C"
);
Button
clear
=
new
Button
(
"EXIT"
);
Mycalculator
() {
l1
.
setBounds
(
50
,
100
,
100
,
20
);
l2
.
setBounds
(
50
,
140
,
115
,
20
);
l3
.
setBounds
(
50
,
180
,
100
,
20
);
t1
.
setBounds
(
200
,
100
,
80
,
20
);
t2
.
setBounds
(
200
,
140
,
80
,
20
);
t3
.
setBounds
(
200
,
180
,
80
,
20
);
b1
.
setBounds
(
50
,
220
,
50
,
20
);
b2
.
setBounds
(
110
,
220
,
50
,
20
);
b3
.
setBounds
(
170
,
220
,
50
,
20
);
b4
.
setBounds
(
230
,
220
,
50
,
20
);
b5
.
setBounds
(
50
,
260
,
50
,
20
);
b6
.
setBounds
(
110
,
260
,
50
,
20
);
b7
.
setBounds
(
170
,
260
,
50
,
20
);
clear
.
setBounds
(
230
,
260
,
50
,
20
);
f
.
add
(
l1
);
f
.
add
(
l2
);
f
.
add
(
l3
);
f
.
add
(
t1
);
f
.
add
(
t2
);
f
.
add
(
t3
);
f
.
add
(
b1
);
f
.
add
(
b2
);
f
.
add
(
b3
);
f
.
add
(
b4
);
f
.
add
(
b5
);
f
.
add
(
b6
);
f
.
add
(
b7
);
f
.
add
(
clear
);
b1
.
addActionListener
(
this
);
b2
.
addActionListener
(
this
);
b3
.
addActionListener
(
this
);
b4
.
addActionListener
(
this
);
b5
.
addActionListener
(
this
);
b6
.
addActionListener
(
this
);
b7
.
addActionListener
(
this
);
clear
.
addActionListener
(
this
);
f
.
setLayout
(
null
);
f
.
setVisible
(
true
);
f
.
setSize
(
500
,
500
);
}
public
void
actionPerformed
(
ActionEvent
e
) {
float
n1
=
Float
.
parseFloat
(
t1
.
getText
());
float
n2
=
Float
.
parseFloat
(
t2
.
getText
());
if
(
e
.
getSource
()==
b1
)
t3
.
setText
(
String
.
valueOf
(
n1
+
n2
));
if
(
e
.
getSource
()==
b2
)
t3
.
setText
(
String
.
valueOf
(
n1
-
n2
));
if
(
e
.
getSource
()==
b3
)
t3
.
setText
(
String
.
valueOf
(
n1
*
n2
));
if
(
e
.
getSource
()==
b4
)
t3
.
setText
(
String
.
valueOf
(
n1
/
n2
));
if
(
e
.
getSource
()==
b5
)
t3
.
setText
(
String
.
valueOf
(
n1
%
n2
));
if
(
e
.
getSource
()==
b6
)
t3
.
setText
(
String
.
valueOf
(
Math
.
pow
(
n1
,
n2
)));
if
(
e
.
getSource
()==
b7
){
t1
.
setText
(
""
);
t2
.
setText
(
""
);
t3
.
setText
(
""
);
}
if
(
e
.
getSource
()==
clear
){
System
.
exit
(
0
);
}
}
public
static
void
main
(
String
[]
args
) {
new
Mycalculator
();
}
}
Back
|
FazBrowse Home
|
New Git URL