Example: I have a timer that recalculates the x/y coordinates of a line and calls repaint();
Now, everytime paint() is executed, the complete component is redrawn and the line moves thus creating an animation. What I want is keep a copy of the old frame still visible, so each call to paint() should add a new line to the graphic context without erasing the background.
I know two ways of doing this:
- add lines to an Image object then draw the image in paint()
- add all lines to an array and redraw all lines each time paint() is called
In both cases, the redrawing becomes slow if the component is big, if the number of elements to add to the image increases, and if the whole component is transformed.