Find the location/Position of JFrame in the window

nebula picture nebula · Oct 31, 2011 · Viewed 18.4k times · Source

I am trying to find the Starting location/position of the JFrame in order to map the mouse cursor from the JFrame window to desktop. Is there anyway to find the X,Y position of JFrame ?

Answer

Harry Joy picture Harry Joy · Oct 31, 2011

You can use getLocation() or getLocationOnScreen() method of JFrame which are inherited from java.awt.Component.