How do I set the position of the mouse in Java?

后端 未结 5 1571
-上瘾入骨i
-上瘾入骨i 2020-12-15 19:32

I\'m doing some Swing GUI work with Java, and I think my question is fairly straightforward; How does one set the position of the mouse?

5条回答
  •  醉话见心
    2020-12-15 19:55

    The code itself is the following:

    char escCode = 0x1B;
    System.out.print(String.format("%c[%d;%df",escCode,row,column));
    

    This code is incomplete by itself, so I recommend placing it in a method and calling it something like 'positionCursor(int row, int column)'.

    Here is the code in full (method and code):

    void positionCursor(int row, int column) {
            char escCode = 0x1B;
            System.out.print(String.format("%c[%d;%df",escCode,row,column));
    }
    

提交回复
热议问题