|
| 1 | +/* |
| 2 | + * Copyright (c) 1998, 2001, Oracle and/or its affiliates. All rights reserved. |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 4 | + * |
| 5 | + * This code is free software; you can redistribute it and/or modify it |
| 6 | + * under the terms of the GNU General Public License version 2 only, as |
| 7 | + * published by the Free Software Foundation. Oracle designates this |
| 8 | + * particular file as subject to the "Classpath" exception as provided |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. |
| 10 | + * |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that |
| 15 | + * accompanied this code). |
| 16 | + * |
| 17 | + * You should have received a copy of the GNU General Public License version |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 20 | + * |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
| 22 | + * or visit www.oracle.com if you need additional information or have any |
| 23 | + * questions. |
| 24 | + */ |
| 25 | +package javax.swing.event; |
| 26 | + |
| 27 | +import java.awt.AWTEvent; |
| 28 | +import javax.swing.JInternalFrame; |
| 29 | + |
| 30 | +/** |
| 31 | + * An <code>AWTEvent</code> that adds support for |
| 32 | + * <code>JInternalFrame</code> objects as the event source. This class has the |
| 33 | + * same event types as <code>WindowEvent</code>, |
| 34 | + * although different IDs are used. |
| 35 | + * Help on handling internal frame events |
| 36 | + * is in |
| 37 | + * <a href="http://java.sun.com/docs/books/tutorial/uiswing/events/internalframelistener.html" target="_top">How to Write an Internal Frame Listener</a>, |
| 38 | + * a section in <em>The Java Tutorial</em>. |
| 39 | + * <p> |
| 40 | + * <strong>Warning:</strong> |
| 41 | + * Serialized objects of this class will not be compatible with |
| 42 | + * future Swing releases. The current serialization support is |
| 43 | + * appropriate for short term storage or RMI between applications running |
| 44 | + * the same version of Swing. As of 1.4, support for long term storage |
| 45 | + * of all JavaBeans<sup><font size="-2">TM</font></sup> |
| 46 | + * has been added to the <code>java.beans</code> package. |
| 47 | + * Please see {@link java.beans.XMLEncoder}. |
| 48 | + * |
| 49 | + * @see java.awt.event.WindowEvent |
| 50 | + * @see java.awt.event.WindowListener |
| 51 | + * @see JInternalFrame |
| 52 | + * @see InternalFrameListener |
| 53 | + * |
| 54 | + * @author Thomas Ball |
| 55 | + */ |
| 56 | +public class InternalFrameEvent extends AWTEvent { |
| 57 | + |
| 58 | + /** |
| 59 | + * The first number in the range of IDs used for internal frame events. |
| 60 | + */ |
| 61 | + public static final int INTERNAL_FRAME_FIRST = 25549; |
| 62 | + |
| 63 | + /** |
| 64 | + * The last number in the range of IDs used for internal frame events. |
| 65 | + */ |
| 66 | + public static final int INTERNAL_FRAME_LAST = 25555; |
| 67 | + |
| 68 | + /** |
| 69 | + * The "window opened" event. This event is delivered only |
| 70 | + * the first time the internal frame is made visible. |
| 71 | + * |
| 72 | + * @see JInternalFrame#show |
| 73 | + */ |
| 74 | + public static final int INTERNAL_FRAME_OPENED = INTERNAL_FRAME_FIRST; |
| 75 | + |
| 76 | + /** |
| 77 | + * The "window is closing" event. This event is delivered when |
| 78 | + * the user attempts to close the internal frame, such as by |
| 79 | + * clicking the internal frame's close button, |
| 80 | + * or when a program attempts to close the internal frame |
| 81 | + * by invoking the <code>setClosed</code> method. |
| 82 | + * |
| 83 | + * @see JInternalFrame#setDefaultCloseOperation |
| 84 | + * @see JInternalFrame#doDefaultCloseAction |
| 85 | + * @see JInternalFrame#setClosed |
| 86 | + */ |
| 87 | + public static final int INTERNAL_FRAME_CLOSING = 1 + INTERNAL_FRAME_FIRST; |
| 88 | + |
| 89 | + /** |
| 90 | + * The "window closed" event. This event is delivered after |
| 91 | + * the internal frame has been closed as the result of a call to |
| 92 | + * the <code>setClosed</code> or |
| 93 | + * <code>dispose</code> method. |
| 94 | + * |
| 95 | + * @see JInternalFrame#setClosed |
| 96 | + * @see JInternalFrame#dispose |
| 97 | + */ |
| 98 | + public static final int INTERNAL_FRAME_CLOSED = 2 + INTERNAL_FRAME_FIRST; |
| 99 | + |
| 100 | + /** |
| 101 | + * The "window iconified" event. |
| 102 | + * This event indicates that the internal frame |
| 103 | + * was shrunk down to a small icon. |
| 104 | + * |
| 105 | + * @see JInternalFrame#setIcon |
| 106 | + */ |
| 107 | + public static final int INTERNAL_FRAME_ICONIFIED = 3 + INTERNAL_FRAME_FIRST; |
| 108 | + |
| 109 | + /** |
| 110 | + * The "window deiconified" event type. This event indicates that the |
| 111 | + * internal frame has been restored to its normal size. |
| 112 | + * |
| 113 | + * @see JInternalFrame#setIcon |
| 114 | + */ |
| 115 | + public static final int INTERNAL_FRAME_DEICONIFIED = 4 + INTERNAL_FRAME_FIRST; |
| 116 | + |
| 117 | + /** |
| 118 | + * The "window activated" event type. This event indicates that keystrokes |
| 119 | + * and mouse clicks are directed towards this internal frame. |
| 120 | + * |
| 121 | + * @see JInternalFrame#show |
| 122 | + * @see JInternalFrame#setSelected |
| 123 | + */ |
| 124 | + public static final int INTERNAL_FRAME_ACTIVATED = 5 + INTERNAL_FRAME_FIRST; |
| 125 | + |
| 126 | + /** |
| 127 | + * The "window deactivated" event type. This event indicates that keystrokes |
| 128 | + * and mouse clicks are no longer directed to the internal frame. |
| 129 | + * |
| 130 | + * @see JInternalFrame#setSelected |
| 131 | + */ |
| 132 | + public static final int INTERNAL_FRAME_DEACTIVATED = 6 + INTERNAL_FRAME_FIRST; |
| 133 | + |
| 134 | + /** |
| 135 | + * Constructs an <code>InternalFrameEvent</code> object. |
| 136 | + * @param source the <code>JInternalFrame</code> object that originated the event |
| 137 | + * @param id an integer indicating the type of event |
| 138 | + */ |
| 139 | + public InternalFrameEvent(JInternalFrame source, int id) { |
| 140 | + super(source, id); |
| 141 | + } |
| 142 | + |
| 143 | + /** |
| 144 | + * Returns a parameter string identifying this event. |
| 145 | + * This method is useful for event logging and for debugging. |
| 146 | + * |
| 147 | + * @return a string identifying the event and its attributes |
| 148 | + */ |
| 149 | + public String paramString() { |
| 150 | + String typeStr; |
| 151 | + switch(id) { |
| 152 | + case INTERNAL_FRAME_OPENED: |
| 153 | + typeStr = "INTERNAL_FRAME_OPENED"; |
| 154 | + break; |
| 155 | + case INTERNAL_FRAME_CLOSING: |
| 156 | + typeStr = "INTERNAL_FRAME_CLOSING"; |
| 157 | + break; |
| 158 | + case INTERNAL_FRAME_CLOSED: |
| 159 | + typeStr = "INTERNAL_FRAME_CLOSED"; |
| 160 | + break; |
| 161 | + case INTERNAL_FRAME_ICONIFIED: |
| 162 | + typeStr = "INTERNAL_FRAME_ICONIFIED"; |
| 163 | + break; |
| 164 | + case INTERNAL_FRAME_DEICONIFIED: |
| 165 | + typeStr = "INTERNAL_FRAME_DEICONIFIED"; |
| 166 | + break; |
| 167 | + case INTERNAL_FRAME_ACTIVATED: |
| 168 | + typeStr = "INTERNAL_FRAME_ACTIVATED"; |
| 169 | + break; |
| 170 | + case INTERNAL_FRAME_DEACTIVATED: |
| 171 | + typeStr = "INTERNAL_FRAME_DEACTIVATED"; |
| 172 | + break; |
| 173 | + default: |
| 174 | + typeStr = "unknown type"; |
| 175 | + } |
| 176 | + return typeStr; |
| 177 | + } |
| 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 : null; |
| 189 | + } |
| 190 | + |
| 191 | + |
| 192 | +} |
0 commit comments