001 /*
002 * Copyright 1998-2001 Sun Microsystems, Inc. All Rights Reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation. Sun designates this
008 * particular file as subject to the "Classpath" exception as provided
009 * by Sun in the LICENSE file that accompanied this code.
010 *
011 * This code is distributed in the hope that it will be useful, but WITHOUT
012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014 * version 2 for more details (a copy is included in the LICENSE file that
015 * accompanied this code).
016 *
017 * You should have received a copy of the GNU General Public License version
018 * 2 along with this work; if not, write to the Free Software Foundation,
019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020 *
021 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022 * CA 95054 USA or visit www.sun.com if you need additional information or
023 * have any questions.
024 */
025 package javax.swing.event;
026
027 import java.awt.AWTEvent;
028 import javax.swing.JInternalFrame;
029
030 /**
031 * An <code>AWTEvent</code> that adds support for
032 * <code>JInternalFrame</code> objects as the event source. This class has the
033 * same event types as <code>WindowEvent</code>,
034 * although different IDs are used.
035 * Help on handling internal frame events
036 * is in
037 * <a href="http://java.sun.com/docs/books/tutorial/uiswing/events/internalframelistener.html" target="_top">How to Write an Internal Frame Listener</a>,
038 * a section in <em>The Java Tutorial</em>.
039 * <p>
040 * <strong>Warning:</strong>
041 * Serialized objects of this class will not be compatible with
042 * future Swing releases. The current serialization support is
043 * appropriate for short term storage or RMI between applications running
044 * the same version of Swing. As of 1.4, support for long term storage
045 * of all JavaBeans<sup><font size="-2">TM</font></sup>
046 * has been added to the <code>java.beans</code> package.
047 * Please see {@link java.beans.XMLEncoder}.
048 *
049 * @see java.awt.event.WindowEvent
050 * @see java.awt.event.WindowListener
051 * @see JInternalFrame
052 * @see InternalFrameListener
053 *
054 * @version 1.23 05/05/07
055 * @author Thomas Ball
056 */
057 public class InternalFrameEvent extends AWTEvent {
058
059 /**
060 * The first number in the range of IDs used for internal frame events.
061 */
062 public static final int INTERNAL_FRAME_FIRST = 25549;
063
064 /**
065 * The last number in the range of IDs used for internal frame events.
066 */
067 public static final int INTERNAL_FRAME_LAST = 25555;
068
069 /**
070 * The "window opened" event. This event is delivered only
071 * the first time the internal frame is made visible.
072 *
073 * @see JInternalFrame#show
074 */
075 public static final int INTERNAL_FRAME_OPENED = INTERNAL_FRAME_FIRST;
076
077 /**
078 * The "window is closing" event. This event is delivered when
079 * the user attempts to close the internal frame, such as by
080 * clicking the internal frame's close button,
081 * or when a program attempts to close the internal frame
082 * by invoking the <code>setClosed</code> method.
083 *
084 * @see JInternalFrame#setDefaultCloseOperation
085 * @see JInternalFrame#doDefaultCloseAction
086 * @see JInternalFrame#setClosed
087 */
088 public static final int INTERNAL_FRAME_CLOSING = 1 + INTERNAL_FRAME_FIRST;
089
090 /**
091 * The "window closed" event. This event is delivered after
092 * the internal frame has been closed as the result of a call to
093 * the <code>setClosed</code> or
094 * <code>dispose</code> method.
095 *
096 * @see JInternalFrame#setClosed
097 * @see JInternalFrame#dispose
098 */
099 public static final int INTERNAL_FRAME_CLOSED = 2 + INTERNAL_FRAME_FIRST;
100
101 /**
102 * The "window iconified" event.
103 * This event indicates that the internal frame
104 * was shrunk down to a small icon.
105 *
106 * @see JInternalFrame#setIcon
107 */
108 public static final int INTERNAL_FRAME_ICONIFIED = 3 + INTERNAL_FRAME_FIRST;
109
110 /**
111 * The "window deiconified" event type. This event indicates that the
112 * internal frame has been restored to its normal size.
113 *
114 * @see JInternalFrame#setIcon
115 */
116 public static final int INTERNAL_FRAME_DEICONIFIED = 4 + INTERNAL_FRAME_FIRST;
117
118 /**
119 * The "window activated" event type. This event indicates that keystrokes
120 * and mouse clicks are directed towards this internal frame.
121 *
122 * @see JInternalFrame#show
123 * @see JInternalFrame#setSelected
124 */
125 public static final int INTERNAL_FRAME_ACTIVATED = 5 + INTERNAL_FRAME_FIRST;
126
127 /**
128 * The "window deactivated" event type. This event indicates that keystrokes
129 * and mouse clicks are no longer directed to the internal frame.
130 *
131 * @see JInternalFrame#setSelected
132 */
133 public static final int INTERNAL_FRAME_DEACTIVATED = 6 + INTERNAL_FRAME_FIRST;
134
135 /**
136 * Constructs an <code>InternalFrameEvent</code> object.
137 * @param source the <code>JInternalFrame</code> object that originated the event
138 * @param id an integer indicating the type of event
139 */
140 public InternalFrameEvent(JInternalFrame source, int id) {
141 super (source, id);
142 }
143
144 /**
145 * Returns a parameter string identifying this event.
146 * This method is useful for event logging and for debugging.
147 *
148 * @return a string identifying the event and its attributes
149 */
150 public String paramString() {
151 String typeStr;
152 switch (id) {
153 case INTERNAL_FRAME_OPENED:
154 typeStr = "INTERNAL_FRAME_OPENED";
155 break;
156 case INTERNAL_FRAME_CLOSING:
157 typeStr = "INTERNAL_FRAME_CLOSING";
158 break;
159 case INTERNAL_FRAME_CLOSED:
160 typeStr = "INTERNAL_FRAME_CLOSED";
161 break;
162 case INTERNAL_FRAME_ICONIFIED:
163 typeStr = "INTERNAL_FRAME_ICONIFIED";
164 break;
165 case INTERNAL_FRAME_DEICONIFIED:
166 typeStr = "INTERNAL_FRAME_DEICONIFIED";
167 break;
168 case INTERNAL_FRAME_ACTIVATED:
169 typeStr = "INTERNAL_FRAME_ACTIVATED";
170 break;
171 case INTERNAL_FRAME_DEACTIVATED:
172 typeStr = "INTERNAL_FRAME_DEACTIVATED";
173 break;
174 default:
175 typeStr = "unknown type";
176 }
177 return typeStr;
178 }
179
180 /**
181 * Returns the originator of the event.
182 *
183 * @return the <code>JInternalFrame</code> object that originated the event
184 * @since 1.3
185 */
186
187 public JInternalFrame getInternalFrame() {
188 return (source instanceof JInternalFrame) ? (JInternalFrame) source
189 : null;
190 }
191
192 }
|