Retrieving mouse location inside a thread relative to an external JPanel.
Okay guys, so here is my problem, I am using making an object follow the mouse, but only when the mouse is pressed, then stop following the mouse when it is released. To do this I of course had to use a separate thread for the movement so the main thread could track when the mouse is released and then stop the separate thread. My problem however, is that I want the movement thread to use coordinates based on the JPanel that the main thread is running, but I don't know how to pass that info on. Right now I am using MouseInfo in the separate thread, but this is only good for finding the mouse location on your whole screen, rather than just within your frame/panel. For example, I want to make it so when my side thread is moving the object, it treats the coordinate 0,0 as the top left corner of the panel that am using, rather than the top left corner of my monitor. So I am wondering if anyone knows a way to pass on the panel info to the side-thread so that it can correctly place the object on the mouse based on where the mouse is in the panel.