001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: /**
018: * @author Michael Danilov
019: * @version $Revision$
020: */package java.awt.event;
021:
022: import java.awt.Window;
023: import java.awt.Frame;
024:
025: public class WindowEvent extends ComponentEvent {
026:
027: private static final long serialVersionUID = -1567959133147912127L;
028:
029: public static final int WINDOW_FIRST = 200;
030:
031: public static final int WINDOW_OPENED = 200;
032:
033: public static final int WINDOW_CLOSING = 201;
034:
035: public static final int WINDOW_CLOSED = 202;
036:
037: public static final int WINDOW_ICONIFIED = 203;
038:
039: public static final int WINDOW_DEICONIFIED = 204;
040:
041: public static final int WINDOW_ACTIVATED = 205;
042:
043: public static final int WINDOW_DEACTIVATED = 206;
044:
045: public static final int WINDOW_GAINED_FOCUS = 207;
046:
047: public static final int WINDOW_LOST_FOCUS = 208;
048:
049: public static final int WINDOW_STATE_CHANGED = 209;
050:
051: public static final int WINDOW_LAST = 209;
052:
053: private Window oppositeWindow;
054: private int oldState;
055: private int newState;
056:
057: public WindowEvent(Window source, int id) {
058: this (source, id, null);
059: }
060:
061: public WindowEvent(Window source, int id, Window opposite) {
062: this (source, id, opposite, Frame.NORMAL, Frame.NORMAL);
063: }
064:
065: public WindowEvent(Window source, int id, int oldState, int newState) {
066: this (source, id, null, oldState, newState);
067: }
068:
069: public WindowEvent(Window source, int id, Window opposite,
070: int oldState, int newState) {
071: super (source, id);
072:
073: oppositeWindow = opposite;
074: this .oldState = oldState;
075: this .newState = newState;
076: }
077:
078: public int getNewState() {
079: return newState;
080: }
081:
082: public int getOldState() {
083: return oldState;
084: }
085:
086: public Window getOppositeWindow() {
087: return oppositeWindow;
088: }
089:
090: public Window getWindow() {
091: return (Window) source;
092: }
093:
094: @Override
095: public String paramString() {
096: /* The format is based on 1.5 release behavior
097: * which can be revealed by the following code:
098: *
099: * WindowEvent e = new WindowEvent(new Frame(),
100: * WindowEvent.WINDOW_OPENED);
101: * System.out.println(e);
102: */
103:
104: String typeString = null;
105:
106: switch (id) {
107: case WINDOW_OPENED:
108: typeString = "WINDOW_OPENED"; //$NON-NLS-1$
109: break;
110: case WINDOW_CLOSING:
111: typeString = "WINDOW_CLOSING"; //$NON-NLS-1$
112: break;
113: case WINDOW_CLOSED:
114: typeString = "WINDOW_CLOSED"; //$NON-NLS-1$
115: break;
116: case WINDOW_ICONIFIED:
117: typeString = "WINDOW_ICONIFIED"; //$NON-NLS-1$
118: break;
119: case WINDOW_DEICONIFIED:
120: typeString = "WINDOW_DEICONIFIED"; //$NON-NLS-1$
121: break;
122: case WINDOW_ACTIVATED:
123: typeString = "WINDOW_ACTIVATED"; //$NON-NLS-1$
124: break;
125: case WINDOW_DEACTIVATED:
126: typeString = "WINDOW_DEACTIVATED"; //$NON-NLS-1$
127: break;
128: case WINDOW_GAINED_FOCUS:
129: typeString = "WINDOW_GAINED_FOCUS"; //$NON-NLS-1$
130: break;
131: case WINDOW_LOST_FOCUS:
132: typeString = "WINDOW_LOST_FOCUS"; //$NON-NLS-1$
133: break;
134: case WINDOW_STATE_CHANGED:
135: typeString = "WINDOW_STATE_CHANGED"; //$NON-NLS-1$
136: break;
137: default:
138: typeString = "unknown type"; //$NON-NLS-1$
139: }
140:
141: return typeString + ",opposite=" + oppositeWindow + //$NON-NLS-1$
142: ",oldState=" + oldState + ",newState=" + newState; //$NON-NLS-1$ //$NON-NLS-2$
143: }
144:
145: }
|