WindowEvent.java revision 2362
2362N/A * Copyright (c) 1996, 2008, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * A low-level event that indicates that a window has changed its status. This 0N/A * low-level event is generated by a Window object when it is opened, closed, 0N/A * activated, deactivated, iconified, or deiconified, or when focus is 0N/A * transfered into or out of the Window. 0N/A * The event is passed to every <code>WindowListener</code> 0N/A * or <code>WindowAdapter</code> object which registered to receive such 0N/A * events using the window's <code>addWindowListener</code> method. 0N/A * (<code>WindowAdapter</code> objects implement the 0N/A * <code>WindowListener</code> interface.) Each such listener object 0N/A * gets this <code>WindowEvent</code> when the event occurs. 217N/A * An unspecified behavior will be caused if the {@code id} parameter 217N/A * of any particular {@code WindowEvent} instance is not 217N/A * in the range from {@code WINDOW_FIRST} to {@code WINDOW_LAST}. 0N/A * @author Carl Quinn 0N/A * @author Amy Fowler 0N/A * @see WindowAdapter 0N/A * @see WindowListener 0N/A * The first number in the range of ids used for window events. 0N/A * The window opened event. This event is delivered only 0N/A * the first time a window is made visible. 0N/A * The "window is closing" event. This event is delivered when 0N/A * the user attempts to close the window from the window's system menu. 0N/A * If the program does not explicitly hide or dispose the window 0N/A * while processing this event, the window close operation will be 0N/A * The window closed event. This event is delivered after 0N/A * the window has been closed as the result of a call to dispose. 0N/A * The window iconified event. This event is delivered when 0N/A * the window has been changed from a normal to a minimized state. 0N/A * For many platforms, a minimized window is displayed as 0N/A * the icon specified in the window's iconImage property. 0N/A * @see java.awt.Frame#setIconImage 0N/A * The window deiconified event type. This event is delivered when 0N/A * the window has been changed from a minimized to a normal state. 0N/A * The window-activated event type. This event is delivered when the Window 0N/A * becomes the active Window. Only a Frame or a Dialog can be the active 0N/A * Window. The native windowing system may denote the active Window or its 0N/A * children with special decorations, such as a highlighted title bar. The 0N/A * active Window is always either the focused Window, or the first Frame or 0N/A * Dialog that is an owner of the focused Window. 0N/A * The window-deactivated event type. This event is delivered when the 0N/A * Window is no longer the active Window. Only a Frame or a Dialog can be 0N/A * the active Window. The native windowing system may denote the active 0N/A * Window or its children with special decorations, such as a highlighted 0N/A * title bar. The active Window is always either the focused Window, or the 0N/A * first Frame or Dialog that is an owner of the focused Window. 0N/A * The window-gained-focus event type. This event is delivered when the 0N/A * Window becomes the focused Window, which means that the Window, or one 0N/A * of its subcomponents, will receive keyboard events. 0N/A * The window-lost-focus event type. This event is delivered when a Window 0N/A * is no longer the focused Window, which means keyboard events will no 0N/A * longer be delivered to the Window or any of its subcomponents. 0N/A * The window-state-changed event type. This event is delivered 0N/A * when a Window's state is changed by virtue of it being 0N/A * iconified, maximized etc. 0N/A * The last number in the range of ids used for window events. 0N/A * The other Window involved in this focus or activation change. For a 0N/A * WINDOW_ACTIVATED or WINDOW_GAINED_FOCUS event, this is the Window that 0N/A * lost activation or focus. For a WINDOW_DEACTIVATED or WINDOW_LOST_FOCUS 0N/A * event, this is the Window that gained activation or focus. For any other 0N/A * type of WindowEvent, or if the focus or activation change occurs with a 0N/A * native application, a Java application in a different VM, or with no 0N/A * other Window, null is returned. 0N/A * @see #getOppositeWindow 0N/A * JDK 1.1 serialVersionUID 0N/A * Constructs a <code>WindowEvent</code> object. 217N/A * <p>This method throws an 0N/A * <code>IllegalArgumentException</code> if <code>source</code> 0N/A * is <code>null</code>. 217N/A * @param source The <code>Window</code> object 0N/A * that originated the event 217N/A * @param id An integer indicating the type of event. 217N/A * For information on allowable values, see 217N/A * the class description for {@link WindowEvent} 217N/A * @param opposite The other window involved in the focus or activation 0N/A * change, or <code>null</code> 217N/A * @param oldState Previous state of the window for window state change event. 217N/A * See {@code #getOldState()} for allowable values 217N/A * @param newState New state of the window for window state change event. 217N/A * See {@code #getNewState()} for allowable values 0N/A * @throws IllegalArgumentException if <code>source</code> is null 217N/A * @see #getOppositeWindow() 0N/A * Constructs a <code>WindowEvent</code> object with the 0N/A * specified opposite <code>Window</code>. The opposite 0N/A * <code>Window</code> is the other <code>Window</code> 0N/A * involved in this focus or activation change. 0N/A * For a <code>WINDOW_ACTIVATED</code> or 0N/A * <code>WINDOW_GAINED_FOCUS</code> event, this is the 0N/A * <code>Window</code> that lost activation or focus. 0N/A * For a <code>WINDOW_DEACTIVATED</code> or 0N/A * <code>WINDOW_LOST_FOCUS</code> event, this is the 0N/A * <code>Window</code> that gained activation or focus. 0N/A * If this focus change occurs with a native application, with a 0N/A * Java application in a different VM, or with no other 0N/A * <code>Window</code>, then the opposite Window is <code>null</code>. 217N/A * <p>This method throws an 0N/A * <code>IllegalArgumentException</code> if <code>source</code> 0N/A * is <code>null</code>. 217N/A * @param source The <code>Window</code> object that 0N/A * originated the event 217N/A * @param id An integer indicating the type of event. 217N/A * For information on allowable values, see 217N/A * the class description for {@link WindowEvent}. 217N/A * It is expected that this constructor will not 217N/A * be used for other then 217N/A * {@code WINDOW_ACTIVATED},{@code WINDOW_DEACTIVATED}, 217N/A * {@code WINDOW_GAINED_FOCUS}, or {@code WINDOW_LOST_FOCUS}. 217N/A * {@code WindowEvent} types, 217N/A * because the opposite <code>Window</code> of other event types 217N/A * will always be {@code null}. 217N/A * @param opposite The other <code>Window</code> involved in the 0N/A * focus or activation change, or <code>null</code> 0N/A * @throws IllegalArgumentException if <code>source</code> is null 217N/A * @see #getOppositeWindow() 0N/A * Constructs a <code>WindowEvent</code> object with the specified 0N/A * previous and new window states. 217N/A * <p>This method throws an 0N/A * <code>IllegalArgumentException</code> if <code>source</code> 0N/A * is <code>null</code>. 217N/A * @param source The <code>Window</code> object 0N/A * that originated the event 217N/A * @param id An integer indicating the type of event. 217N/A * For information on allowable values, see 217N/A * the class description for {@link WindowEvent}. 0N/A * It is expected that this constructor will not 217N/A * be used for other then 217N/A * {@code WINDOW_STATE_CHANGED} 0N/A * types, because the previous and new window 0N/A * states are meaningless for other event types. 217N/A * @param oldState An integer representing the previous window state. 217N/A * See {@code #getOldState()} for allowable values 217N/A * @param newState An integer representing the new window state. 217N/A * See {@code #getNewState()} for allowable values 0N/A * @throws IllegalArgumentException if <code>source</code> is null 0N/A * Constructs a <code>WindowEvent</code> object. 217N/A * <p>This method throws an 0N/A * <code>IllegalArgumentException</code> if <code>source</code> 0N/A * is <code>null</code>. 217N/A * @param source The <code>Window</code> object that originated the event 217N/A * @param id An integer indicating the type of event. 217N/A * For information on allowable values, see 217N/A * the class description for {@link WindowEvent}. 0N/A * @throws IllegalArgumentException if <code>source</code> is null 0N/A * Returns the originator of the event. 0N/A * @return the Window object that originated the event 0N/A * Returns the other Window involved in this focus or activation change. 0N/A * For a WINDOW_ACTIVATED or WINDOW_GAINED_FOCUS event, this is the Window 0N/A * that lost activation or focus. For a WINDOW_DEACTIVATED or 0N/A * WINDOW_LOST_FOCUS event, this is the Window that gained activation or 0N/A * focus. For any other type of WindowEvent, or if the focus or activation 0N/A * change occurs with a native application, with a Java application in a 0N/A * different VM or context, or with no other Window, null is returned. 0N/A * @return the other Window involved in the focus or activation change, or 0N/A * For <code>WINDOW_STATE_CHANGED</code> events returns the 0N/A * previous state of the window. The state is 0N/A * represented as a bitwise mask. 0N/A * <li><code>NORMAL</code> 0N/A * <br>Indicates that no state bits are set. 0N/A * <li><code>ICONIFIED</code> 0N/A * <li><code>MAXIMIZED_HORIZ</code> 0N/A * <li><code>MAXIMIZED_VERT</code> 0N/A * <li><code>MAXIMIZED_BOTH</code> 0N/A * <br>Concatenates <code>MAXIMIZED_HORIZ</code> 0N/A * and <code>MAXIMIZED_VERT</code>. 0N/A * @return a bitwise mask of the previous window state 0N/A * @see java.awt.Frame#getExtendedState() 0N/A * For <code>WINDOW_STATE_CHANGED</code> events returns the 0N/A * new state of the window. The state is 0N/A * represented as a bitwise mask. 0N/A * <li><code>NORMAL</code> 0N/A * <br>Indicates that no state bits are set. 0N/A * <li><code>ICONIFIED</code> 0N/A * <li><code>MAXIMIZED_HORIZ</code> 0N/A * <li><code>MAXIMIZED_VERT</code> 0N/A * <li><code>MAXIMIZED_BOTH</code> 0N/A * <br>Concatenates <code>MAXIMIZED_HORIZ</code> 0N/A * and <code>MAXIMIZED_VERT</code>. 0N/A * @return a bitwise mask of the new window state 0N/A * @see java.awt.Frame#getExtendedState() 0N/A * Returns a parameter string identifying this event. 0N/A * This method is useful for event-logging and for debugging. 0N/A * @return a string identifying the event and its attributes