public static Image loadImage(String path, boolean inJar)
{
Image newImage = null;
try
{
if(inJar)
{
newImage = new Image(null, YOUR_MAIN_CLASS.class.getClassLoader().getResourceAsStream(path));
}
else
{
newImage = new Image(null, path);
}
}
catch(SWTException ex)
{
System.out.println("Couldn't find " + path);
e.printStackTrace();
}
return newImage;
}
getResourceAsStream(path) 함수를 이용해 불러와야 한다.
ResourceAsStream이 아닌 Resource는 URL만 리턴할 뿐이다.
'Java' 카테고리의 다른 글
jar파일의 현재 path 얻어내기 (0) | 2015.04.30 |
---|---|
Java 한글 입출력 깨지지 않는 법 (0) | 2015.04.13 |
현재 디렉토리명 얻기 (0) | 2015.04.09 |