0

I'm drawing a line using the drawLine() method of the Graphics class. Using mouseMoved and mouseDragged i'm drawing the line using the Mouse. When I go to draw another line with the mouse, the first line disappears, how can I have all lines drawn to remain on the applet ?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Mutating Algorithm
  • 2,604
  • 2
  • 29
  • 66
  • 1
    Put the points into some kind of list, use the applet's `paint` method to draw lines between these points by iterating over the list – MadProgrammer Nov 24 '15 at 22:41
  • For [example](http://stackoverflow.com/questions/22927818/create-a-trailing-line-of-blood-behind-a-player/22928302#22928302), [example](http://stackoverflow.com/questions/24374970/why-is-my-line-not-drawing/24376444#24376444), [example](http://stackoverflow.com/questions/23966290/java-paint-not-drawing-in-swing/23966309#23966309) – MadProgrammer Nov 24 '15 at 22:43
  • @MadProgrammer What two mouse events would I use to get the two end points (each line has 4 points that i need to store) ? mousePressed and mouseReleased ? – Mutating Algorithm Nov 25 '15 at 00:16
  • If you want to do click, move click line drawing, then yes, `mousePressed` and `mouseReleased` at you best options, the `MouseEvent` will provide you with the `x/y` point of each event – MadProgrammer Nov 25 '15 at 00:18

0 Answers0