简体   繁体   中英

Java getting mouse location

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 + ")");
        }



    }

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM