package javaGame;
import java.awt.*;
import java.applet.*;public class Ball extends Applet  implements Runnable {
int x = 100;
int y = 20;
int r = 10; 
public void init() 
{

} public void start() 
{
//定义一个新的线程
Thread th=new Thread(this);
th.start();
} public void stop() { } public void destroy() { } public void run () {
//
while(true)
{
//重画applet画面
repaint();
try
{
//暂停线程20毫秒
Thread.sleep(2);
}
catch(InterruptedException ex)
{

}
while(true)
{
//设置动画移动速度
y+=1;
}
}
} public void paint (Graphics g) {
//设置球的颜色
g.setColor(Color.blue);
//从x,y位置处画一个实心的圆
g.fillOval(x,y,2*r,2*r);
// g.drawString("xiaosheng",100,100); 
} }