Top.Mail.Ru
September 23rd, 2008 - Java developers — LiveJournal
? ?

Java developers

September 23rd, 2008
 

11:02 am - Imageex_juan_gan - all about java pair class

Java Pair: closer look
Image

07:30 pm - Imagesparkymark - Perplexed: Freezing the mouse pointer

I have some code that successfully freezes the mouse pointer in one place during a drag operation by moving it back to the place it started after every mouseDragged event: I understand why doing that, with the Robot class, would itself provoke a mouseDragged event (the mouse pointer has moved, while the button was down) , but even if I try to handle that and I still find that net *attempted* motion of the mouse pointer (which is what I am trying to measure) is always zero due to mysterious mouseDragged events undoing the pixels that were (attempted to be) covered.

Suggestions welcome: the target application will use an invisible cursor during this drag: I don't want to just have an invisible cursor, for then if the mouse pointer is moved to the edge of the screen it will stop moving and I won't receive any new drag events, so I need to silently keep the mouse somewhere on the component, and then ultimately make the cursor visible in its original position in the mouseReleased method).

Edit: I think it was just a stupid, if subtle, bit of of bad arithmetic, described in the comments: a bit more obvious when the code is boiled down to the minimal reproducer behind the cut...
CodeCollapse )
Powered by LiveJournal.com
Image