How do I load images (possibly for animation) without flickering?

Rahul kumar Gupta

To Load an images without flickering then you have use the concept called double buffering.

Steps to be followed

  1. create an object of image class
  2. create and object of Mediatracker class
  3. add image object to Mediatracker
  4. check whether image is loaded or not before painting

Here is an example

class SomeClass {

 MediaTracker tracker;
 Image img;

  //adding image to tracker
  tracker = new MediaTracker(this);

  public void paint(Graphics g) {
    // waiting to get image loaded

  //method that will return true if particular image is loaded
  public boolean photochecked(int no) {
    int pchecked=no;
    while(pchecked ==no) {
    return true;
0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.