import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; public class TestShells { public static void main(String[] args) { Display display = new Display(); boolean condition1=false; boolean condition2=false; if(condition1) { new Shell1(); eventLoop(display); } if(condition2) { new Shell2(); eventLoop(display); } new Shell3(); eventLoop(display); display.dispose(); } /** * @param display */ private static void eventLoop(Display display) { while (display.getShells().length > 0) { if (!display.readAndDispatch()) { display.sleep(); } } } } class Shell1 { Shell1() { Display display = Display.getDefault(); Shell shell = new Shell(display); shell.setText("Shell 1"); shell.open(); } } class Shell2 { Shell2() { Display display = Display.getDefault(); Shell shell = new Shell(display); shell.setText("Shell 2"); shell.open(); } } class Shell3 { Shell3() { Display display = Display.getDefault(); Shell shell = new Shell(display); shell.setText("Shell 3"); shell.open(); } }