62,623
社区成员
发帖
与我相关
我的任务
分享import java.applet.Applet;
import java.awt.*;
public class juxing extends Applet implements Runnable{
int i;
Image im;
Thread t=null;
public void init(){
setBackground(Color.white);
}
public void start(){
t=new Thread(this);
t.start();
}
public void run(){
while(true)
{
try
{
Thread.currentThread().sleep(1000);
i=i+10;
if(i>300)
i=0;
repaint();
}
catch (InterruptedException e)
{
throw new RuntimeException(e);
}
}
}
public void paint(Graphics g){
g.fillRect(i,80,70,40);
g.drawImage(im,i,80,this);
}
}