글쓴이 :최효정 1998년 6월 29일 15:10:53
다음과 같이 이미지를 연속적으로 보여주는 애플릿을 만들었는데... 브라우저에서 제대로 이미지를 출력하질 않네요..
Netscape 에서는 다음과 같은 메세지가 상태막대에 출력됩니다. --> Java.lang.NullPointerException
무엇이 문제인지 가르쳐주실분..... 별거 아닌것이 참 답답하게 만드네요...
import java.awt.*;
import java.applet.*;
import java.lang.*;
public class TestLoadimage extends java.applet.Applet implements Runnable {
int imgidx = 0;
Image imgs[] = new Image[10];
Thread mythread;
public void run() {
for(int i=0, j=1; i<10; i++, j++)
imgs[i] = getImage(getCodeBase(), "t" + j + ".gif");
while ( imgidx < 10) {
repaint();
try { Thread.sleep(100);
} catch(InterruptedException e) {}
imgidx++;
}
}
public void start() {
if(mythread == null) {
mythread = new Thread(this);
mythread.start();
}
}
public void stop() {
if(mythread != null) {
mythread.stop();
mythread = null;
}
}
public void paint(Graphics g) {
g.drawImage(imgs[imgidx], 10, 10, this);
}
}