-
Notifications
You must be signed in to change notification settings - Fork 0
/
AWT.java
53 lines (40 loc) · 1.14 KB
/
AWT.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
import java.awt.*;
import java.awt.event.*;
public class AWT extends WindowAdapter implements ActionListener {
private Frame frame;
private Button ok;
private Label disp;
private boolean click;
public AWT(){
frame = new Frame("Hi from AWT");
disp = new Label();
disp.setText("Enter this button");
disp.setBounds(0,50,360,50);
disp.setBackground(Color.blue);
click = false;
ok = new Button("Hi 👋");
ok.setBounds(40,120,100,30);
ok.addActionListener(this);
frame.addWindowListener(this);
frame.add(disp);
frame.add(ok);
frame.setSize(360,200);
frame.setLayout(null);
frame.setVisible(true);
frame.setResizable(false);
}
public void windowClosing(WindowEvent e) {
frame.dispose();
}
public void actionPerformed (ActionEvent e) {
if(e.getSource() == ok){
if(click)
disp.setText("Hello");
else disp.setText("Hi");
click = !click;
}
}
public static void main(String []args){
AWT a = new AWT();
}
}