Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Mouse position relative to screen

Reply
Thread Tools

Mouse position relative to screen

 
 
qed qed is offline
Junior Member
Join Date: May 2007
Posts: 1
 
      05-28-2007
Quote:
Originally Posted by MAB
How do I get the position of the mouse relative to the top left of the
screen. The MouseMotionListener works relative to some component of the app
but what if I have no visual component and I want the absolute position of
the mouse?

thx
Point mousePosition = java.awt.MouseInfo.getPointerInfo().getLocation();
 
Reply With Quote
 
 
 
 
chrisbster chrisbster is offline
Junior Member
Join Date: May 2009
Posts: 1
 
      05-13-2009
import java.awt.*;
PointerInfo a = MouseInfo.getPointerInfo();
Point b = a.getLocation();
int x = (int)b.getX();
int y = (int)b.getY();
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mouse position in both fixed and relative positioning Nikolai Prokoschenko Javascript 2 05-18-2011 11:25 AM
Screen Capture With Mouse , Mouse Position Capture Max Java 7 08-08-2009 11:51 PM
Zoom relative to mouse position Amir Kouchekinia Java 6 05-23-2008 03:28 AM
Where is Form Relative Position and Absolute Position in VS.Net 2005 ? Luqman ASP .Net 1 02-07-2006 10:27 AM
iframe relative mouse position madmike Javascript 2 07-17-2003 06:58 PM



Advertisments