Java Example Program / Sample Source Code
import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Image;
public class ShowImageApplet extends Applet {
private Image image;
public void init() {
image = getImage(getDocumentBase(), "images/draw.png");
}
public void paint(Graphics g) {
int w = image.getWidth(null);
int h = image.getHeight(null);
g.drawImage(image, (400 - w) / 2, (400 - h) / 2, this); // centered
}
} |
|
|