-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathGUIFRAME.java
149 lines (135 loc) · 4.59 KB
/
GUIFRAME.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
package guiframe;
/* @author Saket*/
import java.awt.*;
import java.awt.event.*;
public class GUIFRAME extends Frame implements ActionListener
{
Label l1,l2,l3,l4;
TextField t1,t2,t3;
Button b1,b2,b3,b4,b5,b6;
public GUIFRAME(String title)
{
super(title);
this.setLayout(null);
this.setSize(1200,800);
this.setBackground(Color.cyan);
Font f= new Font("arial",Font.BOLD,20);
l1=new Label("Arithmetic Operations");
l2=new Label("Enter first No:");
l3=new Label("Enter second No:");
l4=new Label("Result");
t1=new TextField();
t2=new TextField();
t3=new TextField();
b1=new Button("ADD");
b2=new Button("SUB");
b3=new Button("MUL");
b4=new Button("DIV");
b5=new Button("REFRSH");
b6=new Button("CLOSE");
l1.setFont(f);
l2.setFont(f);
l3.setFont(f);
l4.setFont(f);
t1.setFont(f);
t2.setFont(f);
t3.setFont(f);
b1.setFont(f);
b2.setFont(f);
b3.setFont(f);
b4.setFont(f);
b5.setFont(f);
b6.setFont(f);
l1.setForeground(Color.RED);
l2.setForeground(Color.RED);
l3.setForeground(Color.RED);
l4.setForeground(Color.RED);
t1.setForeground(Color.RED);
t2.setForeground(Color.RED);
t3.setForeground(Color.RED);
b1.setForeground(Color.RED);
b2.setForeground(Color.RED);
b3.setForeground(Color.RED);
b4.setForeground(Color.RED);
b5.setForeground(Color.RED);
b6.setForeground(Color.RED);
b6.setBounds(500,50,200,30);
l1.setBounds(400,100,300,30);
l2.setBounds(200,200,200,30);
t1.setBounds(400,300,200,30);
l3.setBounds(200,300,200,30);
t2.setBounds(450,200,200,30);
l4.setBounds(200,400,200,30);
t3.setBounds(450,400,200,30);
b1.setBounds(200,500,100,30);
b2.setBounds(350,500,100,30);
b3.setBounds(500,500,100,30);
b4.setBounds(650,500,100,30);
b5.setBounds(800,500,100,30);
this.add(l1);
this.add(l2);
this.add(l3);
this.add(l4);
this.add(t1);
this.add(t2);
this.add(t3);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
b5.addActionListener(this);
b6.addActionListener(this);
this.add(b1);
this.add(b2);
this.add(b3);
this.add(b4);
this.add(b5);
this.add(b6);
this.setVisible(true);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==b1)
{
int a=Integer.parseInt(t1.getText().toString());
int b=Integer.parseInt(t2.getText().toString());
int c=a+b;
t3.setText(c+" ");
}
else if(ae.getSource()==b2)
{
int a=Integer.parseInt(t1.getText().toString());
int b=Integer.parseInt(t2.getText().toString());
int c=a-b;
t3.setText(c+" ");
}
else if(ae.getSource()==b3)
{
int a=Integer.parseInt(t1.getText().toString());
int b=Integer.parseInt(t2.getText().toString());
int c=a*b;
t3.setText(c+" ");
}
else if(ae.getSource()==b4)
{
int a=Integer.parseInt(t1.getText().toString());
int b=Integer.parseInt(t2.getText().toString());
int c=a/b;
t3.setText(c+" ");
}
else if(ae.getSource()==b5)
{
t1.setText(null);
t2.setText(null);
t3.setText(null);
}
else if(ae.getSource()==b6)
{
System.exit(1);
}
}
public static void main(String[] args)
{
GUIFRAME gf=new GUIFRAME("ARITHMETIC CALCULATOR");
}
}