<How to move an existing Line shape in java using ...
# stackoverflow
u
How to move an existing Line shape in java using a mouse? I would like to drag a selected line, but I'm unsure how to do it. I tried the following but it doesn't work and the line doesn't move correctly. What calculations am I missing? var deltaX = mouseEvent.x - (line.startX + line.endX) var deltaY = mouseEvent.y - (line.startY + line.endY) line.startX = line.startX + deltaX line.startY = line.startY +deltaY line.endX = line.endX + deltaX line.endY = line.endX +deltaY