Mouse clicking and mouse dragging
I have a component that extends JPanel, when I click my mouse on it I want it to do one thing (This I can do easily by adding a mouseactionlistener). However when I drag the mouse I want my mousemotionlistener to get the start and end X co-ords so that when the user releases the mouse button I know where they start dragging form and where they dragged to and then it can do something else.
Any ideas ? as I can't think how to do it at the moment
[468 byte] By [
ajpurkiss] at [2007-9-26 1:59:44]

I solved this myself. It was so easy I can't think why i did not do it in the first place.
Made my own listener that extended mouseInputListener and then added this.
On mouse press I get the first X co-ord, on drag I keep track of the X coord so I can draw something at the current mouse position if needs be and on mouse release I get the final X corod. If x coord 1 = last x coord then I treat it as a mouse click. Although I may alter it so that if a drag happens it sets a flag so if start and end X are the same I discard it.
you can also use global vars and in void MouseListener.MousePressed(MouseEvent) remember the the x and y then in void MouseListener.MouseReleased(MouseEvent) also take x and y and that would be where it draged to, I think this is what you want...