For smart Primates & ROBOTS (oh and ALIENS ).

Blogroll

Wednesday, May 07, 2014

Mouse Pointer info in java

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) {
        super(str);
    }
    public void run() {
        while(true){
        PointerInfo info = MouseInfo.getPointerInfo();
        Point pp=info.getLocation();
        System.out.println(pp);
            try {
                sleep((int)(Math.random() * 1000));
            } catch (InterruptedException e) {}
        }
       
    }
}
public class MyMouse{
    public static void main(String[] ss) {
        new ShowMyMouse("Mouse Pointer info").start();
    }
}
Share:

0 comments:

Post a Comment

How to make center align child div

 How to make center align child div?   Suppose you have 2 Div tag. And want the make inner tag center <div id="d1">      ...

Ads Inside Post

Powered by Blogger.

Arsip