forked from mohammedabdulbari/Java-SE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AdapterDemo.java
49 lines (44 loc) · 1.01 KB
/
AdapterDemo.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
package adapterdemo;
import java.awt.*;
import java.awt.event.*;
//Outer class for handling Window Event
/*
class MyWindowAdapter extends WindowAdapter
{
public void windowClosing(WindowEvent we)
{
System.exit(0);
}
}*/
class MyFrame extends Frame
{
MyFrame()
{
super("Adapter Demo");
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent we)
{
System.exit(0);
}
});
// use this for handling event using inner class
// addWindowLister(new MyWindowAdapter());
}
// Inner class used for handling event
/* class MyWindowAdapter extends WindowAdapter
{
public void windowClosing(WindowEvent we)
{
System.exit(0);
}
}*/
}
public class AdapterDemo
{
public static void main(String[] args)
{
MyFrame f=new MyFrame();
f.setSize(500,500);
f.setVisible(true);
}
}