tags:

views:

19

answers:

1

A typical SWT sample code looks like the following:

final Display display = Display.getDefault();
final Shell shell = createMyShell(display);
shell.open();
while (!shell.isDisposed()) {
  if (!display.readAndDispatch()) {
    display.sleep();
  }
}

What is the difference between the Display and the Shell? If multiple windows have to be shown, does each one need an own loop?

+1  A: 

Yes, if you have to show multiple windows (shells), you must have a loop for each one.

But there is only one Display object in an application that you need to create.

True Soft
Thanks, so the `Display` is just an instance to the underlying graphic system and the `Shell` is the window, right?
mklhmnn
Do I understand it right, that one `while`-loop for the whole application would be sufficient as long as there is at least one undisposed `shell`?
mklhmnn
No, there must be a loop for each shell. It keeps the shell open. If you only call `shell.open()`, you'll see that it opens, and closes right the next second.
True Soft