Search code examples
javamouse-position

How to get mouse pointer location relative to frame


I want to get mouse location relative to the frame.

MouseInfo give me the absolute location.

How to get poisition relative to the frame? tahnks.


Solution

  • Get the absolute location of the frame with getLocationOnScreen(), and then compute the relative distance.