Image probe;
Thread t;
public int x=410,y=250;
public void init()
{
//Images Call
probe = getImage(getDocumentBase(),"image/probe.png");
t = new Thread();
}
public void paint(Graphics g)
{
for(int i=0;i<5;i++)
{
g.drawImage(probe,x,y,50,50,this);
g.setColor(Color.red);
System.out.print(i);
x=x+10;
y=y+10;
repaint();
try
{
t.sleep(100);
} catch(Exception e) {}
}
}
所以在这它应该做我的for循环5次正确吗?但相反,它一遍又一遍地做,当我希望它移动 5 次然后停止时,它永远不会停止,而是它只会永远持续下去。