aspose 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
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.
 
 
subject: MouseEvent x,y relative to entire screen