jdk/src/share/classes/java/awt/event/HierarchyEvent.java
author dav
Tue, 08 Apr 2008 12:46:39 +0400
changeset 440 a3dac373f62d
parent 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
6520716: event classes lack info about parameters Summary: clarify allowed values for event constructors Reviewed-by: son, denis
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
440
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
     2
 * Copyright 1999-2008 Sun Microsystems, Inc.  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
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
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
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.awt.event;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.AWTEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.Component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.Container;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * An event which indicates a change to the <code>Component</code>
440
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
    34
 * hierarchy to which <code>Component</code> belongs.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * <li>Hierarchy Change Events (HierarchyListener)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 *     <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 *     <li> addition of an ancestor
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 *     <li> removal of an ancestor
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 *     <li> hierarchy made displayable
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *     <li> hierarchy made undisplayable
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 *     <li> hierarchy shown on the screen (both visible and displayable)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 *     <li> hierarchy hidden on the screen (either invisible or undisplayable)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *     </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * <li>Ancestor Reshape Events (HierarchyBoundsListener)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *     <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *     <li> an ancestor was resized
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *     <li> an ancestor was moved
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *     </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * Hierarchy events are provided for notification purposes ONLY.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * The AWT will automatically handle changes to the hierarchy internally so
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * that GUI layout and displayability works properly regardless of whether a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * program is receiving these events or not.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * This event is generated by a Container object (such as a Panel) when the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * Container is added, removed, moved, or resized, and passed down the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * hierarchy. It is also generated by a Component object when that object's
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * <code>addNotify</code>, <code>removeNotify</code>, <code>show</code>, or
440
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
    61
 * <code>hide</code> method is called. The {@code ANCESTOR_MOVED} and
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
    62
 * {@code ANCESTOR_RESIZED}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * events are dispatched to every <code>HierarchyBoundsListener</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * <code>HierarchyBoundsAdapter</code> object which registered to receive
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * such events using the Component's <code>addHierarchyBoundsListener</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * method. (<code>HierarchyBoundsAdapter</code> objects implement the <code>
440
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
    67
 * HierarchyBoundsListener</code> interface.) The {@code HIERARCHY_CHANGED} events are
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * dispatched to every <code>HierarchyListener</code> object which registered
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * to receive such events using the Component's <code>addHierarchyListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * </code> method. Each such listener object gets this <code>HierarchyEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * </code> when the event occurs.
440
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
    72
 * <p>
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
    73
 * An unspecified behavior will be caused if the {@code id} parameter
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
    74
 * of any particular {@code HierarchyEvent} instance is not
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
    75
 * in the range from {@code HIERARCHY_FIRST} to {@code HIERARCHY_LAST}.
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
    76
 * <br>
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
    77
 * The {@code changeFlags} parameter of any {@code HierarchyEvent} instance takes one of the following
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
    78
 * values:
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
    79
 * <ul>
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
    80
 * <li> {@code HierarchyEvent.PARENT_CHANGED}
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
    81
 * <li> {@code HierarchyEvent.DISPLAYABILITY_CHANGED}
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
    82
 * <li> {@code HierarchyEvent.SHOWING_CHANGED}
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
    83
 * </ul>
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
    84
 * Assigning the value different from listed above will cause unspecified behavior.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * @author      David Mendenhall
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 * @see         HierarchyListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * @see         HierarchyBoundsAdapter
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 * @see         HierarchyBoundsListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 * @since       1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
public class HierarchyEvent extends AWTEvent {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * serialVersionUID
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    private static final long serialVersionUID = -5337576970038043990L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * Marks the first integer id for the range of hierarchy event ids.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    public static final int HIERARCHY_FIRST = 1400; // 1300 used by sun.awt.windows.ModalityEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * The event id indicating that modification was made to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * entire hierarchy tree.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    public static final int HIERARCHY_CHANGED = HIERARCHY_FIRST;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * The event id indicating an ancestor-Container was moved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    public static final int ANCESTOR_MOVED = 1 + HIERARCHY_FIRST;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * The event id indicating an ancestor-Container was resized.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    public static final int ANCESTOR_RESIZED = 2 + HIERARCHY_FIRST;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * Marks the last integer id for the range of ancestor event ids.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    public static final int HIERARCHY_LAST = ANCESTOR_RESIZED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    /**
440
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   125
     * A change flag indicates that the <code>HIERARCHY_CHANGED</code> event
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * was generated by a reparenting operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    public static final int PARENT_CHANGED = 0x1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    /**
440
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   131
     * A change flag indicates that the <code>HIERARCHY_CHANGED</code> event
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   132
     * was generated due to the changing of the hierarchy displayability.
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   133
     * To discern the
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   134
     * current displayability of the hierarchy, call the
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   135
     * <code>Component.isDisplayable</code> method. Displayability changes occur
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   136
     * in response to explicit or implicit calls of the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * <code>Component.addNotify</code> and
440
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   138
     * <code>Component.removeNotify</code> methods.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * @see java.awt.Component#isDisplayable()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * @see java.awt.Component#addNotify()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * @see java.awt.Component#removeNotify()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    public static final int DISPLAYABILITY_CHANGED = 0x2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    /**
440
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   147
     * A change flag indicates that the <code>HIERARCHY_CHANGED</code> event
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   148
     * was generated due to the changing of the hierarchy showing state.
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   149
     * To discern the
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   150
     * current showing state of the hierarchy, call the
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   151
     * <code>Component.isShowing</code> method. Showing state changes occur
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * when either the displayability or visibility of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * hierarchy occurs. Visibility changes occur in response to explicit
440
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   154
     * or implicit calls of the <code>Component.show</code> and
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   155
     * <code>Component.hide</code> methods.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * @see java.awt.Component#isShowing()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * @see java.awt.Component#addNotify()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * @see java.awt.Component#removeNotify()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * @see java.awt.Component#show()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * @see java.awt.Component#hide()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    public static final int SHOWING_CHANGED = 0x4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    Component changed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    Container changedParent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    long      changeFlags;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * Constructs an <code>HierarchyEvent</code> object to identify a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * change in the <code>Component</code> hierarchy.
440
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   172
     * <p>This method throws an
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * <code>IllegalArgumentException</code> if <code>source</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * is <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     *
440
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   176
     * @param source          The <code>Component</code> object that
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     *                        originated the event
440
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   178
     * @param id              An integer indicating the type of event.
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   179
     *                        For information on allowable values, see
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   180
     *                        the class description for {@link HierarchyEvent}
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   181
     * @param changed         The <code>Component</code> at the top of
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     *                        the hierarchy which was changed
440
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   183
     * @param changedParent   The parent of the <code>changed</code> component.
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   184
     *                        This
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     *                        may be the parent before or after the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     *                        change, depending on the type of change
440
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   187
     * @throws IllegalArgumentException if <code>source</code> is {@code null}
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   188
     * @see #getSource()
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   189
     * @see #getID()
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   190
     * @see #getChanged()
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   191
     * @see #getChangedParent()
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    public HierarchyEvent(Component source, int id, Component changed,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                          Container changedParent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        super(source, id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        this.changed = changed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        this.changedParent = changedParent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * Constructs an <code>HierarchyEvent</code> object to identify
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * a change in the <code>Component</code> hierarchy.
440
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   203
     * <p> This method throws an
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * <code>IllegalArgumentException</code> if <code>source</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * is <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     *
440
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   207
     * @param source          The <code>Component</code> object that
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     *                        originated the event
440
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   209
     * @param id              An integer indicating the type of event.
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   210
     *                        For information on allowable values, see
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   211
     *                        the class description for {@link HierarchyEvent}
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   212
     * @param changed         The <code>Component</code> at the top
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     *                        of the hierarchy which was changed
440
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   214
     * @param changedParent   The parent of the <code>changed</code> component.
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   215
     *                        This
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     *                        may be the parent before or after the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     *                        change, depending on the type of change
440
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   218
     * @param changeFlags     A bitmask which indicates the type(s) of
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   219
     *                        the <code>HIERARCHY_CHANGED</code> events
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   220
     *                        represented in this event object.
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   221
     *                        For information on allowable values, see
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   222
     *                        the class description for {@link HierarchyEvent}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * @throws IllegalArgumentException if <code>source</code> is null
440
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   224
     * @see #getSource()
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   225
     * @see #getID()
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   226
     * @see #getChanged()
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   227
     * @see #getChangedParent()
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   228
     * @see #getChangeFlags()
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    public HierarchyEvent(Component source, int id, Component changed,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                          Container changedParent, long changeFlags) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        super(source, id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        this.changed = changed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        this.changedParent = changedParent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        this.changeFlags = changeFlags;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * Returns the originator of the event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * @return the <code>Component</code> object that originated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * the event, or <code>null</code> if the object is not a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * <code>Component</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    public Component getComponent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        return (source instanceof Component) ? (Component)source : null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * Returns the Component at the top of the hierarchy which was
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * changed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     * @return the changed Component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    public Component getChanged() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        return changed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * Returns the parent of the Component returned by <code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * getChanged()</code>. For a HIERARCHY_CHANGED event where the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * change was of type PARENT_CHANGED via a call to <code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * Container.add</code>, the parent returned is the parent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * after the add operation. For a HIERARCHY_CHANGED event where
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * the change was of type PARENT_CHANGED via a call to <code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * Container.remove</code>, the parent returned is the parent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * before the remove operation. For all other events and types,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     * the parent returned is the parent during the operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * @return the parent of the changed Component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    public Container getChangedParent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        return changedParent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * Returns a bitmask which indicates the type(s) of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * HIERARCHY_CHANGED events represented in this event object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * The bits have been bitwise-ored together.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * @return the bitmask, or 0 if this is not an HIERARCHY_CHANGED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    public long getChangeFlags() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        return changeFlags;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     * Returns a parameter string identifying this event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     * This method is useful for event-logging and for debugging.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * @return a string identifying the event and its attributes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    public String paramString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        String typeStr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        switch(id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
          case ANCESTOR_MOVED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
              typeStr = "ANCESTOR_MOVED ("+changed+","+changedParent+")";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
          case ANCESTOR_RESIZED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
              typeStr = "ANCESTOR_RESIZED ("+changed+","+changedParent+")";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
          case HIERARCHY_CHANGED: {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
              typeStr = "HIERARCHY_CHANGED (";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
              boolean first = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
              if ((changeFlags & PARENT_CHANGED) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
                  first = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
                  typeStr += "PARENT_CHANGED";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
              if ((changeFlags & DISPLAYABILITY_CHANGED) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
                  if (first) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
                      first = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
                  } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
                      typeStr += ",";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
                  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
                  typeStr += "DISPLAYABILITY_CHANGED";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
              if ((changeFlags & SHOWING_CHANGED) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
                  if (first) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
                      first = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
                  } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
                      typeStr += ",";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
                  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
                  typeStr += "SHOWING_CHANGED";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
              if (!first) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
                  typeStr += ",";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
              typeStr += changed + "," + changedParent + ")";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
          default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
              typeStr = "unknown type";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        return typeStr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
}