Java中的Array中的GetLocation

时间:2016-04-21 13:29:37

标签: java

你好我想在Array中使用getLocation。我尝试用循环来制作它,但它不是workinm。有人知道怎么修好了吗?谢谢你的帮助!

import java.awt.AWTException;
import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.PointerInfo;
import java.awt.Robot;



 public class Clicker {


public static void main (String[] args) {




 for (int i = 0; i < 10; i++){
     PointerInfo inf = MouseInfo.getPointerInfo();
     Point[i] p = inf.getLocation()[i];
 }
}

1 个答案:

答案 0 :(得分:1)

    Point[] p = new Point[10];
    for(int i = 0; i < 10; i++){
            PointerInfo inf = MouseInfo.getPointerInfo();
            p[i] = inf.getLocation();
    }