且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Swing以编程方式发送事件

更新时间:2023-12-03 14:33:16

对于您的具体示例,您可以简单地调用 AbstractButton#doClick

For your specific example you can simply call AbstractButton#doClick.

如果您需要为一般情况创建合成事件,请确保填写所有字段, AWTEvent 将会有,因为事件处理程序可能会认为它们是理所当然的。

If you need to create synthetic events for the general case, make sure fill in all fields that a real AWTEvent would have, since the event handlers may take them for granted.