Override paintComponent, not paint. This restricts your (re)paint to the client area only. Do not override repaint, just call it when necessary.
Do not call super.paintComponent in your paintComponent, because that's where the old content is being cleared. Just go ahead and paint the new stuff.
For more details see the second half of this:
http://java.sun.com/products/jfc/tsc/articles/painting/
JamesCherrill
... trying to help
8,516 posts since Apr 2008
Reputation Points: 2,583
Solved Threads: 1,455
Skill Endorsements: 30
Another solution is to create a working image with BufferedImage, draw your lines on the working image and then in the paintComponent method, draw the working image on the screen.
Your previously drawn figures would be preserved in the working image. This approach would be similiar to the double buffering technique.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16