• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

How do I find mouse location

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes... but if it's wireless mouse ???
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


But we didn't help the poor guy much, did we.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello.
Download the new J2SE 1.5 SDK and use:
MouseInfo.getPointerInfo().getLocation();
Hope that helps!
reply
    Bookmark Topic Watch Topic
  • New Topic