现在的位置: 首页 > 综合 > 正文

SWT关闭窗口弹出询问对话框

2013年10月30日 ⁄ 综合 ⁄ 共 1295字 ⁄ 字号 评论关闭

通过给shell添加SWT.Close事件

 

shell.addListener(SWT.Close, new Listener() {
   public void handleEvent(Event event) {
    int style = SWT.APPLICATION_MODAL | SWT.YES | SWT.NO;
    MessageBox messageBox = new MessageBox(shell, style);
    messageBox.setText("Information");
    messageBox.setMessage("Close the shell?");
    event.doit = messageBox.open() == SWT.YES;
   }
  });

 

完整示例如下:

 

 

 

 

抱歉!评论已关闭.