Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: making a global hotkey

  1. #1
    Junior Member
    Join Date
    Sep 2011
    Posts
    29
    Thanks
    2
    Thanked 2 Times in 2 Posts

    Default making a global hotkey

    I'm trying to make a global hotkey in my program so that when i press 'l' anywhere it pops up a jdialog. I've tried a keylistener and that works as it should untill i click any button at which point the keylistener stops responding. I've tried adding a keybinding which works as it should in a sample program but never responds in the actual program. What can I do to make it work?


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: making a global hotkey

    A KeyBinding should be appropriate.
    I've tried adding a keybinding which works as it should in a sample program but never responds in the actual program.
    Tough to debug without seeing code. Can you boil your 'actual' program down to an SSCCE that replicates the problem?

  3. #3
    Junior Member
    Join Date
    Sep 2011
    Posts
    29
    Thanks
    2
    Thanked 2 Times in 2 Posts

    Default Re: making a global hotkey

    --- Update ---

    Okay, I just found what's causing the problem. The actual program also implements ActionListener and that's stopping the keybind from working. I need the actionlistener for several buttons also in the program so I can't just get rid of it. Is there any way I can have both, or is there something I can replace the actionlistener with instead?

    --- Update ---

    With a bit of googling, I managed to find a solution. Apparently an action is also an actionlistener, as odd as that seems. So now I just need to make actions for all the buttons in my program, and get rid of all the actionlisteners, but at least it will work.
    Last edited by Harry Blargle; March 6th, 2014 at 04:12 PM. Reason: found problem

Similar Threads

  1. [SOLVED] Regarding static variables as global variable in Java....
    By ineedahero in forum What's Wrong With My Code?
    Replies: 7
    Last Post: December 21st, 2013, 06:52 PM
  2. global variables for threads
    By barhom in forum What's Wrong With My Code?
    Replies: 4
    Last Post: June 17th, 2013, 10:28 PM
  3. global color histogram
    By larbie in forum Java Theory & Questions
    Replies: 6
    Last Post: February 28th, 2013, 03:13 PM
  4. How can I create a global or local script terminater?
    By YourCrazyFriend in forum Java Theory & Questions
    Replies: 5
    Last Post: March 20th, 2012, 06:33 AM
  5. [SOLVED] Problem while getting a number from another thread
    By Koren3 in forum Threads
    Replies: 4
    Last Post: April 7th, 2009, 01:42 PM