No Double Buffering

Let's look at the code, which can be found in WDB.java:

Line 1 and 2 specify what classes to import. These are the, by now familiar:

        import java.awt.*;
        import java.applet.Applet;
Line 4 specifies the WDB class as extending the Applet class. It starts by declaring an image:
	public class WDB extends Applet {
		Image background;
The image will hold the image to be painted in the background.

Initialization

In the init() function we just get the image and store it in background:
	public void init() {
		background = getImage(getCodeBase(), "./images/ANIM0.GIF");
	}

Painting

The paint method just draws the image on the screen without waiting for the image to be completely loaded:
	public void paint(Graphics g) {
		g.drawImage(background, 0, 0, this);
	}


Back to Lecture2