コードを実行しようとしています
// Create a label with an image
Image image = new Image(display, "interspatial.gif");
Label imageLabel = new Label(shell, SWT.NONE);
imageLabel.setImage(image);
エラーメッセージが表示されます
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
追加情報:
Eclipse では、Chapter05、次に examples.ch5 を展開し、LabelExample.java を右クリックして、[Run As]、[1 Java Application] の順に選択しました。
interspatial.gif を Chapter05 ディレクトリー、examples ディレクトリー、ch5 ディレクトリー、および images ディレクトリー (おそらく同じ章の他のソース コードに関連する) に配置しようとしました。
「パッケージexamples.ch5;」があります。ファイルの先頭にある行。
画像が読み込まれないのはなぜですか?