swing模拟窗口关闭事件

来源:互联网 发布:交互界面设计软件 编辑:程序博客网 时间:2024/04/30 12:16

1、窗口属性 xxx.setDefaultCloseOperation(EXIT_ON_CLOSE);

2、模拟事件 WindowEvent we = new  WindowEvent(xxx.this,WindowEvent.WINDOW_CLOSING);
3、事件分发 xxx.this.dispatchEvent(we);

 

其他事件模拟

 

Toolkit.getEventQueue().postEvent(
                        new ActionEvent(Button.this,
                                        ActionEvent.ACTION_PERFORMED,
                                        Button.this.getActionCommand()));