public class ScrollingBanner2 extends ScrollingBanner
1: /*
2: * Copyright (c) 1999-2002, Xiaoping Jia.
3: * All Rights Reserved.
4: */
5:
6: import java.awt.*;
7:
8: /**
9: * An enhanced version of the scrolling banner applet.
10: * It uses double-buffering to eliminate the flickering.
11: */
12: public class ScrollingBanner2 extends ScrollingBanner {
13:
14: protected Image image; // The off-screen image
15: protected Graphics offscreen; // The off-screen graphics
16:
17: public void update(Graphics g) {
18: // create the offscreen image if it is the first time
19: if (image == null) {
20: image = createImage(d.width, d.height);
21: offscreen = image.getGraphics();
22: }
23:
24: // draw the current frame into the off-screen image
25: // using the paint method of the superclass
26: super.paint(offscreen);
27:
28: // copy the off-screen image to the screen
29: g.drawImage(image, 0, 0, this);
30: }
31:
32: public void paint(Graphics g) {
33: update(g);
34: }
35:
36: }