src/share/classes/sun/awt/SunToolkit.java
Print this page
@@ -575,11 +575,14 @@
* Execute a chunk of code on the Java event handler thread for the
* given target. Does not wait for the execution to occur before
* returning to the caller.
*/
public static void executeOnEventHandlerThread(PeerEvent peerEvent) {
- postEvent(targetToAppContext(peerEvent.getSource()), peerEvent);
+ AppContext appContext = targetToAppContext(peerEvent.getSource());
+ if (appContext != null) {
+ postEvent(appContext, peerEvent);
+ }
}
/*
* Execute a chunk of code on the Java event handler thread. The
* method takes into account provided AppContext and sets
@@ -632,10 +635,13 @@
* Use this call to ensure that a given task is being executed
* (or not being) on the event dispatch thread for the given target.
*/
public static boolean isDispatchThreadForAppContext(Object target) {
AppContext appContext = targetToAppContext(target);
+ if (appContext == null) {
+ return false;
+ }
EventQueue eq = (EventQueue)appContext.get(AppContext.EVENT_QUEUE_KEY);
AWTAccessor.EventQueueAccessor accessor = AWTAccessor.getEventQueueAccessor();
return accessor.isDispatchThreadImpl(eq);
}