Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Display and Shell

Tags:

java

swt

A typical SWT sample code looks like the following code:

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 Display and Shell?
If multiple windows have to be shown, does each one need an own loop?

like image 715
Mot Avatar asked Dec 22 '22 22:12

Mot


1 Answers

You can have multiple shells with a single Display and a single while loop handing event dispatch. Create the display, create the Shell(s) from the Display, and then start the single UI event dispatcher loop. See http://www.chrisnewland.com/av/111/swt-best-practice-single-display-multiple-shells

like image 73
ChrisWhoCodes Avatar answered Dec 27 '22 03:12

ChrisWhoCodes