jdk/src/share/classes/javax/swing/AncestorNotifier.java
author alitvinov
Wed, 24 Oct 2012 18:27:14 +0400
changeset 14303 de2b26a9e1c3
parent 11268 f0e59c4852de
permissions -rw-r--r--
7193219: JComboBox serialization fails in JDK 1.7 Reviewed-by: rupashka, anthony
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
14303
de2b26a9e1c3 7193219: JComboBox serialization fails in JDK 1.7
alitvinov
parents: 11268
diff changeset
     2
 * Copyright (c) 1997, 2012, 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: 1639
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: 1639
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: 1639
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1639
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1639
diff changeset
    23
 * questions.
2
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 javax.swing;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import javax.swing.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.awt.Component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.awt.Container;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.awt.Window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.beans.PropertyChangeListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.beans.PropertyChangeEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.io.Serializable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * @author Dave Moore
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
11268
f0e59c4852de 7116950: Reduce number of warnings in swing
alexsch
parents: 5506
diff changeset
    45
@SuppressWarnings("serial")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
class AncestorNotifier implements ComponentListener, PropertyChangeListener, Serializable
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
{
14303
de2b26a9e1c3 7193219: JComboBox serialization fails in JDK 1.7
alitvinov
parents: 11268
diff changeset
    48
    transient Component firstInvisibleAncestor;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    EventListenerList listenerList = new EventListenerList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    JComponent root;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    AncestorNotifier(JComponent root) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        this.root = root;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
        addListeners(root, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    void addAncestorListener(AncestorListener l) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        listenerList.add(AncestorListener.class, l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    void removeAncestorListener(AncestorListener l) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        listenerList.remove(AncestorListener.class, l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    AncestorListener[] getAncestorListeners() {
1301
15e81207e1f2 6727662: Code improvement and warnings removing from swing packages
rupashka
parents: 2
diff changeset
    66
        return listenerList.getListeners(AncestorListener.class);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * Notify all listeners that have registered interest for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * notification on this event type.  The event instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * is lazily created using the parameters passed into
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * the fire method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * @see EventListenerList
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    protected void fireAncestorAdded(JComponent source, int id, Container ancestor, Container ancestorParent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        // Guaranteed to return a non-null array
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        Object[] listeners = listenerList.getListenerList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        // Process the listeners last to first, notifying
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        // those that are interested in this event
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        for (int i = listeners.length-2; i>=0; i-=2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
            if (listeners[i]==AncestorListener.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
                // Lazily create the event:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
                AncestorEvent ancestorEvent =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
                    new AncestorEvent(source, id, ancestor, ancestorParent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
                ((AncestorListener)listeners[i+1]).ancestorAdded(ancestorEvent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * Notify all listeners that have registered interest for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * notification on this event type.  The event instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * is lazily created using the parameters passed into
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * the fire method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * @see EventListenerList
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    protected void fireAncestorRemoved(JComponent source, int id, Container ancestor, Container ancestorParent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        // Guaranteed to return a non-null array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        Object[] listeners = listenerList.getListenerList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        // Process the listeners last to first, notifying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        // those that are interested in this event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        for (int i = listeners.length-2; i>=0; i-=2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
            if (listeners[i]==AncestorListener.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
                // Lazily create the event:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
                AncestorEvent ancestorEvent =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
                    new AncestorEvent(source, id, ancestor, ancestorParent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
                ((AncestorListener)listeners[i+1]).ancestorRemoved(ancestorEvent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * Notify all listeners that have registered interest for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * notification on this event type.  The event instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * is lazily created using the parameters passed into
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * the fire method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * @see EventListenerList
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    protected void fireAncestorMoved(JComponent source, int id, Container ancestor, Container ancestorParent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        // Guaranteed to return a non-null array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        Object[] listeners = listenerList.getListenerList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        // Process the listeners last to first, notifying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        // those that are interested in this event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        for (int i = listeners.length-2; i>=0; i-=2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
            if (listeners[i]==AncestorListener.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
                // Lazily create the event:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
                AncestorEvent ancestorEvent =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
                    new AncestorEvent(source, id, ancestor, ancestorParent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
                ((AncestorListener)listeners[i+1]).ancestorMoved(ancestorEvent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    void removeAllListeners() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        removeListeners(root);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    void addListeners(Component ancestor, boolean addToFirst) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        Component a;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        firstInvisibleAncestor = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        for (a = ancestor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
             firstInvisibleAncestor == null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
             a = a.getParent()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            if (addToFirst || a != ancestor) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
                a.addComponentListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
                if (a instanceof JComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
                    JComponent jAncestor = (JComponent)a;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
                    jAncestor.addPropertyChangeListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
            if (!a.isVisible() || a.getParent() == null || a instanceof Window) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
                firstInvisibleAncestor = a;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        if (firstInvisibleAncestor instanceof Window &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
            firstInvisibleAncestor.isVisible()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
            firstInvisibleAncestor = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    void removeListeners(Component ancestor) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        Component a;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        for (a = ancestor; a != null; a = a.getParent()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
            a.removeComponentListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
            if (a instanceof JComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                JComponent jAncestor = (JComponent)a;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                jAncestor.removePropertyChangeListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
            if (a == firstInvisibleAncestor || a instanceof Window) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    public void componentResized(ComponentEvent e) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    public void componentMoved(ComponentEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        Component source = e.getComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        fireAncestorMoved(root, AncestorEvent.ANCESTOR_MOVED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
                          (Container)source, source.getParent());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    public void componentShown(ComponentEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        Component ancestor = e.getComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        if (ancestor == firstInvisibleAncestor) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            addListeners(ancestor, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
            if (firstInvisibleAncestor == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
                fireAncestorAdded(root, AncestorEvent.ANCESTOR_ADDED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                                  (Container)ancestor, ancestor.getParent());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    public void componentHidden(ComponentEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        Component ancestor = e.getComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        boolean needsNotify = firstInvisibleAncestor == null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        if ( !(ancestor instanceof Window) ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            removeListeners(ancestor.getParent());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        firstInvisibleAncestor = ancestor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        if (needsNotify) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
            fireAncestorRemoved(root, AncestorEvent.ANCESTOR_REMOVED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                                (Container)ancestor, ancestor.getParent());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    public void propertyChange(PropertyChangeEvent evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        String s = evt.getPropertyName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        if (s!=null && (s.equals("parent") || s.equals("ancestor"))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
            JComponent component = (JComponent)evt.getSource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
            if (evt.getNewValue() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                if (component == firstInvisibleAncestor) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                    addListeners(component, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                    if (firstInvisibleAncestor == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
                        fireAncestorAdded(root, AncestorEvent.ANCESTOR_ADDED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                                          component, component.getParent());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                boolean needsNotify = firstInvisibleAncestor == null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
                Container oldParent = (Container)evt.getOldValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                removeListeners(oldParent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                firstInvisibleAncestor = component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
                if (needsNotify) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
                    fireAncestorRemoved(root, AncestorEvent.ANCESTOR_REMOVED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
                                        component, oldParent);
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
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
}