Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » JFace close button(Proper technique)
JFace close button [message #777694] Tue, 10 January 2012 17:32 Go to next message
Bill Brandley is currently offline Bill Brandley
Messages: 12
Registered: October 2011
Junior Member
I created a JFace application containing a "Close" button. In the "mouseUp" event, I placed:

Display.getCurrent().dispose();

I modified main() thusly:

if(Display.getCurrent() != null) {
Display.getCurrent().dispose();
}

Is this a reasonable way to code a JFace close application from a button? What is the preferred method of accomplishing this?

Thanx,
Bill
Re: JFace close button [message #778182 is a reply to message #777694] Wed, 11 January 2012 09:34 Go to previous message
Daniel Krügler is currently offline Daniel Krügler
Messages: 853
Registered: July 2009
Senior Member
On 2012-01-10 23:32, Bill Brandley wrote:
> I created a JFace application containing a "Close" button. In the
> "mouseUp" event, I placed:
>
> Display.getCurrent().dispose();
>
> I modified main() thusly:
>
> if(Display.getCurrent() != null) {
> Display.getCurrent().dispose();
> }
>
> Is this a reasonable way to code a JFace close application from a
> button? What is the preferred method of accomplishing this?

I would instead call the "close" function from the shell:

"* Requests that the window manager close the receiver in
* the same way it would be closed when the user clicks on
* the "close box" or performs some other platform specific
* key or mouse combination that indicates the window
* should be removed."

This seems to be the more appropriate action to me. Display.close is
more drastically and does not give corresponding promises. It should be
invoked after the disposal of the shell, though.

HTH & Greetings from Bremen,

Daniel Krügler
Previous Topic:Question about ImageDescriptor
Next Topic:adding multiple columns in ListSelectionDialog
Goto Forum:
  


Current Time: Thu Aug 21 12:03:56 EDT 2014

Powered by FUDForum. Page generated in 0.02213 seconds