Java - Freeze Mouse -


is there way lock mouse in 1 position in java amount of time?

i've tried this:

while(timer == true){      robot bot = new robot();     bot.mousemove(x, y);  } 

but when user moves mouse jumps unpleasantly , forth (from position user dragging position it's supposed locked).

any ideas if there better way this? or can disable user input mouse? in advance!

this far can go (at least standard libraries). mouse "jumps" system dependent, on "sampling rate" of listener. i'm not aware of jvm parameter affecting it, wouldn't surprised if there in spirit. jumps in opposite relation mouse acceleration (the mouse can move "long" distance between samples).

public class stop extends jframe {      static robot robot = null;     static rectangle bounds = new rectangle(300, 300, 300, 300);     static int lastx = 450; static int lasty = 450;      stop() {          try {             robot = new robot();         } catch (awtexception e) {             e.printstacktrace();         }         addmousemotionlistener(new mousestop());          getcontentpane().add(new jlabel("<html>a sticky situation<br>hold shift out of it", jlabel.center));         setdefaultcloseoperation(exit_on_close);         setbounds(bounds);         setvisible(true);     }      private static class mousestop extends mouseadapter {          @override         public void mousemoved(mouseevent e) {              if(e.isshiftdown()) {                 lastx = e.getxonscreen();                 lasty = e.getyonscreen();             }             else                 robot.mousemove(lastx, lasty);         }     }      public static void main(string args[]) {          new stop();     } } 

edit: have gotten idea involving painting of cursor appear if mouse not moving @ all. i'll add code if working.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -