爲什麼這不是在Windows上工作,但在Mac上?從資源窗口加載圖像不工作
public final static String PATH = "resources" + File.separator;
/** Returns an ImageIcon, or null if the path was invalid. */
public static ImageIcon createImageIcon(String name, String description) {
java.net.URL imgURL = GuiTools.class.getResource(PATH + name);
if (imgURL != null) {
return new ImageIcon(imgURL, description);
} else {
System.err.println("Couldn't find file: " + PATH + name);
return null;
}
}
不要忘記選擇最有效的答案,方法是單擊答案旁邊的綠色複選框。 – 2011-06-11 14:32:23