All About Class MediaTracker in AWT in Java

0
109
Spread the love
  • 29
  • 34
  • 28
  • 35
  •  
  •  
  •  
  • 12
  •  
  •  
    138
    Shares

MediaTracker in Java
MediaTracker in Java

MediaTracker in Java:

The MediaTracker class is an utility class to trace the status of number of media objects.Media objects could include images as well as audio clips(through currently only images are supported). So MediaTracker loads and keeps track asynchronously of the status of any number of Image objects.To use the media tracker,we need to create an instance of the MediaTracker class and then call addImage() method for each image we want to track.In addition each image can be assigned as unique identifier.The identifier controls both the priority order in which the images are fetched as well as in identifying unique subsets of the images that can be waited on independently. Images with a lowed id are labeled in preference to those with a higher ID number.

The class structure of class MediaTracker is given as:


public class java.awt.MediaTracker extends java.lang.Object implements
             java.io.Serializable{
//member elements
public final static final int ABORTED;
//ABORTED=2: flag indicating the download of some media was aborted.
public final static final int COMPLETE;
//COMPLETE=8:flag indicating the download of some media was completed successfully.
public final static final int ERRORED;
//ERRORED=4: flag indicating the download of some media was encountered an error.
public final static final int LOADING;
//LOADING=1: flag indicating that some media is currently being downloaded.
//constructor
public MediaTracker(Component comp);
//creates a media tracker to track images for a given component.
//methods:
public void addImage(Image img,int id);
public synchronized void addImage(Image img,int id,int weight,int height);
public void waitForAll()throws InterruptedException;
public void waitForID(int id)throws InterruptedException;
public synchronized boolean waitForAll(long ms)throws InterruptedException;
public synchronized boolean waitForID(int id,long ms)throws InterruptedException;
public boolean checkAll();
public boolean checkAll(boolean load);
public boolean checkID(int id);
public boolean checkID(int id,boolean load);
public synchronized boolean isErrorAny();
public synchronized boolean isErrorID(int id);
public synchronized Object[] getErrorAny();
public synchronized Object[] getErrorsID(int id);
public int statusAll(boolean load);
public int statusID(int id,boolean load);
public synchronized void removeImage(Image image);
public synchronized void removeImage(Image image, int id);
public synchronized void removeImage(Image image, int id, int width, int height);
}
 

Spread the love
  • 29
  • 34
  • 28
  • 35
  •  
  •  
  •  
  • 12
  •  
  •  
    138
    Shares

LEAVE A REPLY

Please enter your comment!
Please enter your name here