것은 내가 이미지 아이콘으로 로컬 디렉토리에서 (URL)를 이미지를로드하려고하는 이미지 파일] 파일을 jar 파일 이름의 .jar에서 액세스 .This은 1 로고를 보는 방법Swing을 사용하여 로컬 디렉토리에서 이미지를 가져 옵니까?
F:/>SwingExample
|
|___src
|
|___build.xml
|
|___lib
|
|___swingsex.jar(generated through build.xml file)
|
|__resource
|
|_____images
|
|___logo1.png
같은 swingex.jar.The 프로젝트 구조입니다. PNG 파일?
나는이
file:///f://resources//images//processedimages//
반환ClassLoader.getSystemResource("resources/images/processedimages/");
반환
이 업데이트를 null null로 좋아하는 것을 시도하고있다 : - 아직도 내가 problem.because이 내가 만든 SwingExample에 jar 파일을 만들고 resource/images 디렉토리를 제외합니다. 그되지 자원이/내가 SwingExample 프로젝트를 실행 folder.But 이미지를 통해 작업을 일식 인식 좋아 보입니다 코드를 파일 항아리를 실행 .When 것은
File directory = new File ("."); Image img = null; String path=""; URL url=null; try { path=directory.getCanonicalPath()+"/resources/images/logo1.png"; img = ImageIO.read(new File(getDefaultImageUploadPath()); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return new ImageIcon(img);
구조와 시도가 일치하지 않습니다. – madth3
'ClassLoader.getSystemResource ("resources/images/processedimages /");'대신 다음과 같이 시도하십시오 :'this.getClass(). getResource ("/ resources/images/logo1.png");' –