Mega Code Archive

 
Categories / Java Tutorial / SWT
 

Images created using different flags for Label

import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; public class ImageCreateForLable {   public static void main(String[] args) {     Image image;     Image copy;     Image disable;     Image gray;     Display display = new Display();     Shell shell = new Shell(display);     shell.setText("Show Image Flags");     image = new Image(display, "yourFile.gif");     copy = new Image(display, image, SWT.IMAGE_COPY);     disable = new Image(display, image, SWT.IMAGE_DISABLE);     gray = new Image(display, image, SWT.IMAGE_GRAY);     shell.setLayout(new FillLayout());     // Create labels to hold each image     new Label(shell, SWT.NONE).setImage(image);     new Label(shell, SWT.NONE).setImage(copy);     new Label(shell, SWT.NONE).setImage(disable);     new Label(shell, SWT.NONE).setImage(gray);     shell.pack();     shell.open();     while (!shell.isDisposed()) {       if (!display.readAndDispatch()) {         display.sleep();       }     }     image.dispose();     copy.dispose();     disable.dispose();     gray.dispose();     display.dispose();   } }