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
1 The DigitalClock doesn't flicker, but this illustrates the technique on a short example.
2 public void class DigitalClock extends java.applet.Applet
3 implements Runnable
4 { . . .
5 Image offscreenImg;
6 Graphics og;
7 public void init ( )
8 { offscreenImg = createImage (getSize( ).width, getSize( ).height);
9 og = offscreenImg.getGraphics ( );
10 }
11 public void paint ( Graphics g )
12 { og.setFont ( theFont );
13 og.drawString ( theDate.toString ( ), 10, 50 );
14 g.drawImage ( offscreenImg, 0, 0, this);
15 }
16 public void update ( Graphics g)
17 { paint ( g); }
18 }

in Table To:


© 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