/Users/lyon/j4p/src/gui/JClosableFrame.java
|
1 package gui;
2
3 import javax.swing.*;
4 import java.awt.*;
5 import java.awt.event.WindowEvent;
6 import java.awt.event.WindowListener;
7
8 public class JClosableFrame
9 extends JFrame implements WindowListener {
10 // constructor needed to pass
11 // window title to class Frame
12 public JClosableFrame(String name) {
13 // call java.awt.Frame(String) constructor
14 super(name);
15 init();
16 }
17
18 public JClosableFrame() {
19 init();
20 }
21
22 private void init() {
23 setBackground(Color.white);
24 addWindowListener(this);
25 }
26
27
28 public static void main(String args[]) {
29 JClosableFrame cf = new JClosableFrame("Closable Frame");
30 cf.setSize(200, 200);
31 cf.show();
32 }
33
34
35 public void windowClosing(WindowEvent e) {
36 setVisible(true);
37 dispose();
38 }
39
40 public void windowClosed(WindowEvent e) {
41 };
42 public void windowDeiconified(WindowEvent e) {
43 };
44 public void windowIconified(WindowEvent e) {
45 };
46 public void windowActivated(WindowEvent e) {
47 };
48 public void windowDeactivated(WindowEvent e) {
49 };
50 public void windowOpened(WindowEvent e) {
51 };
52 }