-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWindowEventListenerUsingInterfaceDemo.java
More file actions
55 lines (38 loc) · 1.21 KB
/
Copy pathWindowEventListenerUsingInterfaceDemo.java
File metadata and controls
55 lines (38 loc) · 1.21 KB
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
import java.awt.event.*;
import java.awt.Frame;
public class WindowEventListenerUsingInterfaceDemo implements WindowListener {
public Frame f;
public static void main(String[] args) {
WindowEventListenerUsingInterfaceDemo weld = new WindowEventListenerUsingInterfaceDemo();
weld.prepareWindow();
}
private void prepareWindow() {
f = new Frame();
f.setSize(400, 400);
f.addWindowListener(this); // I missed this in class, this is an important code, always rememeber to write this line, It registers the listener to the component or class itself.
f.setVisible(true);
}
@Override
public void windowOpened(WindowEvent e) {
}
@Override
public void windowClosing(WindowEvent e) {
f.setVisible(false);
f.dispose();
}
@Override
public void windowClosed(WindowEvent e) {
}
@Override
public void windowIconified(WindowEvent e) {
}
@Override
public void windowDeiconified(WindowEvent e) {
}
@Override
public void windowActivated(WindowEvent e) {
}
@Override
public void windowDeactivated(WindowEvent e) {
}
}