snail
发贴: 2
积分: 0
|
于 2005-02-13 16:48
我想在一个类似写字板的程序里,添加一个功能 就是在退出时,询问是否保存 shell.addShellListener(new ShellAdapter(){ public void shellClosed(ShellEvent e){ int flag = 0; if (!saved ){ MessageBox saveMessage= new MessageBox(shell, SWT.YES | SWT.NO | SWT.CANCEL | SWT.ICON_WARNING); saveMessage.setMessage("还未保存,是否保存?"); flag = saveMessage.open(); if (flag == SWT.YES) { try { save(); }catch (IOException event){ event.printStackTrace();}} if (flag == SWT.NO); if (flag == SWT.CANCEL) { //这里如何写,使MessageBox退出时,程序不要关闭 }; } }}); 用shell.wait();错误提示不是用户线程 请问有什么办法使shell可以中止退出的过程
snail edited on 2005-02-13 21:38
|