by Dinesh Thakur Category: AWT and Applets

When the images are initially loaded, they are only partially displayed as they may not have been loaded completely. Mediatracker tracks the status of the number of media objects which includes audio clips as well as images. Secondly, it also determines if an image has been completely loaded.

To use a media tracker, create an instance of MediaTracker and call its addImage method for each image to be tracked. In addition, each image can be assigned a unique identifier. This identifier controls the priority order in which the images are fetched. It can also be used to identify unique subsets of the images that can be waited on independently. Images with a lower ID are loaded in preference to those with a higher ID number.

          import java.applet.Applet;

          import java.awt.*;
          import java.awt.event.*;
          /* <APPLET CODE=MediaTrackerClass.class WIDTH=400 HEIGHT=200 > </APPLET> */
          public class MediaTrackerClass  extends Applet implements AdjustmentListener
                    Image image;
                   Scrollbar horiz=new Scrollbar(Scrollbar.HORIZONTAL,0,400,0,500);
                   Scrollbar vert=new Scrollbar(Scrollbar.VERTICAL,0,400,0,500);
                   public void init()
                   setLayout(new BorderLayout());
                      void loadImage()
                          Toolkit toolkit=getToolkit();
                      MediaTracker tracker=new MediaTracker(this);
                                   catch(InterruptedException ex)
                                  public void paint(Graphics g)
                                      public void adjustmentValueChanged(AdjustmentEvent e)

MediaTracker Class in java 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