why isn't this working on windows but on 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.getResourc开发者_开发问答e(PATH + name);
if (imgURL != null) {
return new ImageIcon(imgURL, description);
} else {
System.err.println("Couldn't find file: " + PATH + name);
return null;
}
}
Because File.separator is the system dependent character for files, which is "/" for mac but "\" for windows. However, in a URL, all of the separators should be '/'. Try changing the first line to be:
public final static String PATH = "resources/";
精彩评论