This is what i got so far, but this is printing the mouse position every 1000ms, how can I code it such that only when i click on a position it print out the location
public static void main(String[] args) throws InterruptedException {
while (true) {
Thread.sleep(1000);
System.out.println("(" + MouseInfo.getPointerInfo().getLocation().x + ", " + MouseInfo.getPointerInfo().getLocation().y + ")");
}
}
Use mouselistener's java swing. you will get the mouse position.
http://www.realapplets.com/tutorial/MouseClickExample.html
http://docs.oracle.com/javase/7/docs/api/java/awt/event/MouseEvent.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.