Basic HTML version of Foils prepared Sept 21 1998

Foil 26 Double Buffering

From Java Tutorial 98- 3: Graphics and the Abstract Windowing Toolkit NAVO Tutorial -- Sept 23 1998. by Geoffrey C. Fox, Nancy McCracken

Movable Objects example with double buffering and boundary checking for Foil 26
The DigitalClock doesn't flicker, but this illustrates the technique on a short example.
public void class DigitalClock extends java.applet.Applet
implements Runnable
{ . . .
Image offscreenImg;
Graphics og;
public void init ( )
{ offscreenImg = createImage (getSize( ).width, getSize( ).height);
og = offscreenImg.getGraphics ( );
}
public void paint ( Graphics g )
{ og.setFont ( theFont );
og.drawString ( theDate.toString ( ), 10, 50 );
g.drawImage ( offscreenImg, 0, 0, this);
}
public void update ( Graphics g)
{ paint ( g); }
}



© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sat Nov 28 1998