JDK-4888539 : AWT Toolkit getSystemEventQueue returns wrong event queue
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.1
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2003-07-10
  • Updated: 2003-07-16
  • Resolved: 2003-07-16
Related Reports
Duplicate :  
Description

Name: dk106046			Date: 07/10/2003

1.4.1_02-b06
 
I have subclassed the EventQueue class, and pushed it on stack using Toolkit.getSystemEventQueue().push().  
However, when I call getSystemEventQueue() from this time onwards, the OLD EventQueue is returned, 
not the new one on the top of the stack. 
Looking at the Java source-code, all other methods navigate the internal chain/stack to find the most recent EventQueue 
- except getSystemEventQueue!

I found this problem while using JavaHelp 1.1.2, which reads the EventQueue to find the component
that was clicked on. However, it called getEvents() and caused the Application to freeze (due to 
the blocking call). The block happens because events are now sent to my subclassed EventQueue, not 
the original one, but getSystemEventQueue has returned the original EventQueue.                                                

We have applied following fix to EventQueue.java:


1. Add an import

import sun.awt.AppContext;


2. At the end of the push method add the following:

       nextQueue = newEventQueue;

/* Add */      AppContext appContext = AppContext.getAppContext();
/* Add */      if (appContext.get(AppContext.EVENT_QUEUE_KEY) == this) {
/* Add */      appContext.put(AppContext.EVENT_QUEUE_KEY, newEventQueue);
/* Add */      }

    }



3. At the end of the pop method add the following:
 
 /* Add */         AppContext appContext = AppContext.getAppContext();
 /* Add */         if (appContext.get(AppContext.EVENT_QUEUE_KEY) == this) {
 /* Add */              appContext.put(AppContext.EVENT_QUEUE_KEY, previousQueue);
 /* Add */         }
     
           previousQueue = null;

[This bug is being submitted as a courtesy, in order to maintain uniformity between Sun & IBM JDKs.  It has been fixed in IBM JDKs.  Please contact ###@###.### if you have questions.]
======================================================================