내가 JLabel의에서 애니메이션 GIF를로드하기 위해 노력하고있어 이상한 것들하지만이 작동하는 동안 :로드 애니메이션 GIF는
URL urlsd;
try {
urlsd = new URL("http://pscode.org/media/starzoom-thumb.gif");
ImageIcon imageIcon = new ImageIcon(urlsd);
JLabel progress = new JLabel(imageIcon);
progress.setBounds(5, 20, 66, 66);
contentPane.add(progress);
} catch (MalformedURLException e) {
e.printStackTrace();
}
이, 다른 한편으로는, 나는 싶지 않아하지 않습니다 GIF가 이미 있기 때문에 URL에서 GIF를 가져옵니다. 로드 결과이는 GIF의 첫 번째 프레임을 보여줍니다
try {
ImageIcon imageIcon = new ImageIcon(ImageIO.read(ClassLoader.getSystemResourceAsStream("res/images/progress_indicator.gif")));
JLabel progress = new JLabel(imageIcon);
imageIcon.setImageObserver(progress);
progress.setBounds(5, 20, 66, 66);
contentPane.add(progress);
} catch (MalformedURLException e) {
e.printStackTrace();
}
내가 이것에 대한 추론이 있어야 같아요 ....하지만 그것을 찾을 수 없습니다 ...
감사합니다! 알렉스
클래스 로더는,이 링크를 시도,이 몇 가지 도움이 될 수있는 희망을 정말 액세스,'응용 프로그램 Resources'의 방법이 아니다, [프로젝트에 이미지를로드하는 방법 (http://stackoverflow.com/ 9864657/load-icon-image-exception/9866659 # 9866659) –
이 [Java 문서] (http://docs.oracle.com/javase/7/docs/technotes/guides/)에 설명 된대로 ClassLoader를 사용하지 않는 이유는 무엇입니까? lang/resources.html), "모든 클래스 로더는 클래스 파일 검색과 유사한 방식으로 시스템 리소스로 먼저 리소스를 검색합니다" –
@AlejandroVK : 작업 예제에서 this [thread] (http : //stackoverflow.com/questions/9721421/show-image-by-click-jbutton/9722205#9722205) –