KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > swingwt > awt > event > WindowEvent


1 /*
2    SwingWT
3    Copyright(c)2003-2004, R. Rawson-Tetley
4
5    For more information on distributing and using this program, please
6    see the accompanying "COPYING" file.
7
8    Contact me by electronic mail: bobintetley@users.sourceforge.net
9
10    $Log: WindowEvent.java,v $
11    Revision 1.3 2004/05/06 12:35:21 bobintetley
12    Parity with Swing constants for Binary Compatibility + fixes to JDesktopPane
13
14    Revision 1.2 2003/12/14 09:13:38 bobintetley
15    Added CVS log to source headers
16
17 */

18 package swingwt.awt.event;
19
20 import swingwt.awt.*;
21
22 public class WindowEvent extends AWTEvent {
23     
24     public static final int WINDOW_FIRST = 200;
25     public static final int WINDOW_OPENED = 0 + WINDOW_FIRST;
26     public static final int WINDOW_CLOSING = 1 + WINDOW_FIRST;
27     public static final int WINDOW_CLOSED = 2 + WINDOW_FIRST;
28     public static final int WINDOW_ICONIFIED = 3 + WINDOW_FIRST;
29     public static final int WINDOW_DEICONIFIED = 4 + WINDOW_FIRST;
30     public static final int WINDOW_ACTIVATED = 5 + WINDOW_FIRST;
31     public static final int WINDOW_DEACTIVATED = 6 + WINDOW_FIRST;
32     public static final int WINDOW_GAINED_FOCUS = 7 + WINDOW_FIRST;
33     public static final int WINDOW_LOST_FOCUS = 8 + WINDOW_FIRST;
34     public static final int WINDOW_STATE_CHANGED = 9 + WINDOW_FIRST;
35     
36     protected Window opposite;
37     protected int oldState;
38     protected int newState;
39
40     public WindowEvent(Window source, int id, Window opposite,
41                int oldState, int newState) {
42         super(source, id);
43     this.opposite = opposite;
44     this.oldState = oldState;
45     this.newState = newState;
46     }
47
48     public WindowEvent(Window source, int id, Window opposite) {
49         this(source, id, opposite, 0, 0);
50     }
51     public WindowEvent(Window source, int id) {
52         this(source, id, null, 0, 0);
53     }
54     public Window getWindow() {
55         return (source instanceof Window) ? (Window)source : null;
56     }
57     public Window getOppositeWindow() {
58         return opposite;
59     }
60     public int getOldState() {
61     return oldState;
62     }
63     public int getNewState() {
64     return newState;
65     }
66     public String JavaDoc paramString() {
67         String JavaDoc typeStr;
68         switch(this.getID()) {
69           case WINDOW_OPENED:
70               typeStr = "WINDOW_OPENED";
71               break;
72           case WINDOW_CLOSING:
73               typeStr = "WINDOW_CLOSING";
74               break;
75           case WINDOW_CLOSED:
76               typeStr = "WINDOW_CLOSED";
77               break;
78           case WINDOW_ICONIFIED:
79               typeStr = "WINDOW_ICONIFIED";
80               break;
81           case WINDOW_DEICONIFIED:
82               typeStr = "WINDOW_DEICONIFIED";
83               break;
84           case WINDOW_ACTIVATED:
85               typeStr = "WINDOW_ACTIVATED";
86               break;
87           case WINDOW_DEACTIVATED:
88               typeStr = "WINDOW_DEACTIVATED";
89               break;
90       case WINDOW_GAINED_FOCUS:
91           typeStr = "WINDOW_GAINED_FOCUS";
92           break;
93       case WINDOW_LOST_FOCUS:
94           typeStr = "WINDOW_LOST_FOCUS";
95           break;
96       case WINDOW_STATE_CHANGED:
97           typeStr = "WINDOW_STATE_CHANGED";
98           break;
99           default:
100               typeStr = "unknown type";
101         }
102     return typeStr + ",opposite=" + getOppositeWindow()
103         + ",oldState=" + oldState + ",newState=" + newState;
104     }
105 }
106
Popular Tags