鼠标连点器的java代码 鼠标连点器的java代码怎么写( 二 )


setSize(400, 300);
setResizable(false);
getContentPane().setLayout(null);
lblNewLabel = new JLabel("");
lblNewLabel.setBounds(0, 259, 394, 13);
getContentPane().add(lblNewLabel);
setVisible(true);
new Thread() {
public void run() {
while (true) {
try {
Point mainPoint = getLocation();
Point point = MouseInfo.getPointerInfo().getLocation();
int x = point.x - mainPoint.x;
int y = point.y - mainPoint.y;
if (x0 || x400) {
sleep(10);
continue;
}
if (y0 || y300) {
sleep(10);
continue;
}
lblNewLabel.setText(str + "x : " + x + " y : " + y);
sleep(10);
} catch (Exception e) {
}
}
}
}.start();
this.addKeyListener(this);
}
public static void main(String[] args) {
new App();
}
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_CONTROL) {
str = "C ";
return;
}
if (e.getKeyCode() == KeyEvent.VK_SHIFT) {
str = "S ";
return;
}
str = "D ";
}
public void keyReleased(KeyEvent e) {
str = "U ";
}
public void keyTyped(KeyEvent e) {
}
}
鼠标连点器的java代码的介绍就聊到这里吧,感谢你花时间阅读本站内容 , 更多关于鼠标连点器的java代码怎么写、鼠标连点器的java代码的信息别忘了在本站进行查找喔 。

推荐阅读