Java SWT shell window closing event

江枫思渺然 提交于 2019-12-23 09:33:47

问题


I just have a quick question.

How do you override the window closing event for a shell in an swt application? I want the X-Button to simple hide the shell, not close the program.

I tried something simple:

shell.addListener(SWT.Close, new Listener() {
      public void handleEvent(Event event) {
        shell.setVisible(false);
      }
    });

Still terminates the program.

Thanks in advance.


回答1:


You could try

shell.addListener(SWT.Close, new Listener() {
      public void handleEvent(Event event) {
        event.doit = false;
      }
    });


来源:https://stackoverflow.com/questions/15789202/java-swt-shell-window-closing-event

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!