by Dinesh Thakur Category: AWT and Applets

The java.awt.MediaTracker class is a useful class.It can monitor the progress of any number of images, so you can expect to all images are loaded or to be loaded only specific. Furthermore, can check for errors. The constructor is: public MediaTracker (Component comp) This constructor creates a new MediaTracker for pictures to be displayed in the variable comp, but really this parameter is not particularly important. 

To upload images, a MediaTracker object provides the method following :
public void addImage ( Image image , int id)
This method adds the thumbnail image to the image list to load the object MediaTracker receiving the message . The id variable is used as the number of image identification when using other methods concerning this class.

import java.awt.*;

import java.applet.*;
public class JavaExampleMediaTrackerInJavaApplet extends Applet
    Image Img;
    public void init()
        MediaTracker Trckr = new MediaTracker(this);
        Img = getImage(getDocumentBase(),"Koala.jpg");
            catch (InterruptedException e1) { }
            public void paint(Graphics gr)
               gr.drawImage(Img, 10, 10, this);
/*<APPLET CODE=JavaExampleMediaTrackerInJavaApplet.class WIDTH=600 HEIGHT=150> </APPLET>*/

Java MediaTracker Example

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.

Related Articles