This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes How do I find mouse location Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How do I find mouse location" Watch "How do I find mouse location" New topic
Author

How do I find mouse location

Tom Flanagan
Greenhorn

Joined: Mar 03, 2004
Posts: 5
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

Joined: Jan 29, 2003
Posts: 8791
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.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Igor Ko
Ranch Hand

Joined: Jun 24, 2002
Posts: 90
Yes... but if it's wireless mouse ???
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Originally posted by Igor Ko:
Yes... but if it's wireless mouse ???

Then you have to get the assistance of your cat.


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791


But we didn't help the poor guy much, did we.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12756
    
    5
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

Joined: Apr 27, 2004
Posts: 1
Hello.
Download the new J2SE 1.5 SDK and use:
MouseInfo.getPointerInfo().getLocation();
Hope that helps!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do I find mouse location
 
Similar Threads
mouse curser
Current mouse location...
NetBeans IDE 5.5
Getting current mouse position
mouse clicks