Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to close a Java SWT window with a button?

Tags:

java

dialog

swt

As a newbie to Java, and many years of iOS and .NET experience, I found this to be massively confusing. What I want I thought would be very simple - I want a dialog (called from a main window) with OK and Cancel buttons. When you click OK, it does something, then dismisses the dialog. When you click Cancel, it just dismisses the dialog.

However, doing this using the SWT shell Dialog class is not obvious. How do you get a button to dismiss the dialog, and return execution back to the main Window?

like image 888
Jay Imerman Avatar asked Jan 10 '23 02:01

Jay Imerman


1 Answers

Use Shell.close() rather than dispose() - so shlCheckOut.close().

Shell.close sends the SWT.Close event and then calls dispose.

like image 160
greg-449 Avatar answered Jan 12 '23 16:01

greg-449