Dispatching AWT Event With No User Input
I need to dispatch an event in AWT in the constructor of a panel. I need to do this because the AWT-EventQueue
开发者_JAVA百科 needs to aquire a ReentrantLock
and release it when the user clicks a button.
How can I do this?
I've found an easy solution:
invokeLater()
What about:
AWTEvent e = ...
this.dispatchEvent( e );
Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent( e );
KeyboardFocusManager.getCurrentKeyboardFocusManager().processKeyEvent(this, (KeyEvent)e);
精彩评论