aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes method for mouse when the mouse stopped Dragging but is not released yet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "method for mouse when the mouse stopped Dragging but is not released yet" Watch "method for mouse when the mouse stopped Dragging but is not released yet" New topic
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: 39409
    
  28
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 is
  • clicked
  • depressed
  • released
  • enters the Component
  • leaves the Component
  • moved
  • and dragged
  • I 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: 4642
        
        5

    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.
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
     
    subject: method for mouse when the mouse stopped Dragging but is not released yet