我有以下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);
}
我尝试通过关闭shell(“窗口”)或下拉应用程序菜单(标记为“SWT”)并选择“退出”来退出应用程序。
当我这样做时,一个SWT存根留在Dock中,并且SWT应用程序实际上没有退出。我必须通过Eclipse或Force Quit手动终止SWT应用程序。
我已经尝试使用v3.4和v3.5 SWT jar,在Mac OS X 10.5.6(Intel)下的Eclipse 3.4.1下。
当我关闭shell时,是否需要做额外的工作才能退出应用程序?