Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » How to dispose ApplicationWindow
How to dispose ApplicationWindow [message #520027] Wed, 10 March 2010 16:20 Go to next message
Ilja is currently offline Ilja
Messages: 1
Registered: March 2010
Junior Member
Hi all,
maybe this is a beginner question, but this is a hobby project of mine.
I have problems terminating my programm cleanly. Below is my code. So
when I close the window the task will not be treminated completely (no
Finished! writing in the console). What I am missing here to terminate
the applicationwindow? I tried it even without any content created ...

thanks
Ilja

public class AVC extends ApplicationWindow {

private AVC(Shell shell) {
super(shell);
}


protected Control createContents (Composite parent) {
getShell().setText ("Das namenlose Programm");
getShell().setSize(1000, 700);

return new Composite (parent, SWT.BORDER | SWT.NULL);
}

public static void main(String[] args) {
final Display display = new Display();
Realm.runWithDefault(SWTObservables.getRealm(display), new Runnable() {
public void run() {
Shell shell = new Shell(display);
AVC avc = new AVC(shell);
avc.setBlockOnOpen (true);
avc.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
avc.handleShellCloseEvent();
}
});
display.dispose();

System.out.println("Finished!");
}

}
Re: How to dispose ApplicationWindow [message #520554 is a reply to message #520027] Fri, 12 March 2010 13:50 Go to previous message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Ilja Roganov wrote:

> Shell shell = new Shell(display);
> AVC avc = new AVC(shell);
> avc.setBlockOnOpen (true);
> avc.open();

The above code seems fine.

> while (!shell.isDisposed()) {
> if (!display.readAndDispatch())
> display.sleep();
> }
> avc.handleShellCloseEvent();

This code, however, is superfluous. your avc.open() ran the event loop,
and an avc.close() or Shell close event would have disposed the shell, no?


PW



--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Previous Topic:Chaining content assist's in an editor
Next Topic:Problems with Frame toolkit
Goto Forum:
  


Current Time: Thu Aug 28 21:40:40 EDT 2014

Powered by FUDForum. Page generated in 0.03539 seconds