问题
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