Check out this URL
www.ecs.umass.edu/.../
drawingImages.html
Its from the 2D graphics section of the Java tutorial.
In the example displays an image on an applet and scales it. In your
case, you want to display an image on a JPanel (I'm assuming that you
are using Swing but it should work if you are using the Panel object
from AWT).
import javax.swing.*;
public class ImagePanel extends JPanel {
Image image;
...
image = getImage(getCodeBase(), "../images/rocketship.gif");
...
public void paint(Graphics g) {
g.drawImage(image, 0, 0, getWidth(), getHeight(), this);
}
}
The getWidth() and getheight() should return the width and height of
the JPanel.