• 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
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

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: 3080
  • 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)
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!