我有以下 SWT 测试代码:
public static void main(String[] args) {
shell = new Shell();
shell.setText(APP_NAME + " " + APP_VERSION);
shell.addShellListener(new ShellListener() {
public void shellActivated(ShellEvent event) { }
public void shellClosed(ShellEvent event) { exit(); }
public void shellDeactivated(ShellEvent event) { }
public void shellDeiconified(ShellEvent event) { }
public void shellIconified(ShellEvent event) { }
});
shell.open();
display = shell.getDisplay();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
我的 exit() 方法如下:
private void exit() {
System.exit(0);
}
我尝试通过关闭外壳(“窗口”)或拉下应用程序菜单(标记为“SWT”)并选择“退出”来退出应用程序。
当我这样做时,在 Dock 中留下了一个 SWT 存根,并且 SWT 应用程序实际上并没有退出。我必须通过 Eclipse 或 Force Quit 手动终止 SWT 应用程序。
我已经在 Mac OS X 10.5.6 (Intel) 下的 Eclipse 3.4.1 下使用 v3.4 和 v3.5 SWT jar 进行了尝试。
当我关闭 shell 时,我需要做额外的工作才能退出应用程序吗?