forked from ranjansharma255/Java_Programs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSwapButton.java
More file actions
40 lines (36 loc) · 752 Bytes
/
SwapButton.java
File metadata and controls
40 lines (36 loc) · 752 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
import java.awt.*;
import java.awt.event.*;
public class SwapButton extends Frame implements ActionListener
{
Label l1,l2;
TextField t1,t2;
Button b;
SwapButton()
{
super("My Frame");
l1 = new Label("First");
l2 = new Label("Second");
t1 = new TextField(10);
t2 = new TextField(10);
b = new Button("Swap Cheysey");
add(l1);
add(t1);
add(l2);
add(t2);
add(b);
setLayout(new FlowLayout());
b.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
String temp = t1.getText();
t1.setText(t2.getText());
t2.setText(temp);
}
public static void main(String[] args)
{
SwapButton f = new SwapButton();
f.setSize(300,300);
f.setVisible(true);
}
}