6

How do I use SwingEventMonitor to monitor mouse events in applications running in other JVMs?

The demo code I have can monitor mouse clicks in applications running within its own JVM, but applications started seperately or via jnlp are ignored.

How do I make sure Java loads my SwingEventMonitor app with every application, regardless of how its started (desktop or jnlp)

DFriend
  • 237
  • 2
  • 9
  • Java VisualVM, [jvisualvm](http://java.sun.com/javase/6/docs/technotes/tools/share/jvisualvm.html), which is included with the JDK, maybe an alternative. – trashgod Nov 12 '11 at 05:28
  • A useful debugging aid, but not something I can run on an end users machine. We'd already looked into it, but thanks for the suggestion. – DFriend Nov 12 '11 at 19:03
  • Look at this [post](http://stackoverflow.com/questions/504559/is-it-possible-to-have-a-mousemotionlistener-listen-to-all-system-mouse-motion-e), there are a couple of pointers – aymeric Aug 09 '12 at 20:25

1 Answers1

1

Run your monitor and create a sever = ServerSocket(MONITOR_PORT). Then listen for incoming connections:

while (true) {
    Socket socket = server.accept();
    connectionCount++;
    // start a new monitor thread for this connection
}

Note: SwingEventMonitor is not included anymore in JDK1.7, you may wish to push your own EventQueue. See What happened to SwingEventMonitor?

Community
  • 1
  • 1
sina72
  • 4,931
  • 3
  • 35
  • 36