Drawing Images to the applet window
The Graphics class provides a method drawImage to actually display the image on the browser screen.
- void paint ( )
- { g.drawImage ( img, 10, 10, this) ; }
- where the top left corner of the image will be drawn at (x,y) position (10,10)
- use “this” as 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.
- void paint ( )
- { g.drawImage ( img, 10, 10, w, h, this) ; }