Return to article

Painting Each Frame: Example3Applet

One frame per second:

Five frames per second:

Twenty frames per second:

This applet is a further extension of the previous example. It adds the paint() method to draw the current frame number to the screen. The actual code for this applet is in Example3Applet.java. This is the new method:

    /**
     * Paint a frame of animation.
     */
    public void paint(Graphics g) {
	g.setColor(Color.black);
	g.drawString("Frame " + frame, 0, 30);
    }