Drawing Images
The Graphics class provides a method drawImage() to actually display the image:
void paintComponent ( ) {
g.drawImage (img, 10, 10, this) ;
}
- the top left corner of the image will be drawn at (x,y) position (10,10).
- this is the ImageObserver argument—it is the component in which the image is displayed.
You can also scale the image to a particular width and height:
g.drawImage (img, 10, 10, w, h, this) ;