I’m writing a simple game in Java and are trying to get the coordinates of the mouse. What I want is 0,0 at the upper left corner of the content, however, I get coordinates relative to the Window.

The code is as follows:
public void mouseMoved(MouseEvent event)
{
x = event.getY();
y = event.getX();
}
and this is hooked up via JFrame.addWindowListener()
Any suggestions?
I would make sure you bind your event to the content pane inside the window frame. Then your events should trigger relatively from 0,0 coordinates. Assuming, you don’t need events outside on the main, which for all purposes you could bind a different event handler there.
Another method is to determine the title bar height and window frame width and just subtract them from the given coordinates (since you are positioned adjacent to them inside the game window – if you move adjust appropriately) for the position relative inside the content frame.