You could use the MouseListener interface, it allows you to define the methods:
mouseClicked(MouseEvent e)
Invoked when the mouse has been clicked on a component.
mouseEntered(MouseEvent e)
Invoked when the mouse enters a component.
mouseExited(MouseEvent e)
Invoked when the mouse exits a component.
mousePressed(MouseEvent e)
Invoked when a mouse button has been pressed on a component.
mouseReleased(MouseEvent e)
Invoked when a mouse button has been released on a component.
and when the user clicks, call you need to do is to do some coding within the mouseClicked() method.
What i would do is set a variable when the user clicks it increment it by 1, and simply draw the dot where the mouse clicks (do this by using the event parameter passed into the mouseClicked method "e" and getting the x and y coords) enter the clicked points into a vector and call repaint, then in the paint method go through the array and draw the points.
The reason i said to have a variable is so that when the user clicks, you check the variable to see if it is even, if it is even then call a method to draw a line between the last 2 entries in the vector.
As for moving the points, i really cant help ya there...
A kram a day keeps the doctor......guessing
Bookmarks