Display an Image
Here is the applet: Solution
//Purpose: Open an image from the same directory as the web-page
// that includes this applet and display it to the screen.
import java.awt.*;
import java.applet.Applet;
public class test7 extends Applet {
Image butch;
public void init() {
butch = getImage(getDocumentBase(), "B.jpg");
}
//draw as must as you can of the image.
// Note that we use the Applet itself (this) as
// an object that implements the ImageObserver interface
// the applet inheirits this from is Component superclass.
// this monitors the loading of the Image.
public void paint(Graphics g) {
g.drawImage(butch, 0, 0, this);
}
}
|