Results 1 to 4 of 4
  1. #1
    JeffThomas is offline Member
    Join Date
    Dec 2011
    Posts
    31
    Rep Power
    0

    Default Is it Possible to have a general Mouse Listener?

    Can I detect if the left mouse button has been pressed anywhere? I already know how to make listeners to specific buttons and panes but what about a listener for something like clicking while on the desktop or clicking while in another program?

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default Re: Is it Possible to have a general Mouse Listener?

    You can use a Timer and poll a MouseInfo object to get the mouse's location, but what you're really trying to do is to provide a hook to the OS to monitor mouse events. This can't be done in core Java, but can be done with JNA (Java Native Access) or JNI (Java Native Interface) .
    Last edited by Fubarable; 12-19-2011 at 11:52 PM. Reason: corrected

  3. #3
    JeffThomas is offline Member
    Join Date
    Dec 2011
    Posts
    31
    Rep Power
    0

    Default Re: Is it Possible to have a general Mouse Listener?

    Awesome. You see this is the area of the internet were you can get expert responses from people that know what they are doing. Thanks.

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default Re: Is it Possible to have a general Mouse Listener?

    You're welcome. Best of luck!

Similar Threads

  1. Need some help with mouse listener
    By Serialcek in forum AWT / Swing
    Replies: 8
    Last Post: 01-07-2012, 10:20 AM
  2. Mouse listener
    By chetoos in forum Advanced Java
    Replies: 3
    Last Post: 06-23-2011, 09:23 PM
  3. Need Help with Mouse Listener!!!!
    By Doggir in forum New To Java
    Replies: 11
    Last Post: 05-05-2011, 11:48 PM
  4. Mouse Listener
    By Quizerno in forum New To Java
    Replies: 8
    Last Post: 03-17-2011, 05:25 AM
  5. Mouse Listener for mouse floating over object?
    By Krooger in forum AWT / Swing
    Replies: 1
    Last Post: 11-18-2009, 04:34 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •