All you need to do is extend the JPanel class and override the paintcomponent method in it to also call the function to redraw your graphics like so.
You can find a copy of this program at My prog
Open PQGui and look for the above code, then run it and see how it behaves.
Let me know if this helps you, or if everyone already knows it or a better way..
(Edited by Suke at 12:49 am on Oct. 26, 2004)
We have the same idea in Win32. Though not quite double buffering(unless it happens under the covers), does this really reduce the flickering? I guess the Graphics object is pretty powerful.
Along these lines, I'd like to add my little tip about flicker reduction, double buffering, etc.
Double buffering is a good idea in a lot of applications. It's almost a staple when using any sort of graphics. But be very careful about using it. Do not double buffer everything, unless you really need to. Take some time to calculate which area needs to be redrawn, and redraw only it. This can save a lot of computing power, and allow for smoother repaints, which may or may not be to your liking.