Monday, 17 November 2014

Mouse Pointer info in java

Suppose you move your mouse pointer in entire desktop area and want to know the exact position of the mouse. then use listed below code. by this code you can get the real mouse position X and Y .

import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.PointerInfo;
class ShowMyMouse extends Thread {
    public ShowMyMouse(String str) {
    public void run() {
        PointerInfo info = MouseInfo.getPointerInfo();
        Point pp=info.getLocation();
            try {
                sleep((int)(Math.random() * 1000));
            } catch (InterruptedException e) {}
public class MyMouse{
    public static void main(String[] ss) {
        new ShowMyMouse("Mouse Pointer info").start();

No comments:

Post a Comment