-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathAddTwo.java
More file actions
48 lines (43 loc) · 871 Bytes
/
AddTwo.java
File metadata and controls
48 lines (43 loc) · 871 Bytes
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
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class AddTwo extends Frame implements ActionListener
{
String msg;
TextField num1, num2, res;
Label l1, l2, l3;
Button sum;
public AddTwo()
{
l1 = new Label("Number 1");
l2 = new Label("Number 2");
l3 = new Label("result");
num1 = new TextField(10);
num2 = new TextField(10);
res = new TextField(30);
sum = new Button("Add");
sum.addActionListener(this);
add(l1);
add(num1);
add(l2);
add(num2);
add(l3);
add(res);
add(sum);
setVisible(true);
setSize(800,800);
setLayout(new FlowLayout());
}
public void actionPerformed(ActionEvent ae)
{
int n1 = Integer.parseInt(num1.getText());
int n2 = Integer.parseInt(num2.getText());
int num3 = n1 + n2;
System.out.println("Result of Adding Two no is :");
res.setText(String.valueOf(num3));
}
public static void main(String args[])
{
new AddTwo();
}
}