Skip to content

Instantly share code, notes, and snippets.

@Vzor-
Created August 29, 2022 22:47
Show Gist options
  • Save Vzor-/dd7a85b04dc81daee5dfb97bc98207de to your computer and use it in GitHub Desktop.
Save Vzor-/dd7a85b04dc81daee5dfb97bc98207de to your computer and use it in GitHub Desktop.
mouse location test
import java.awt.*;
import java.awt.geom.Area;
public class MouseTest {
public static void main(String[] args) {
GraphicsDevice[] devices = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
Area area = new Area();
for (GraphicsDevice gd : devices) {
for (GraphicsConfiguration gc : gd.getConfigurations()) {
area.add(new Area(gc.getBounds()));
}
}
while (true) {
System.out.println(MouseInfo.getPointerInfo().getLocation());
Point testPoint = MouseInfo.getPointerInfo().getLocation();
testPoint.x += 10;
System.out.println(area.contains(testPoint));
try {
Thread.sleep(100);
} catch (InterruptedException e) {
break;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment