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 26 package java.awt; 27 28 import java.util.LinkedList; 29 import sun.awt.AppContext; 30 import sun.awt.SunToolkit; 31 32 /** 33 * A mechanism for ensuring that a series of AWTEvents are executed in a 34 * precise order, even across multiple AppContexts. The nested events will be 35 * dispatched in the order in which their wrapping SequencedEvents were 36 * constructed. The only exception to this rule is if the peer of the target of 37 * the nested event was destroyed (with a call to Component.removeNotify) 38 * before the wrapping SequencedEvent was able to be dispatched. In this case, 39 * the nested event is never dispatched. 40 * 41 * @author David Mendenhall 42 */ 43 class SequencedEvent extends AWTEvent implements ActiveEvent { 44 /* 45 * serialVersionUID 46 */ 47 private static final long serialVersionUID = 547742659238625067L; 48 49 private static final int ID = 50 java.awt.event.FocusEvent.FOCUS_LAST + 1; 51 private static final LinkedList list = new LinkedList(); 52 53 private final AWTEvent nested; 54 private AppContext appContext; 55 private boolean disposed; 56 57 /** 58 * Constructs a new SequencedEvent which will dispatch the specified 59 * nested event. 60 * 61 * @param nested the AWTEvent which this SequencedEvent's dispatch() 62 * method will dispatch 63 */ 64 public SequencedEvent(AWTEvent nested) { 65 super(nested.getSource(), ID); 66 this.nested = nested; 67 // All AWTEvents that are wrapped in SequencedEvents are (at 68 // least currently) implicitly generated by the system 69 SunToolkit.setSystemGenerated(nested); 70 synchronized (SequencedEvent.class) { 71 list.add(this); 72 } 73 } 74 75 /** 76 * Dispatches the nested event after all previous nested events have been | 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 26 package java.awt; 27 28 import java.util.LinkedList; 29 import sun.awt.AWTAccessor; 30 import sun.awt.AppContext; 31 import sun.awt.SunToolkit; 32 33 /** 34 * A mechanism for ensuring that a series of AWTEvents are executed in a 35 * precise order, even across multiple AppContexts. The nested events will be 36 * dispatched in the order in which their wrapping SequencedEvents were 37 * constructed. The only exception to this rule is if the peer of the target of 38 * the nested event was destroyed (with a call to Component.removeNotify) 39 * before the wrapping SequencedEvent was able to be dispatched. In this case, 40 * the nested event is never dispatched. 41 * 42 * @author David Mendenhall 43 */ 44 class SequencedEvent extends AWTEvent implements ActiveEvent { 45 /* 46 * serialVersionUID 47 */ 48 private static final long serialVersionUID = 547742659238625067L; 49 50 private static final int ID = 51 java.awt.event.FocusEvent.FOCUS_LAST + 1; 52 private static final LinkedList list = new LinkedList(); 53 54 private final AWTEvent nested; 55 private AppContext appContext; 56 private boolean disposed; 57 58 static { 59 AWTAccessor.setSequencedEventAccessor(new AWTAccessor.SequencedEventAccessor() { 60 public AWTEvent getNested(AWTEvent sequencedEvent) { 61 return ((SequencedEvent)sequencedEvent).nested; 62 } 63 public boolean isSequencedEvent(AWTEvent event) { 64 return event instanceof SequencedEvent; 65 } 66 }); 67 } 68 69 /** 70 * Constructs a new SequencedEvent which will dispatch the specified 71 * nested event. 72 * 73 * @param nested the AWTEvent which this SequencedEvent's dispatch() 74 * method will dispatch 75 */ 76 public SequencedEvent(AWTEvent nested) { 77 super(nested.getSource(), ID); 78 this.nested = nested; 79 // All AWTEvents that are wrapped in SequencedEvents are (at 80 // least currently) implicitly generated by the system 81 SunToolkit.setSystemGenerated(nested); 82 synchronized (SequencedEvent.class) { 83 list.add(this); 84 } 85 } 86 87 /** 88 * Dispatches the nested event after all previous nested events have been |