• 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 ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Robot.moveCursor doesn't work  RSS feed

 
Greenhorn
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: 3001
105
  • 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)
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!