Q:

Canvas blinks when constantly repainting

I'm making an app which contains a java.awt.Canvas to display a sequence of conected nodes like in a graph. while editing, the last dot is conected to the mouse cursor with a java.awt.geom.Line2D so that it must be repainted everytime the user moves the mouse, and it causes a really disgusting -flashy- effect on screen.
I did this once before, and I know the solution was so easy and didn't need a really hard code, but to mess around with paint(g), repaint(g) and update(g) methods, despite it, I cannot manage to solve it and hope someone can help me!
Lots of thanks in advance!! :)

A:

You need to do Double Buffering to get rid of the flickering. Loads of examples if you google for it.
Found a previous question that has more info.
Here is another example.

