Home Segments Top Top Previous Next

866: Mainline

You display images within a paint method using drawImage, an instance method of the Graphics class.

First, however, you have to determine the appropriate size for the image. You first determine the size of the Poster instance by using the getSize method to obtain a Dimension instance, d, which then provides width and height instance-variable values for the image component:

Dimension d = getSize(); 
... d.width ...
... d.height ...