3 回答

TA貢獻(xiàn)1865條經(jīng)驗(yàn) 獲得超7個(gè)贊
MouseInfo.getPointerInfo()。getLocation()可能會(huì)有所幫助。它返回與當(dāng)前鼠標(biāo)位置對(duì)應(yīng)的Point對(duì)象。

TA貢獻(xiàn)2021條經(jīng)驗(yàn) 獲得超8個(gè)贊
PointerInfo a = MouseInfo.getPointerInfo();
Point b = a.getLocation();
int x = (int) b.getX();
int y = (int) b.getY();
System.out.print(y + "jjjjjjjjj");
System.out.print(x);
Robot r = new Robot();
r.mouseMove(x, y - 50);

TA貢獻(xiàn)1871條經(jīng)驗(yàn) 獲得超13個(gè)贊
在SWT中,您無(wú)需在聽(tīng)眾中找到鼠標(biāo)位置。Display對(duì)象具有該方法getCursorLocation()。
在vanilla SWT / JFace中,請(qǐng)致電Display.getCurrent().getCursorLocation()。
在RCP應(yīng)用程序中,請(qǐng)致電PlatformUI.getWorkbench().getDisplay().getCursorLocation()。
對(duì)于SWT應(yīng)用中,優(yōu)選使用getCursorLocation()過(guò)MouseInfo.getPointerInfo(),其他人已經(jīng)提到的,隨著后者在SWT被設(shè)計(jì)用來(lái)替換AWT工具包來(lái)實(shí)現(xiàn)。
添加回答
舉報(bào)