trying to run the code
// Create a label with an image
Image image = new Image(display, "interspatial.gif");
Label imageLabel = new Label(shell, SWT.NONE);
imageLabel.setImage(image);
is giving me the error message
Exception in thread "main" org.eclipse.swt.SWTException:
i/o error (java.io.FileNotFoundException: interspatial.gif
(O sistema não pode encontrar o arquivo especificado))
at org.eclipse.swt.SWT.error(Unknown Source)
at org.eclipse.swt.SWT.error(Unknown Source)
at org.eclipse.swt.graphics.ImageLoader.load(Unknown Source)
at org.eclipse.swt.graphics.ImageDataLoader.load(Unknown Source)
at org.eclipse.swt.graphics.ImageData.<init>(Unknown Source)
at org.eclipse.swt.graphics.Image.<init>(Unknown Source)
at examples.ch5.LabelExample.main(LabelExample.java:31)
Caused by: java.io.FileNotFoundException:
interspatial.gif
(O sistema não pode encontrar o arquivo especificado)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at java.io.FileInputStream.<init>(FileInputStream.java:66)
at org.eclipse.swt.internal.Compatibility.newFileInputStream(Unknown Source)
... 5 more
Additional information:
In Eclipse, I had expanded Chapter05, then examples.ch5, then right-clicked LabelExample.java, then chose Run As, then 1 Java Application.
I tried placing interspatial.gif in the Chapter05 dir, the examples dir, the ch5 dir and the images dir (probably related to an other source code from the same chapter).
There is "a package examples.ch5;" line in the beginning of the file.
Why is the image not loading?