getImage() Example




import java.awt.*;
import java.applet.*;

public class ImageTest extends Applet {
    Image jpgimg, gifimg;

	public void init() {
        jpgimg = getImage(getCodeBase(),
		"MITdome.jpg");
        gifimg = Toolkit.
                 getDefaultToolkit().
                 getImage("cowicon.gif");
	}

    public void paint(Graphics g) {
        g.drawImage(jpgimg, 0, 0, this);
        g.drawImage(gifimg, 180, 5, this);
    }
}
	
Download the source here.
Lecture 3 Slide 18 6.837 Fall '98