import java.awt.*;

    // Continuously animate a narrow arc.
public class MovingArcCanvas extends Canvas {
    public MovingArcCanvas(){
        // setBackground(Color.white);
        // setForeground(Color.black);
    }

    public void paint(Graphics g){
        Dimension size = getSize();

        final int x = size.width/4, y = size.height/4;
        final int width = size.width/2, height = size.height/2;

        MovingArc arc = getArc();
        final int startAngle = arc.getAngle();
        final int arcWidth = arc.getWidth();
        g.fillArc(x,y,width,height,startAngle,arcWidth);
    }

        // Perform the next animation step.
    public void step(){
        Graphics g = getGraphics();

        if(g != null){
            // Clear last arc.
            g.setColor(getBackground());
            paint(g);

            getArc().step();

            // Draw the current arc
            g.setColor(getForeground());
            paint(g);
        }
    }

    protected MovingArc getArc(){
        return arc;
    }

    // Move clockwise.
    private final int increment = -1;
    // The arc to be animated.
    private final MovingArc arc = new MovingArc(increment);
}

