Monday, September 25, 2006

SWT Image creation from jar file

If you need to include your images in the jar when creating SWT images, this is the way to do it.

Image image = new Image(display, ImageDescriptor.createFromFile(yourClass.class, image_path).getImageData());
Label imageContainer = new Label(shell, SWT.NONE);
imageContainer.setImage(image);

yourClass.class is the class that contains the image, display is the current display, and shell is the control that holds the image label.

0 Comments:

Post a Comment

<< Home