[英]Dispatching AWT Event With No User Input
I need to dispatch an event in AWT in the constructor of a panel. 我需要在面板的构造函数中的AWT中调度一个事件。 I need to do this because the
AWT-EventQueue
needs to aquire a ReentrantLock
and release it when the user clicks a button. 我需要执行此操作,因为
AWT-EventQueue
需要获取ReentrantLock
并在用户单击按钮时将其释放。
How can I do this? 我怎样才能做到这一点?
I've found an easy solution: 我找到了一个简单的解决方案:
What about: 关于什么:
AWTEvent e = ...
this.dispatchEvent( e );
Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent( e );
KeyboardFocusManager.getCurrentKeyboardFocusManager().processKeyEvent(this, (KeyEvent)e);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.