java - Prevent AWT Event Queue from overloading -
I have coded the swing GUI, which uses key accelerator on the jammuites. To suppress the key, which triggers accelerator for a long time, causes EventQueue stacking commands and blocking GUI. I want the AWT event line to contain more than one (or two) content modifier with keyant should not be. I tried to do this:
AWTEvent awtevent = Toolkit.getDefaultToolkit () .getSystemEventQueue (). PeekEvent (); If (awtevent! = Null) {string paramString = awtevent.paramString (); If ((paramString.indexOf ("modifiers = Ctrl")! = -1 & amp; amp; ((KeyEvent) event) .isControlDown ())) {(KeyEvent event) .consume (); } And if (paramString.indexOf ("modifiers = Ctrl")! = -1 & amp; amp; (paramchrring.indexOf ("keychhar = undefined")! = -1)) {(KeyEvent event) .consume ( ); }} But this is very unbelievable because sometimes programs are consumed which should not be consumed.
You can not trust it from the outside outside This event-sending thread manipulate the event queue out of thread To do is not thread-safe, and you can not execute any work on the event dispatch thread, which is being executed manually with the events posted before that task. You can probably push the cleanup work on every other or two on Qi, which will handle two-pro-saved events so far, but ... not just.
If you want to filter AWT / Swing events then you need to install the queue of your own event, which is easier than sound. You can be educative.
Comments
Post a Comment