See How to Writer a Mouse Listener and Mouse Motion Listener. Change the coordinates of the line based upon mouse clicks and mouse motion