List of usage examples for org.eclipse.swt.widgets Label setLayoutData
public void setLayoutData(Object layoutData)
From source file:org.eclipse.swt.snippets.Snippet295.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); shell.setText("Shell"); FillLayout fillLayout = new FillLayout(); fillLayout.marginWidth = 10;/*from w w w. j ava 2 s . com*/ fillLayout.marginHeight = 10; shell.setLayout(fillLayout); Button open = new Button(shell, SWT.PUSH); open.setText("Prompt for a String"); open.addSelectionListener(widgetSelectedAdapter(e -> { final Shell dialog = new Shell(shell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); dialog.setText("Dialog Shell"); FormLayout formLayout = new FormLayout(); formLayout.marginWidth = 10; formLayout.marginHeight = 10; formLayout.spacing = 10; dialog.setLayout(formLayout); Label label = new Label(dialog, SWT.NONE); label.setText("Type a String:"); FormData data = new FormData(); label.setLayoutData(data); Button cancel = new Button(dialog, SWT.PUSH); cancel.setText("Cancel"); data = new FormData(); data.width = 60; data.right = new FormAttachment(100, 0); data.bottom = new FormAttachment(100, 0); cancel.setLayoutData(data); cancel.addSelectionListener(widgetSelectedAdapter(event -> { System.out.println("User cancelled dialog"); dialog.close(); })); final Text text = new Text(dialog, SWT.BORDER); data = new FormData(); data.width = 200; data.left = new FormAttachment(label, 0, SWT.DEFAULT); data.right = new FormAttachment(100, 0); data.top = new FormAttachment(label, 0, SWT.CENTER); data.bottom = new FormAttachment(cancel, 0, SWT.DEFAULT); text.setLayoutData(data); Button ok = new Button(dialog, SWT.PUSH); ok.setText("OK"); data = new FormData(); data.width = 60; data.right = new FormAttachment(cancel, 0, SWT.DEFAULT); data.bottom = new FormAttachment(100, 0); ok.setLayoutData(data); ok.addSelectionListener(widgetSelectedAdapter(event -> { System.out.println("User typed: " + text.getText()); dialog.close(); })); dialog.setDefaultButton(ok); dialog.pack(); dialog.open(); })); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet335.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Snippet 335"); shell.setLayout(new GridLayout()); Label label = new Label(shell, SWT.WRAP | SWT.BORDER); GridData labelData = new GridData(); labelData.widthHint = 10; /* default width */ labelData.horizontalAlignment = SWT.FILL; /* grow to fill available width */ label.setLayoutData(labelData); label.setText(/* www . j a va 2s. c om*/ "Snippets are minimal stand-alone programs that demonstrate specific techniques or functionality."); new Button(shell, SWT.PUSH).setText("This button determines the Shell's width"); /* do an initial pack() so that the Shell determines its required width */ shell.pack(); /* update the Label's width hint to match what the layout allocated for it */ labelData.widthHint = label.getBounds().width; /* * do a second pack() so that the Label will compute its required height * based on its correct width instead of its previously-set default width */ shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet208.java
public static void main(String[] args) { PaletteData palette = new PaletteData(0xff, 0xff00, 0xff0000); // ImageData showing variations of hue ImageData hueData = new ImageData(360, 100, 24, palette); float hue = 0; for (int x = 0; x < hueData.width; x++) { for (int y = 0; y < hueData.height; y++) { int pixel = palette.getPixel(new RGB(hue, 1f, 1f)); hueData.setPixel(x, y, pixel); }//from ww w .ja v a 2 s .c om hue += 360f / hueData.width; } // ImageData showing saturation on x axis and brightness on y axis ImageData saturationBrightnessData = new ImageData(360, 360, 24, palette); float saturation = 0f; float brightness = 1f; for (int x = 0; x < saturationBrightnessData.width; x++) { brightness = 1f; for (int y = 0; y < saturationBrightnessData.height; y++) { int pixel = palette.getPixel(new RGB(360f, saturation, brightness)); saturationBrightnessData.setPixel(x, y, pixel); brightness -= 1f / saturationBrightnessData.height; } saturation += 1f / saturationBrightnessData.width; } Display display = new Display(); Image hueImage = new Image(display, hueData); Image saturationImage = new Image(display, saturationBrightnessData); Shell shell = new Shell(display); shell.setText("Hue, Saturation, Brightness"); GridLayout gridLayout = new GridLayout(2, false); gridLayout.verticalSpacing = 10; gridLayout.marginWidth = gridLayout.marginHeight = 16; shell.setLayout(gridLayout); Label label = new Label(shell, SWT.CENTER); label.setImage(hueImage); GridData data = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 2, 1); label.setLayoutData(data); label = new Label(shell, SWT.CENTER); //spacer label = new Label(shell, SWT.CENTER); label.setText("Hue"); data = new GridData(SWT.CENTER, SWT.CENTER, false, false); label.setLayoutData(data); label = new Label(shell, SWT.CENTER); //spacer data = new GridData(SWT.CENTER, SWT.CENTER, false, false, 2, 1); label.setLayoutData(data); label = new Label(shell, SWT.LEFT); label.setText("Brightness"); data = new GridData(SWT.LEFT, SWT.CENTER, false, false); label.setLayoutData(data); label = new Label(shell, SWT.CENTER); label.setImage(saturationImage); data = new GridData(SWT.CENTER, SWT.CENTER, false, false); label.setLayoutData(data); label = new Label(shell, SWT.CENTER); //spacer label = new Label(shell, SWT.CENTER); label.setText("Saturation"); data = new GridData(SWT.CENTER, SWT.CENTER, false, false); label.setLayoutData(data); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } hueImage.dispose(); saturationImage.dispose(); display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet128.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); shell.setText("Snippet 128"); GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 3;/*from ww w . j a va 2 s . c o m*/ shell.setLayout(gridLayout); ToolBar toolbar = new ToolBar(shell, SWT.NONE); ToolItem itemBack = new ToolItem(toolbar, SWT.PUSH); itemBack.setText("Back"); ToolItem itemForward = new ToolItem(toolbar, SWT.PUSH); itemForward.setText("Forward"); ToolItem itemStop = new ToolItem(toolbar, SWT.PUSH); itemStop.setText("Stop"); ToolItem itemRefresh = new ToolItem(toolbar, SWT.PUSH); itemRefresh.setText("Refresh"); ToolItem itemGo = new ToolItem(toolbar, SWT.PUSH); itemGo.setText("Go"); GridData data = new GridData(); data.horizontalSpan = 3; toolbar.setLayoutData(data); Label labelAddress = new Label(shell, SWT.NONE); labelAddress.setText("Address"); final Text location = new Text(shell, SWT.BORDER); data = new GridData(); data.horizontalAlignment = GridData.FILL; data.horizontalSpan = 2; data.grabExcessHorizontalSpace = true; location.setLayoutData(data); final Browser browser; try { browser = new Browser(shell, SWT.NONE); } catch (SWTError e) { System.out.println("Could not instantiate Browser: " + e.getMessage()); display.dispose(); return; } data = new GridData(); data.horizontalAlignment = GridData.FILL; data.verticalAlignment = GridData.FILL; data.horizontalSpan = 3; data.grabExcessHorizontalSpace = true; data.grabExcessVerticalSpace = true; browser.setLayoutData(data); final Label status = new Label(shell, SWT.NONE); data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 2; status.setLayoutData(data); final ProgressBar progressBar = new ProgressBar(shell, SWT.NONE); data = new GridData(); data.horizontalAlignment = GridData.END; progressBar.setLayoutData(data); /* event handling */ Listener listener = event -> { ToolItem item = (ToolItem) event.widget; String string = item.getText(); if (string.equals("Back")) browser.back(); else if (string.equals("Forward")) browser.forward(); else if (string.equals("Stop")) browser.stop(); else if (string.equals("Refresh")) browser.refresh(); else if (string.equals("Go")) browser.setUrl(location.getText()); }; browser.addProgressListener(new ProgressListener() { @Override public void changed(ProgressEvent event) { if (event.total == 0) return; int ratio = event.current * 100 / event.total; progressBar.setSelection(ratio); } @Override public void completed(ProgressEvent event) { progressBar.setSelection(0); } }); browser.addStatusTextListener(event -> status.setText(event.text)); browser.addLocationListener(LocationListener.changedAdapter(event -> { if (event.top) location.setText(event.location); })); itemBack.addListener(SWT.Selection, listener); itemForward.addListener(SWT.Selection, listener); itemStop.addListener(SWT.Selection, listener); itemRefresh.addListener(SWT.Selection, listener); itemGo.addListener(SWT.Selection, listener); location.addListener(SWT.DefaultSelection, e -> browser.setUrl(location.getText())); shell.open(); browser.setUrl("http://eclipse.org"); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:MainClass.java
public static void main(String[] a) { Display d = new Display(); Shell s = new Shell(d); s.setSize(250, 250);/*from www. j a va 2 s .c o m*/ s.setText("A FormLayout Example"); s.setLayout(new FormLayout()); final Label l1 = new Label(s, SWT.RIGHT); l1.setText("First Name"); FormData fd = new FormData(); fd.top = new FormAttachment(10, 10); fd.left = new FormAttachment(0, 10); fd.bottom = new FormAttachment(30, 0); fd.right = new FormAttachment(40, 0); l1.setLayoutData(fd); final Label l2 = new Label(s, SWT.RIGHT); l2.setText("Last Name"); fd = new FormData(); fd.top = new FormAttachment(l1, 5); fd.left = new FormAttachment(0, 10); fd.bottom = new FormAttachment(40, 0); fd.right = new FormAttachment(40, 0); l2.setLayoutData(fd); final Text t1 = new Text(s, SWT.BORDER | SWT.SINGLE); fd = new FormData(); fd.top = new FormAttachment(l1, 0, SWT.TOP); fd.left = new FormAttachment(l1, 10); t1.setLayoutData(fd); final Text t2 = new Text(s, SWT.BORDER | SWT.SINGLE); fd = new FormData(); fd.top = new FormAttachment(l2, 0, SWT.TOP); fd.left = new FormAttachment(l2, 10); t2.setLayoutData(fd); s.open(); while (!s.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); }
From source file:BringUpBrowser.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 3;//from ww w. j a v a2s . c o m shell.setLayout(gridLayout); ToolBar toolbar = new ToolBar(shell, SWT.NONE); ToolItem itemBack = new ToolItem(toolbar, SWT.PUSH); itemBack.setText("Back"); ToolItem itemForward = new ToolItem(toolbar, SWT.PUSH); itemForward.setText("Forward"); ToolItem itemStop = new ToolItem(toolbar, SWT.PUSH); itemStop.setText("Stop"); ToolItem itemRefresh = new ToolItem(toolbar, SWT.PUSH); itemRefresh.setText("Refresh"); ToolItem itemGo = new ToolItem(toolbar, SWT.PUSH); itemGo.setText("Go"); GridData data = new GridData(); data.horizontalSpan = 3; toolbar.setLayoutData(data); Label labelAddress = new Label(shell, SWT.NONE); labelAddress.setText("Address"); final Text location = new Text(shell, SWT.BORDER); data = new GridData(); data.horizontalAlignment = GridData.FILL; data.horizontalSpan = 2; data.grabExcessHorizontalSpace = true; location.setLayoutData(data); final Browser browser = new Browser(shell, SWT.NONE); data = new GridData(); data.horizontalAlignment = GridData.FILL; data.verticalAlignment = GridData.FILL; data.horizontalSpan = 3; data.grabExcessHorizontalSpace = true; data.grabExcessVerticalSpace = true; browser.setLayoutData(data); final Label status = new Label(shell, SWT.NONE); data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 2; status.setLayoutData(data); final ProgressBar progressBar = new ProgressBar(shell, SWT.NONE); data = new GridData(); data.horizontalAlignment = GridData.END; progressBar.setLayoutData(data); /* event handling */ Listener listener = new Listener() { public void handleEvent(Event event) { ToolItem item = (ToolItem) event.widget; String string = item.getText(); if (string.equals("Back")) browser.back(); else if (string.equals("Forward")) browser.forward(); else if (string.equals("Stop")) browser.stop(); else if (string.equals("Refresh")) browser.refresh(); else if (string.equals("Go")) browser.setUrl(location.getText()); } }; browser.addProgressListener(new ProgressListener() { public void changed(ProgressEvent event) { if (event.total == 0) return; int ratio = event.current * 100 / event.total; progressBar.setSelection(ratio); } public void completed(ProgressEvent event) { progressBar.setSelection(0); } }); browser.addStatusTextListener(new StatusTextListener() { public void changed(StatusTextEvent event) { status.setText(event.text); } }); browser.addLocationListener(new LocationListener() { public void changed(LocationEvent event) { if (event.top) location.setText(event.location); } public void changing(LocationEvent event) { } }); itemBack.addListener(SWT.Selection, listener); itemForward.addListener(SWT.Selection, listener); itemStop.addListener(SWT.Selection, listener); itemRefresh.addListener(SWT.Selection, listener); itemGo.addListener(SWT.Selection, listener); location.addListener(SWT.DefaultSelection, new Listener() { public void handleEvent(Event e) { browser.setUrl(location.getText()); } }); shell.open(); browser.setUrl("http://eclipse.org"); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet367.java
public static void main(String[] args) { final ImageFileNameProvider filenameProvider = zoom -> { switch (zoom) { case 100: return IMAGE_PATH_100; case 150: return IMAGE_PATH_150; case 200: return IMAGE_PATH_200; default://from ww w . ja v a 2 s.c om return null; } }; final ImageDataProvider imageDataProvider = zoom -> { switch (zoom) { case 100: return new ImageData(IMAGE_PATH_100); case 150: return new ImageData(IMAGE_PATH_150); case 200: return new ImageData(IMAGE_PATH_200); default: return null; } }; final Display display = new Display(); final Shell shell = new Shell(display); shell.setText("Snippet367"); shell.setLayout(new GridLayout(3, false)); Menu menuBar = new Menu(shell, SWT.BAR); shell.setMenuBar(menuBar); MenuItem fileItem = new MenuItem(menuBar, SWT.CASCADE); fileItem.setText("&File"); Menu fileMenu = new Menu(menuBar); fileItem.setMenu(fileMenu); MenuItem exitItem = new MenuItem(fileMenu, SWT.PUSH); exitItem.setText("&Exit"); exitItem.addListener(SWT.Selection, e -> shell.close()); new Label(shell, SWT.NONE).setText(IMAGE_200 + ":"); new Label(shell, SWT.NONE).setImage(new Image(display, IMAGE_PATH_200)); new Button(shell, SWT.PUSH).setImage(new Image(display, IMAGE_PATH_200)); new Label(shell, SWT.NONE).setText(IMAGE_150 + ":"); new Label(shell, SWT.NONE).setImage(new Image(display, IMAGE_PATH_150)); new Button(shell, SWT.NONE).setImage(new Image(display, IMAGE_PATH_150)); new Label(shell, SWT.NONE).setText(IMAGE_100 + ":"); new Label(shell, SWT.NONE).setImage(new Image(display, IMAGE_PATH_100)); new Button(shell, SWT.NONE).setImage(new Image(display, IMAGE_PATH_100)); createSeparator(shell); new Label(shell, SWT.NONE).setText("ImageFileNameProvider:"); new Label(shell, SWT.NONE).setImage(new Image(display, filenameProvider)); new Button(shell, SWT.NONE).setImage(new Image(display, filenameProvider)); new Label(shell, SWT.NONE).setText("ImageDataProvider:"); new Label(shell, SWT.NONE).setImage(new Image(display, imageDataProvider)); new Button(shell, SWT.NONE).setImage(new Image(display, imageDataProvider)); createSeparator(shell); new Label(shell, SWT.NONE).setText("1. Canvas\n(PaintListener)"); final Point size = new Point(550, 40); final Canvas canvas = new Canvas(shell, SWT.NONE); canvas.addPaintListener(e -> { Point size1 = canvas.getSize(); paintImage(e.gc, size1); }); GridData gridData = new GridData(size.x, size.y); gridData.horizontalSpan = 2; canvas.setLayoutData(gridData); createSeparator(shell); new Label(shell, SWT.NONE).setText("2. Painted image\n (default resolution)"); Image image = new Image(display, size.x, size.y); GC gc = new GC(image); try { paintImage(gc, size); } finally { gc.dispose(); } Label imageLabel = new Label(shell, SWT.NONE); imageLabel.setImage(image); imageLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false, 2, 1)); createSeparator(shell); new Label(shell, SWT.NONE).setText("3. Painted image\n(multi-res, unzoomed paint)"); imageLabel = new Label(shell, SWT.NONE); imageLabel.setImage(new Image(display, (ImageDataProvider) zoom -> { Image temp = new Image(display, size.x * zoom / 100, size.y * zoom / 100); GC gc1 = new GC(temp); try { paintImage(gc1, size); return temp.getImageData(); } finally { gc1.dispose(); temp.dispose(); } })); imageLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false, 2, 1)); createSeparator(shell); new Label(shell, SWT.NONE).setText("4. Painted image\n(multi-res, zoomed paint)"); imageLabel = new Label(shell, SWT.NONE); imageLabel.setImage(new Image(display, (ImageDataProvider) zoom -> { Image temp = new Image(display, size.x * zoom / 100, size.y * zoom / 100); GC gc1 = new GC(temp); try { paintImage2(gc1, new Point(size.x * zoom / 100, size.y * zoom / 100), zoom / 100); return temp.getImageData(); } finally { gc1.dispose(); temp.dispose(); } })); imageLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false, 2, 1)); createSeparator(shell); new Label(shell, SWT.NONE).setText("5. 50x50 box\n(Display#getDPI(): " + display.getDPI().x + ")"); Label box = new Label(shell, SWT.NONE); box.setBackground(display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW)); box.setLayoutData(new GridData(50, 50)); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:Snippet104.java
public static void main(String[] args) { final Display display = new Display(); final int[] count = new int[] { 4 }; final Image image = new Image(display, 300, 300); final Shell splash = new Shell(SWT.ON_TOP); final ProgressBar bar = new ProgressBar(splash, SWT.NONE); bar.setMaximum(count[0]);// w w w . j a v a 2 s . co m Label label = new Label(splash, SWT.NONE); label.setImage(image); FormLayout layout = new FormLayout(); splash.setLayout(layout); FormData labelData = new FormData(); labelData.right = new FormAttachment(100, 0); labelData.bottom = new FormAttachment(100, 0); label.setLayoutData(labelData); FormData progressData = new FormData(); progressData.left = new FormAttachment(0, 5); progressData.right = new FormAttachment(100, -5); progressData.bottom = new FormAttachment(100, -5); bar.setLayoutData(progressData); splash.pack(); Rectangle splashRect = splash.getBounds(); Rectangle displayRect = display.getBounds(); int x = (displayRect.width - splashRect.width) / 2; int y = (displayRect.height - splashRect.height) / 2; splash.setLocation(x, y); splash.open(); display.asyncExec(new Runnable() { public void run() { Shell[] shells = new Shell[count[0]]; for (int i = 0; i < count[0]; i++) { shells[i] = new Shell(display); shells[i].setSize(300, 300); shells[i].addListener(SWT.Close, new Listener() { public void handleEvent(Event e) { --count[0]; } }); bar.setSelection(i + 1); try { Thread.sleep(1000); } catch (Throwable e) { } } splash.close(); image.dispose(); for (int i = 0; i < count[0]; i++) { shells[i].open(); } } }); while (count[0] != 0) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet104.java
public static void main(String[] args) { final Display display = new Display(); final int[] count = new int[] { 4 }; final Image image = new Image(display, 300, 300); GC gc = new GC(image); gc.setBackground(display.getSystemColor(SWT.COLOR_CYAN)); gc.fillRectangle(image.getBounds()); gc.drawText("Splash Screen", 10, 10); gc.dispose();// www.ja v a 2s. c o m final Shell splash = new Shell(SWT.ON_TOP); final ProgressBar bar = new ProgressBar(splash, SWT.NONE); bar.setMaximum(count[0]); Label label = new Label(splash, SWT.NONE); label.setImage(image); FormLayout layout = new FormLayout(); splash.setLayout(layout); FormData labelData = new FormData(); labelData.right = new FormAttachment(100, 0); labelData.bottom = new FormAttachment(100, 0); label.setLayoutData(labelData); FormData progressData = new FormData(); progressData.left = new FormAttachment(0, 5); progressData.right = new FormAttachment(100, -5); progressData.bottom = new FormAttachment(100, -5); bar.setLayoutData(progressData); splash.pack(); Rectangle splashRect = splash.getBounds(); Rectangle displayRect = display.getBounds(); int x = (displayRect.width - splashRect.width) / 2; int y = (displayRect.height - splashRect.height) / 2; splash.setLocation(x, y); splash.open(); display.asyncExec(() -> { Shell[] shells = new Shell[count[0]]; for (int i1 = 0; i1 < count[0]; i1++) { shells[i1] = new Shell(display); shells[i1].setSize(300, 300); shells[i1].addListener(SWT.Close, e -> --count[0]); bar.setSelection(i1 + 1); try { Thread.sleep(1000); } catch (Throwable e) { } } splash.close(); image.dispose(); for (int i2 = 0; i2 < count[0]; i2++) { shells[i2].setText("SWT Snippet 104 - " + (i2 + 1)); shells[i2].open(); } }); while (count[0] != 0) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:SplashScreenCreate.java
public static void main(String[] args) { final Display display = new Display(); final int[] count = new int[] { 4 }; final Image image = new Image(display, 300, 300); GC gc = new GC(image); gc.setBackground(display.getSystemColor(SWT.COLOR_CYAN)); gc.fillRectangle(image.getBounds()); gc.drawText("Splash Screen", 10, 10); gc.dispose();/* ww w .j a va 2 s. c o m*/ final Shell splash = new Shell(SWT.ON_TOP); final ProgressBar bar = new ProgressBar(splash, SWT.NONE); bar.setMaximum(count[0]); Label label = new Label(splash, SWT.NONE); label.setImage(image); FormLayout layout = new FormLayout(); splash.setLayout(layout); FormData labelData = new FormData(); labelData.right = new FormAttachment(100, 0); labelData.bottom = new FormAttachment(100, 0); label.setLayoutData(labelData); FormData progressData = new FormData(); progressData.left = new FormAttachment(0, 5); progressData.right = new FormAttachment(100, -5); progressData.bottom = new FormAttachment(100, -5); bar.setLayoutData(progressData); splash.pack(); Rectangle splashRect = splash.getBounds(); Rectangle displayRect = display.getBounds(); int x = (displayRect.width - splashRect.width) / 2; int y = (displayRect.height - splashRect.height) / 2; splash.setLocation(x, y); splash.open(); display.asyncExec(new Runnable() { public void run() { Shell[] shells = new Shell[count[0]]; for (int i = 0; i < count[0]; i++) { shells[i] = new Shell(display); shells[i].setSize(300, 300); shells[i].addListener(SWT.Close, new Listener() { public void handleEvent(Event e) { --count[0]; } }); bar.setSelection(i + 1); try { Thread.sleep(1000); } catch (Throwable e) { } } splash.close(); image.dispose(); for (int i = 0; i < count[0]; i++) { shells[i].open(); } } }); while (count[0] != 0) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }