I suggest you to refer following example of Image class', which will give you something idea about the use of this class:
Code:
import org.eclipse.swt.SWT;
java.awt.Image
import org.eclipse.swt.widgets.Shell;
public class ImageDM {
public static void main(String[] arhhgs) {
final Display display = new Display();
final Shell shell1 = new Shell(display);
shell1.setText("Canvas Example");
shell1.setLayout(new FillLayout());
Canvas canvas1 = new Canvas(shell, SWT.NONE);
canvas1.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
Image image = null;
try {
image = new Image(display, ImageLoadFromClassStream.class.getResourceAsStream("test.gif"));
} catch (Exception e1) {
e1.printStackTrace();
}
e.gc.drawImage(image, 25, 5);
}image.dispose();
}
Bookmarks