Re: Double buffer help




"Ian Shef" <invalid@xxxxxxxxxxxxx> wrote in message
news:Xns979C800D25A1Bvaj4088ianshef@xxxxxxxxxxxxxxxxxx
"Martin" <zedolf@xxxxxxxx> wrote in news:c9adncRoxOlOOazZRVnyiA@xxxxxxxxx:


Brilliant!

No, but thanks.

Yep my timer thread was calling repaint().
I had a quick Google and found an example of using the update() method.

An excellent resource for painting issues is
"Painting in AWT and Swing":

http://java.sun.com/products/jfc/tsc/articles/painting/index.html



I simply duplicated the code from my paint() method in the update()
method and gave that a try and it's perfect.
Nooooooooooooo !!

You are setting yourself up for a maintenance and debug nightmare.
Provide the code in only ONE place!
Either:
1) Locate the code in paint(), and have update() call paint(), OR
2) Locate the code in update(), and have paint() call update(), OR
3) Locate the code in a new method, and have both paint() and update(0
call the new method.

The flicker has disappeared.

Glad to hear it.

I've updated the temporary webpage too - both the old (flickering)
applet and the new improved applet can both be seen in action.
http://www.warwound.dsl.pipex.com/applet/panViewer.htm

Nice contrast between the two cases. Thanks, I rarely get to see such a
visible result of my advice.

Thanks a lot - very easy and quick for me to fix it once i was pointed
in the right direction.

Martin.



Happy to have helped.
-- Ian



--
Ian Shef 805/F6 * These are my personal opinions
Raytheon Company * and not those of my employer.
PO Box 11337 *
Tucson, AZ 85734-1337 *

Thanks for the advice about duplicating the drawing code.

I've rewritten my applet and created a new method which i've called
displayRedraw() and moved the code to that method.
Then both paint() and update() methods merely call my new displayRedraw()
method and all works as before - even makes the compiled class file a very
little bit smaller too.

I'll take a look at the "Painting in AWT and Swing" link later when i have
more time.

Thanks again.

Martin.


.



Relevant Pages

  • Re: Simple Problem - Question from Book
    ... Sonia, ... >>painting is handled by the paint method, which is turn calls things like ... > that will help an elementary school student learn multiplication. ... > on the applet and ask another multiplication question. ...
    (comp.lang.java.help)
  • Re: JPanel not visible in JApplet
    ... drawing is done by paint() and not init(). ... called when your applet is first invoked. ... the the Panel was painted. ...
    (comp.lang.java)
  • refreshing 2D Graphics screen problem
    ... The following program is an applet that reads a number from a file 10 ... that the method paint is performed. ... public class Shapes extends JApplet { ...
    (comp.lang.java)
  • Re: Double buffer help
    ... An excellent resource for painting issues is ... "Painting in AWT and Swing": ... I simply duplicated the code from my paint() method in the update ... applet and the new improved applet can both be seen in action. ...
    (comp.lang.java)
  • Re: how and when components get their own size?
    ... First access of the applet is working fine. ... without closing the browser) and hitting again the applet's page the applet crashes because ... Displaying applet's page always causes init() and start, ... them in paint() or paintComponentmethod of custom component. ...
    (comp.lang.java.gui)