This code usually doesn't work if you try to run it, but it shows you how to get the mouse position X and Y as integers
import java.awt.MouseInfo;
public class testmouse {
public static void main(String[] args){
int mouseY = MouseInfo.getPointerInfo().getLocation().y;
int mouseX = MouseInfo.getPointerInfo().getLocation().x;
}
}
source
share