This discussion is archived
1 Reply Latest reply: Apr 13, 2007 4:27 AM by 807596 RSS

Capturing mouse information before it makes the pointer move on screen

807596 Newbie
Currently Being Moderated
Hi,

I'm new here to the forum, so I am unsure where to post this!

It's been a while since I've used java, but I thought I'd refresh my knowledge to resolve a problem I am having - if anyone could help me with this it would be fantastic!

The issue I am having is the RF interference in my house is causing a brand new Wacom graphics tablet to jitter/shake on my screen in a 5x5 pixel area - sometimes it gets worse to around 10x10 pixel, making it very hard to draw straight lines, select things, and open and close windows.

My proposed solution is to try and capture the pointer movements before they actually move the pointer on the screen, and try and average them, so that the pointer will be smooth, and not so shakey and jittery.

I am thinking to use mouseMoved to get the co-ordinates, however these co-ordinates are only after the mouse has actually moved, and not where the mouse says it will be moving to.

I know only basic java so I was wondering if there a way to capture the information coming from the mouse/graphics tablet with java before it is translated to a movement on the screen?

Thanks heaps,

Jash
  • 1. Re: Capturing mouse information before it makes the pointer move on screen
    807596 Newbie
    Currently Being Moderated
    What you can do is create another thread or at least that is what I have done. Basically I created another thread object so I could watch where the pointer always was. I also have it set up so if you don't want to watch the mouse for whatever reason it can be shut off or you can kill it.
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    public class MouseWatch extends Thread {
      private boolean inbounds=false;
      private boolean notDestroy=true;
      Component component;
      public MouseWatch(Component component) {
          this.component=component;
      }
      public void run() {
       try{while(notDestroy==true)
           {
          while (inbounds==false) {
             
            System.out.println(MouseInfo.getPointerInfo().getLocation());
           
        Thread.sleep(50);}
        if(notDestroy==true)
         {while (inbounds==true) {Thread.sleep(100);}}}
        
    }catch(InterruptedException e){}
    }
    public void pause(){inbounds=true;}
    public void restart(){inbounds=false;}
    public void end(){notDestroy=false;}
    }