• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
  • Carey Brown
  • salvin francis
  • Claude Moore

Robot.moveCursor doesn't work  RSS feed

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm working on a graphics program that displays a plot and, when the user moves the cursor over the plot, moves to the (x,y) location of the data point.  To do this, I'm using a Robot.  However, when I implement this code in a mouse move event, the mouse jumps around to random locations on the screen.

So, I simplified the code so it only moves to the current mouse location.  You should see no effect, but the mouse still jumps around the screen.

Master Rancher
Posts: 3189
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi bobt,

welcome to the Ranch and enjoy the stay!

If 'r' is a Robot, then r.mouseMove(x, y) moves the cursor to the screen coordinates (x, y). The coordinates that you receive as arguments to the mouseEvent are coordinates relative to the panel origin (or the relevant component that has the MouseListener attached).

So, you have to translate the MouseEvent coordinates to Screen coordinates (use the method getLocationOnScreen)
I've never won anything before. Not even a tiny ad:
Create Edit Print & Convert PDF Using Free API with Java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!