/* 
 * Copyright (c) 1999-2002, Xiaoping Jia.  
 * All Rights Reserved. 
 */

import java.awt.*;

/**
 *  An enhanced version of the scrolling banner applet.
 *  It uses double-buffering to eliminate the flickering. 
 */
public class ScrollingBanner2 extends ScrollingBanner {

  protected Image image;          // The off-screen image
  protected Graphics offscreen;   // The off-screen graphics

  public void update(Graphics g) {
    // create the offscreen image if it is the first time
    if (image == null) {
      image = createImage(d.width, d.height);
      offscreen = image.getGraphics();
    }

    // draw the current frame into the off-screen image
    // using the paint method of the superclass
    super.paint(offscreen);

    // copy the off-screen image to the screen
    g.drawImage(image, 0, 0, this);
  }

  public void paint(Graphics g) {
    update(g);
  }

}