KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > swing > event > InternalFrameEvent


1 /*
2  * @(#)InternalFrameEvent.java 1.16 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7 package javax.swing.event;
8
9 import java.awt.AWTEvent JavaDoc;
10 import javax.swing.JInternalFrame JavaDoc;
11
12 /**
13  * An <code>AWTEvent</code> that adds support for
14  * <code>JInternalFrame</code> objects as the event source. This class has the
15  * same event types as <code>WindowEvent</code>,
16  * although different IDs are used.
17  * Help on handling internal frame events
18  * is in
19  * <a HREF="http://java.sun.com/docs/books/tutorial/uiswing/events/internalframelistener.html" target="_top">How to Write an Internal Frame Listener</a>,
20  * a section in <em>The Java Tutorial</em>.
21  * <p>
22  * <strong>Warning:</strong>
23  * Serialized objects of this class will not be compatible with
24  * future Swing releases. The current serialization support is
25  * appropriate for short term storage or RMI between applications running
26  * the same version of Swing. As of 1.4, support for long term storage
27  * of all JavaBeans<sup><font size="-2">TM</font></sup>
28  * has been added to the <code>java.beans</code> package.
29  * Please see {@link java.beans.XMLEncoder}.
30  *
31  * @see java.awt.event.WindowEvent
32  * @see java.awt.event.WindowListener
33  * @see JInternalFrame
34  * @see InternalFrameListener
35  *
36  * @version 1.16 12/19/03
37  * @author Thomas Ball
38  */

39 public class InternalFrameEvent extends AWTEvent JavaDoc {
40
41     /**
42      * The first number in the range of IDs used for internal frame events.
43      */

44     public static final int INTERNAL_FRAME_FIRST = 25549;
45
46     /**
47      * The last number in the range of IDs used for internal frame events.
48      */

49     public static final int INTERNAL_FRAME_LAST = 25555;
50
51     /**
52      * The "window opened" event. This event is delivered only
53      * the first time the internal frame is made visible.
54      *
55      * @see JInternalFrame#show
56      */

57     public static final int INTERNAL_FRAME_OPENED = INTERNAL_FRAME_FIRST;
58
59     /**
60      * The "window is closing" event. This event is delivered when
61      * the user attempts to close the internal frame, such as by
62      * clicking the internal frame's close button,
63      * or when a program attempts to close the internal frame
64      * by invoking the <code>setClosed</code> method.
65      *
66      * @see JInternalFrame#setDefaultCloseOperation
67      * @see JInternalFrame#doDefaultCloseAction
68      * @see JInternalFrame#setClosed
69      */

70     public static final int INTERNAL_FRAME_CLOSING = 1 + INTERNAL_FRAME_FIRST;
71
72     /**
73      * The "window closed" event. This event is delivered after
74      * the internal frame has been closed as the result of a call to
75      * the <code>setClosed</code> or
76      * <code>dispose</code> method.
77      *
78      * @see JInternalFrame#setClosed
79      * @see JInternalFrame#dispose
80      */

81     public static final int INTERNAL_FRAME_CLOSED = 2 + INTERNAL_FRAME_FIRST;
82
83     /**
84      * The "window iconified" event.
85      * This event indicates that the internal frame
86      * was shrunk down to a small icon.
87      *
88      * @see JInternalFrame#setIcon
89      */

90     public static final int INTERNAL_FRAME_ICONIFIED = 3 + INTERNAL_FRAME_FIRST;
91
92     /**
93      * The "window deiconified" event type. This event indicates that the
94      * internal frame has been restored to its normal size.
95      *
96      * @see JInternalFrame#setIcon
97      */

98     public static final int INTERNAL_FRAME_DEICONIFIED = 4 + INTERNAL_FRAME_FIRST;
99
100     /**
101      * The "window activated" event type. This event indicates that keystrokes
102      * and mouse clicks are directed towards this internal frame.
103      *
104      * @see JInternalFrame#show
105      * @see JInternalFrame#setSelected
106      */

107     public static final int INTERNAL_FRAME_ACTIVATED = 5 + INTERNAL_FRAME_FIRST;
108
109     /**
110      * The "window deactivated" event type. This event indicates that keystrokes
111      * and mouse clicks are no longer directed to the internal frame.
112      *
113      * @see JInternalFrame#setSelected
114      */

115     public static final int INTERNAL_FRAME_DEACTIVATED = 6 + INTERNAL_FRAME_FIRST;
116
117     /**
118      * Constructs an <code>InternalFrameEvent</code> object.
119      * @param source the <code>JInternalFrame</code> object that originated the event
120      * @param id an integer indicating the type of event
121      */

122     public InternalFrameEvent(JInternalFrame JavaDoc source, int id) {
123         super(source, id);
124     }
125
126     /**
127      * Returns a parameter string identifying this event.
128      * This method is useful for event logging and for debugging.
129      *
130      * @return a string identifying the event and its attributes
131      */

132     public String JavaDoc paramString() {
133         String JavaDoc typeStr;
134         switch(id) {
135           case INTERNAL_FRAME_OPENED:
136               typeStr = "INTERNAL_FRAME_OPENED";
137               break;
138           case INTERNAL_FRAME_CLOSING:
139               typeStr = "INTERNAL_FRAME_CLOSING";
140               break;
141           case INTERNAL_FRAME_CLOSED:
142               typeStr = "INTERNAL_FRAME_CLOSED";
143               break;
144           case INTERNAL_FRAME_ICONIFIED:
145               typeStr = "INTERNAL_FRAME_ICONIFIED";
146               break;
147           case INTERNAL_FRAME_DEICONIFIED:
148               typeStr = "INTERNAL_FRAME_DEICONIFIED";
149               break;
150           case INTERNAL_FRAME_ACTIVATED:
151               typeStr = "INTERNAL_FRAME_ACTIVATED";
152               break;
153           case INTERNAL_FRAME_DEACTIVATED:
154               typeStr = "INTERNAL_FRAME_DEACTIVATED";
155               break;
156           default:
157               typeStr = "unknown type";
158         }
159         return typeStr;
160     }
161
162
163     /**
164      * Returns the originator of the event.
165      *
166      * @return the <code>JInternalFrame</code> object that originated the event
167      * @since 1.3
168      */

169
170     public JInternalFrame JavaDoc getInternalFrame () {
171       return (source instanceof JInternalFrame JavaDoc)? (JInternalFrame JavaDoc)source : null;
172     }
173     
174
175 }
176
Popular Tags