SWT Shell Window Close Event

I have a quick question.

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

I tried something simple:

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

Still shutting down the program.

Thanks in advance.

+6
source share
1 answer

You can try

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

All Articles