SWT中实现关闭窗口弹出确认

// 添加事件监听器
shell.addShellListener(new ShellAdapter() {
	@Override
	public void shellClosed(ShellEvent e) {

		// 获得确认结果
		boolean result = new MsgBox().questionTip(shell, "确定要退出程序吗?");

		// 确认是否退出
		e.doit = result;
	}
});

你可能感兴趣的:(java,SWT)