Display background Image in Applet

Applet Background Image

Displaying backgound Image in an Applet is a two step process.

First – Get the handle to the image using a simplified method getImage() or using the MediaTracker API. This is done in the Applet’s init() method. Using the Media Tracker provides more events/notification that can handled ex.failed to load the media, etc.

Also with Media Tracker a variety of resource types can be retrieved not just image.

Finally – Once the image handle is there, draw the image at a given location in the Applet’s paint(..) method with the drawImage(image,x,y, this) method.

The image can of any format like jpg, gif, png etc.