Created
August 29, 2022 22:47
-
-
Save Vzor-/dd7a85b04dc81daee5dfb97bc98207de to your computer and use it in GitHub Desktop.
mouse location test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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