开发者

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜