File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MouseEvent x,y relative to entire screen

 
Nathan Paris
Greenhorn
Posts: 28
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 313
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 28
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. I actually just found it.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic