编写一个shellClosed事件,代码如下:

        shell.addShellListener(new ShellAdapter() {
            
public void shellClosed(final ShellEvent e) {
                MessageBox messageBox 
= new MessageBox(shell,
                        SWT.ICON_WARNING 
| SWT.OK | SWT.CANCEL);
                messageBox.setText(
"确定");
                messageBox.setMessage(
"你确定要退出吗?");
                
int rc = messageBox.open();
                
if (rc == SWT.CANCEL) {
                    e.doit 
= false;
                }
            }
        });

 

e.doit 是指操作是否被允许。

相关文章:

  • 2021-08-15
  • 2022-12-23
  • 2022-01-25
  • 2022-01-26
  • 2022-12-23
  • 2022-12-23
  • 2022-01-09
  • 2022-12-23
猜你喜欢
  • 2021-08-02
  • 2022-12-23
  • 2022-12-23
  • 2021-11-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案