• Post Reply Bookmark Topic Watch Topic
  • New Topic

Urgent Question about paint in Canvas

 
Richard Wilson
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,I am using Java to do Bresenham line drawing homework.Users can drag lines on an canvas and a series of circles will show as a result of the algorithm.
However,when I resize the canvas or make it reexposed, the previous generated lines will disappear. I know it is due to the calling of paint method in canvas.But anyone can tell me how can I restore previously user-drawing lines when the canvas is reexposed or resized?
Thank u.
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By default the update() method clears the screen and then calls paint().
If you do not want the screen cleared, then override the update() method to ONLY call paint() and the previous stuff will stay there.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!