import org.eclipse.swt.widgets.*; Display display = new Display(); Shell shell = new Shell(display); Label label = new Label(shell, SWT.NONE); label.setText("Hello, World!"); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose();
import org.eclipse.swt.graphics.*; import org.eclipse.swt.widgets.*; Display display = new Display(); Shell shell = new Shell(display); Image image = new Image(display, "path/to/image.png"); Label label = new Label(shell, SWT.NONE); label.setImage(image); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose();This code creates an SWT window with a Label widget that displays an image loaded from a file. The image is loaded into an Image object using the Display object's constructor, and then the Label's setImage() method is called to display the image in the Label widget. The package library for the SWT widgets is typically included in the Eclipse IDE or can be downloaded separately as a set of Java libraries.