/[classpath]/classpath/java/awt/event/WindowEvent.java
ViewVC logotype

Diff of /classpath/java/awt/event/WindowEvent.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by mark, Tue Jan 22 22:26:59 2002 UTC revision 1.6 by ericb, Sat Mar 30 12:02:30 2002 UTC
# Line 1  Line 1 
1  /* WindowEvent.java -- Window change event  /* WindowEvent.java -- window change event
2     Copyright (C) 1999 Free Software Foundation, Inc.     Copyright (C) 1999, 2002 Free Software Foundation, Inc.
3    
4  This file is part of GNU Classpath.  This file is part of GNU Classpath.
5    
# Line 41  package java.awt.event; Line 41  package java.awt.event;
41  import java.awt.Window;  import java.awt.Window;
42    
43  /**  /**
44    * This event is generated when there is a change in the window.   * This event is generated when there is a change in a window. This includes
45    *   * creation, closing, iconification, activation, and focus changes. There
46    * @author Aaron M. Renn (arenn@urbanophile.com)   * are three listeners, for three types of events: WindowListeners deal with
47    */   * the lifecycle of a window, WindowStateListeners deal with window state
48  public class WindowEvent extends ComponentEvent   * like maximization, and WindowFocusListeners deal with focus switching to
49               implements java.io.Serializable   * or from a window.
50  {   *
51     * @author Aaron M. Renn <arenn@urbanophile.com>
52  /*   * @see WindowAdapter
53   * Static Variables   * @see WindowListener
54     * @see WindowFocusListener
55     * @see WindowStateListener
56     * @since 1.1
57     * @status updated to 1.4
58   */   */
59    public class WindowEvent extends ComponentEvent
 /**  
   * This is the first id in the range of event ids used by this class.  
   */  
 public static final int WINDOW_FIRST = 200;  
   
 /**  
   * This is the last id in the range of event ids used by this class.  
   */  
 public static final int WINDOW_LAST = 206;  
   
 /**  
   * This is the id for a window that is opened.  
   */  
 public static final int WINDOW_OPENED = 200;  
   
 /**  
   * This is the id for a window that is closing.  
   */  
 public static final int WINDOW_CLOSING = 201;  
   
 /**  
   * This is the id for a window that is closed.  
   */  
 public static final int WINDOW_CLOSED = 202;  
   
 /**  
   * This is the id for a window that is iconified.  
   */  
 public static final int WINDOW_ICONIFIED = 203;  
   
 /**  
   * This is the id for a window that is de-iconified.  
   */  
 public static final int WINDOW_DEICONIFIED = 204;  
   
 /**  
   * This is the id for a window that is activated.  
   */  
 public static final int WINDOW_ACTIVATED = 205;  
   
 /**  
   * This is the id for a window that is de-activated.  
   */  
 public static final int WINDOW_DEACTIVATED = 206;  
   
 /*************************************************************************/  
   
 /*  
  * Constructors  
  */  
   
 /**  
   * Initializes a new instance of <code>WindowEvent</code> with the  
   * specified source and id.  
   *  
   * @param source The window that generated this event.  
   * @param id The event id.  
   */  
 public  
 WindowEvent(Window source, int id)  
60  {  {
61    super(source, id);    /**
62  }     * Compatible with JDK 1.1+.
63       */
64  /*************************************************************************/    private static final long serialVersionUID = -1567959133147912127L;
65    
66  /*    /** This is the first id in the range of event ids used by this class. */
67   * Instance Methods    public static final int WINDOW_FIRST = 200;
68   */  
69      /** This is the id for a window that is opened. */
70  /**    public static final int WINDOW_OPENED = 200;
71    * Returns the event source as a <code>Window</code>.  
72    *    /** This is the id for a window that is about to close. */
73    * @return The event source as a <code>Window</code>.    public static final int WINDOW_CLOSING = 201;
74    */  
75  public Window    /** This is the id for a window that finished closing. */
76  getWindow()    public static final int WINDOW_CLOSED = 202;
77  {  
78    return((Window)getSource());    /** This is the id for a window that is iconified. */
79  }    public static final int WINDOW_ICONIFIED = 203;
80    
81  /*************************************************************************/    /** This is the id for a window that is de-iconified. */
82      public static final int WINDOW_DEICONIFIED = 204;
83  /**  
84    * Returns a string that identifies this event.    /** This is the id for a window that is activated. */
85      public static final int WINDOW_ACTIVATED = 205;
86    
87      /** This is the id for a window that is de-activated. */
88      public static final int WINDOW_DEACTIVATED = 206;
89    
90      /**
91       * This is the id for a window becoming the focused window.
92       *
93       * @since 1.4
94       */
95      public static final int WINDOW_GAINED_FOCUS = 207;
96    
97      /**
98       * This is the id for a window losing all focus.
99       *
100       * @since 1.4
101       */
102      public static final int WINDOW_LOST_FOCUS = 208;
103    
104      /**
105       * This is the id for a window state change, such as maximization.
106       *
107       * @since 1.4
108       */
109      public static final int WINDOW_STATE_CHANGED = 209;
110    
111      /** This is the last id in the range of event ids used by this class. */
112      public static final int WINDOW_LAST = 207;
113    
114      /**
115       * The other Window involved in a focus or activation change. For
116       * WINDOW_ACTIVATED and WINDOW_GAINED_FOCUS events, this is the window that
117       * lost focus; for WINDOW_DEACTIVATED and WINDOW_LOST_FOCUS, this is the
118       * window that stole focus; and for other events (or when native
119       * implementation does not have the data available), this is null.
120       *
121       * @see #getOppositeWindow()
122       * @serial the opposite window, or null
123       * @since 1.4
124       */
125      private final Window opposite;
126    
127      /**
128       * The former state of the window.
129       *
130       * @serial bitmask of the old window state
131       * @since 1.4
132       */
133      private final int oldState;
134    
135      /**
136       * The present state of the window.
137       *
138       * @serial bitmask of the new window state
139       * @since 1.4
140       */
141      private final int newState;
142    
143      /**
144       * Initializes a new instance of <code>WindowEvent</code> with the specified
145       * parameters. Note that an invalid id leads to unspecified results.
146       *
147       * @param source the window that generated this event
148       * @param id the event id
149       * @param opposite the window that received the opposite event, or null
150       * @param oldState the previous state of this window
151       * @param newState the new state of this window
152       * @throws IllegalArgumentException if source is null
153       * @since 1.4
154       */
155      public WindowEvent(Window source, int id, Window opposite,
156                         int oldState, int newState)
157      {
158        super(source, id);
159        this.opposite = opposite;
160        this.oldState = oldState;
161        this.newState = newState;
162      }
163    
164      /**
165       * Initializes a new instance of <code>WindowEvent</code> with the specified
166       * parameters. Note that an invalid id leads to unspecified results.
167       *
168       * @param source the window that generated this event
169       * @param id the event id
170       * @param opposite the window that received the opposite event, or null
171       * @throws IllegalArgumentException if source is null
172       * @since 1.4
173       */
174      public WindowEvent(Window source, int id, Window opposite)
175      {
176        this(source, id, opposite, 0, 0);
177      }
178    
179      /**
180       * Initializes a new instance of <code>WindowEvent</code> with the specified
181       * parameters. Note that an invalid id leads to unspecified results.
182       *
183       * @param source the window that generated this event
184       * @param id the event id
185       * @param oldState the previous state of this window
186       * @param newState the new state of this window
187       * @throws IllegalArgumentException if source is null
188       * @since 1.4
189       */
190      public WindowEvent(Window source, int id, int oldState, int newState)
191      {
192        this(source, id, null, oldState, newState);
193      }
194    
195      /**
196       * Initializes a new instance of <code>WindowEvent</code> with the specified
197       * parameters. Note that an invalid id leads to unspecified results.
198       *
199       * @param source the window that generated this event
200       * @param id the event id
201       * @throws IllegalArgumentException if source is null
202       */
203      public WindowEvent(Window source, int id)
204      {
205        this(source, id, null, 0, 0);
206      }
207    
208      /**
209       * Returns the event source as a <code>Window</code>. If the source has
210       * subsequently been modified to a non-Window, this returns null.
211    *    *
212    * @return A string that identifies this event.    * @return the event source as a <code>Window</code>
213    */    */
214  public String    public Window getWindow()
215  paramString()    {
216  {      return source instanceof Window ? (Window) source : null;
217    return(getClass().getName() + " source=" + getSource() + " id=" + getID());    }
218  }  
219      /**
220       * Returns the opposite window if this window was involved in an activation
221       * or focus change. For WINDOW_ACTIVATED and WINDOW_GAINED_FOCUS events,
222       * this is the window that lost focus; for WINDOW_DEACTIVATED and
223       * WINDOW_LOST_FOCUS, this is the window that stole focus; and for other
224       * events (or when native implementation does not have the data available),
225       * this is null.
226       *
227       * @return the opposite window, or null
228       * @since 1.4
229       */
230      public Window getOppositeWindow()
231      {
232        return opposite;
233      }
234    
235      /**
236       * Returns the state of this window before the event. This is the bitwise
237       * or of fields in Frame: NORMAL, ICONIFIED, MAXIMIZED_HORIZ, MAXIMIZED_VERT,
238       * and MAXIMIZED_BOTH.
239       *
240       * @return the former state
241       * @see Frame#getExtendedState()
242       * @since 1.4
243       */
244      public int getOldState()
245      {
246        return oldState;
247      }
248    
249      /**
250       * Returns the state of this window after the event. This is the bitwise
251       * or of fields in Frame: NORMAL, ICONIFIED, MAXIMIZED_HORIZ, MAXIMIZED_VERT,
252       * and MAXIMIZED_BOTH.
253       *
254       * @return the updated state
255       * @see Frame#getExtendedState()
256       * @since 1.4
257       */
258      public int getNewState()
259      {
260        return newState;
261      }
262    
263      /**
264       * Returns a string that identifies this event. This is formatted as the
265       * field name of the id, followed by the opposite window, old state, and
266       * new state.
267       *
268       * @return a string that identifies this event
269       */
270      public String paramString()
271      {
272        StringBuffer s = new StringBuffer();
273        switch (id)
274          {
275          case WINDOW_OPENED:
276            s.append("WINDOW_OPENED,opposite=");
277            break;
278          case WINDOW_CLOSING:
279            s.append("WINDOW_CLOSING,opposite=");
280            break;
281          case WINDOW_CLOSED:
282            s.append("WINDOW_CLOSED,opposite=");
283            break;
284          case WINDOW_ICONIFIED:
285            s.append("WINDOW_ICONIFIED,opposite=");
286            break;
287          case WINDOW_DEICONIFIED:
288            s.append("WINDOW_DEICONIFIED,opposite=");
289            break;
290          case WINDOW_ACTIVATED:
291            s.append("WINDOW_ACTIVATED,opposite=");
292            break;
293          case WINDOW_DEACTIVATED:
294            s.append("WINDOW_DEACTIVATED,opposite=");
295            break;
296          case WINDOW_GAINED_FOCUS:
297            s.append("WINDOW_GAINED_FOCUS,opposite=");
298            break;
299          case WINDOW_LOST_FOCUS:
300            s.append("WINDOW_LOST_FOCUS,opposite=");
301            break;
302          case WINDOW_STATE_CHANGED:
303            s.append("WINDOW_STATE_CHANGED,opposite=");
304            break;
305          default:
306            s.append("unknown type,opposite=");
307          }
308        return s.append(opposite).append(",oldState=").append(oldState)
309          .append(",newState=").append(newState).toString();
310      }
311  } // class WindowEvent  } // class WindowEvent
   

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26