// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.applet.Applet;
import java.awt.Graphics;

public class RepaintApplet extends Applet implements Runnable {
    private String s = "*";
    public RepaintApplet() {
        super();
        setSize(200, 200);
        (new Thread(this)).start();
    }
    public void paint(Graphics g) {
        g.drawString(s, 100 - 5 * s.length() / 2 , 100);
    }

    public void run() {
        for(int i = 0; i < 30; i++) {
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
            }
            s = s + "*";
            repaint();
        }
        for(int i = 0; i < 30; i++) {
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
            }
            s = s.substring(1);
            repaint();
        }
    }
}
