| Author |
method for mouse when the mouse stopped Dragging but is not released yet
|
Bobby Marvikuan
Ranch Hand
Joined: Mar 14, 2012
Posts: 54
|
|
Hello. I am interested how to do this thing:
for e.g., I want to draw a square when the mouse stopped Dragging but is not released yet? I tried mouse pressed but it calls it only at the beginning. So, I have no idea, any help?
Cheers in advance!
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32712
|
|
|
Can’t think of any offhand, even though I once had to program the same sort of thing. There are 7 mouse methods that I can remember, in the MouseListener interface and in MouseMotionListener. They are for when the mouse isclickeddepressedreleasedenters the Componentleaves the Componentmovedand draggedI think mouseDragged is the most likely to work. Try the two opposite corners with pressed giving you one pair of x, y (first corner) and dragged (repeatedly) giving you the x, y for the other corner.
|
 |
Darryl Burke
Bartender
Joined: May 03, 2008
Posts: 4167
|
|
If you want to draw a square (rectangle?) when the drag is stopped but don't want to draw while the mouse is still being dragged, you need to start by defining 'stopped' in terms of time/duration and drift/pixels (since the user may, like me, have a shaky hand) even before you begin coding.
You'd want to use a Swing Timer for that.
|
luck, db
There are no new questions, but there may be new answers.
|
 |
 |
|
|
subject: method for mouse when the mouse stopped Dragging but is not released yet
|
|
|