我图片怎么显示不出来啊,求各位大佬帮忙!
package 线程;
import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Image;
public class UseRunnable extends Applet implements Runnable {
Thread t;
Image imgs[];
int high,h1,h2,h3;
public void init()
{
high=getHeight()/3;
h1=high;
h2=2*high;
h3=3*high;
imgs=new Image[3];
imgs[0]=getImage(getDocumentBase(), "11.gif");
imgs[1]=getImage(getDocumentBase(), "12.gif");
imgs[2]=getImage(getDocumentBase(), "13.gif");
}
public void start()
{
t=new Thread(this);
t.start();
}
public void stop()
{
t=null;
}
//实现接口的run的方法,获得动画效果
public void run()
{
while(t!=null)
{
try {
Thread.sleep(100);
repaint();
h1--;
//上移,到顶点时睡眠
if(h1==0)
{
Thread.sleep(3000);
h2=high;
}
//上移,到顶点时睡眠
h2--;
if(h2==0)
{
Thread.sleep(3000);
h3=high;
}
//上移,到顶点时睡眠
h3--;
if(h3==0)
{
Thread.sleep(3000);
h1=high;
}
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public void paint(Graphics g)
{
//三幅图片依次显示
g.drawImage(imgs[0], 0, h1, this);
g.drawImage(imgs[1], 0, h2, this);
g.drawImage(imgs[2], 0, h2, this);
}
public void update(Graphics g){
paint(g);
}
}