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