Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do I find mouse location

 
Tom Flanagan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know how to find a mouse location inside a Java JFrame - but is there any way to find the mouse location on the desktop (say in Windows xp) without being in a JFrame?
With Toolbox you can find the resolution of the desktop. With the robot class I can move the mouse around - butI can't find a way to find the current location of the mouse. Any help?
Thanks
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some night I'm going to answer a whole bunch of questions just by reading the subject line and not the actual note. Find the mouse by following the cord from the PC. It's out there on the end. Sorry, I'll go away now.
 
Igor Ko
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes... but if it's wireless mouse ???
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Igor Ko:
Yes... but if it's wireless mouse ???

Then you have to get the assistance of your cat.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


But we didn't help the poor guy much, did we.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13056
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only time I have seen mouse position messages when the mouse is outside the Java controlled area is when a mouse_down occurred inside the area and the button stayed down when the mouse moved outside.
I suspect that operating system specific native code would be required to get it otherwise. Basically, Java only gets mousemessages when the mouse is in the controlled area.
Bill
 
Charlie Hayes
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello.
Download the new J2SE 1.5 SDK and use:
MouseInfo.getPointerInfo().getLocation();
Hope that helps!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic