File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes MouseEvent x,y relative to entire screen Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "MouseEvent x,y relative to entire screen" Watch "MouseEvent x,y relative to entire screen" New topic
Author

MouseEvent x,y relative to entire screen

Nathan Paris
Greenhorn

Joined: Jun 21, 2000
Posts: 28
Once you recieve a MouseEvent is there a way that you can get the X and Y coordinate relative to the entire screen and not just to the source component?
I have done it by going through all of the Parents of the components until I get the top parent frame and then using its x and y , but want to know if there is a simpeler way.
Thanks
San Su
Ranch Hand

Joined: Jul 06, 2001
Posts: 313

You can use SwingUtilities.convertPointToScreen(Point p, Component c) method to convert a point relative to a component to a point relative to screen. Check out the documentation for more information.

Nathan Paris
Greenhorn

Joined: Jun 21, 2000
Posts: 28
Thanks. I actually just found it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: MouseEvent x,y relative to entire screen
 
Similar Threads
Generating Mouseclick Programmatically
Movement event
MouseMotionListener question
Displaying the window in the center of the MONITOR
Getting pixel information for mouse movement