You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Graphics, AWT, Swing I part<br />
Receive our newsletter with new tips! Almost 6,000 subscribers (by June 2001) can not be wrong!<br />
They read our tips every week! To subscribe to The <strong>Java</strong> FAQ Daily send empty e-mail to:<br />
javafaq-tips-subscribe@topica.com or visit at:<br />
http://www.topica.com/lists/javafaq-tips/<br />
Graphics, AWT, Swing<br />
How can I minimise "Flicker" in animation? Solution 1:<br />
Answer: Solution 1:<br />
Visit us here and you will find<br />
much more tips!<br />
Override update() : Flickering in animation occurs because default update() method<br />
clears the screen of any existing contents and then calls paint(). To reduce flickering,<br />
therefore, override update(). Here is how just add the following code to your applet:<br />
public void update(Graphics g) {<br />
paint(g);<br />
}<br />
What the update is now doing is just calling paint() and not clearing it, a further<br />
refinement to the above will be to override update() method and painting only the<br />
region where the changes are taking place. Here is how:<br />
public void update(Graphics g) {<br />
g.clipRect(x, y, w, h);<br />
paint(g);<br />
}<br />
Solution 2 will be described tomorrow<br />
How can I minimise "Flicker" in animation? Solution 2:<br />
Solution 1 was described in our tip yesterday<br />
Solution 2:<br />
Use double-buffering : double buffering is the process of doing all your drawing to an<br />
file:///F|/350_t/350_tips/graphics-I.htm (1 of 6) [2002-02-27 21:18:07]