PointerInfo a = MouseInfo.getPointerInfo();
Point b = a.getLocation();
int x = (int) b.getX();
int y = (int) b.getY();
System.out.print("Y: "+y);
System.out.print("X: "+x+"\n");
Right now I'm using this, but it gives me the coordinates relative to the entire monitor. Since you can move the program frame anywhere on the monitor, this doesn't help me. How can I get the mouse's coordinates relative to the program window? For instance, the top left corner would be (0, 0) and the bottom right would be (400, 420)