import java.awt.*;
import java.applet.*;
public class Roll extends Applet implements Runnable{
String text="朋友是生活中的阳光";
int x,y;
Thread timer=null;
public void init(){
x=500;
y=50;
}
public void paint(Graphics g){
g.setColor(Color.blue);
g.drawString(text,x,y);
}
public void start(){
if(timer==null){
timer=new Thread(this);
timer.start();
}
}
public void stop(){
timer=null;
}
public void run(){
while(timer!=null){
try{
Thread.sleep(50);
if(x==0) x=500;
else x=x-1;
}catch(InterruptedException e){}
repaint();
}
}
}