home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / VCafe / WDESAMPL.BIN / DoubleBufferPanel.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-06-23  |  1.0 KB  |  33 lines

  1. package actual;
  2.  
  3. import java.awt.Component;
  4. import java.awt.Graphics;
  5. import java.awt.Image;
  6. import java.awt.Panel;
  7. import java.awt.image.ImageObserver;
  8.  
  9. public class DoubleBufferPanel extends Panel {
  10.    Image offscreen;
  11.  
  12.    public void invalidate() {
  13.       super.invalidate();
  14.       this.offscreen = null;
  15.    }
  16.  
  17.    public void update(Graphics var1) {
  18.       this.paint(var1);
  19.    }
  20.  
  21.    public void paint(Graphics var1) {
  22.       if (this.offscreen == null) {
  23.          this.offscreen = ((Component)this).createImage(((Component)this).getSize().width, ((Component)this).getSize().height);
  24.       }
  25.  
  26.       Graphics var2 = this.offscreen.getGraphics();
  27.       var2.setClip(0, 0, ((Component)this).getSize().width, ((Component)this).getSize().height);
  28.       super.paint(var2);
  29.       var1.drawImage(this.offscreen, 0, 0, (ImageObserver)null);
  30.       var2.dispose();
  31.    }
  32. }
  33.