Source of DoubleBufferHandler.java


  1: import java.awt.*; 
  2: 
  3: public class DoubleBufferHandler {
  4:   public DoubleBufferHandler(DoubleBufferedComponent comp) {
  5:     this.comp = comp; 
  6:   }
  7: 
  8:   final public void update(Graphics g) {
  9:     if (im == null) {
 10:       d = comp.getSize(); 
 11:       im = comp.createImage(d.width, d.height);
 12:       offscreen = im.getGraphics();
 13:     }
 14:     comp.paintFrame(offscreen); 
 15:     g.drawImage(im, 0, 0, comp);
 16:   }
 17: 
 18:   DoubleBufferedComponent comp; 
 19: 
 20:   /** The size of the viewing area */ 
 21:   protected Dimension d;         
 22:   
 23:   /** The off-screen image */
 24:   protected Image im;
 25:   
 26:   /** The off-screen graphics */
 27:   protected Graphics offscreen;
 28:    
 29: }