Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java SWT shell window closing event

Tags:

java

swt

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.

like image 840
B3st0fth3w0rst Avatar asked Apr 03 '13 13:04

B3st0fth3w0rst


1 Answers

You could try

shell.addListener(SWT.Close, new Listener() {
      public void handleEvent(Event event) {
        event.doit = false;
      }
    });
like image 143
Tom Seidel Avatar answered Oct 04 '22 05:10

Tom Seidel