Results 1 to 4 of 4
  1. #1
    Peter_Aye is offline Member
    Join Date
    Nov 2012
    Location
    Nigeria
    Posts
    4
    Rep Power
    0

    Default Tripple KeyDispatch events

    Hi everyone. I have a challenge with an application. I used the KeyDispatcher to capture application-wide key events. However, I noticed that the KeyboardFocusManager is sending three events with every KeyPress. How can I resolve this? Thanks in anticipation. Here's the code:

    Java Code:
    KeyboardFocusManager.getCurrentKeyboardFocusmanager().addKeyEventDispatcher(new KeyEventDispatcher(){
    @Override
    public boolean dispatchKeyEvent(KeyEvent e) {
        if(Character.isDigit(e.getKeyChar())) {  // to filter out non-digits
            digitDisplay("" + e.getKeyChar()); // to display the pressed key
       }
       return false;
    }
    });

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default Re: Tripple KeyDispatch events

    You didn't bother to reply to the three responses in your earlier thread. Why should we expect any better behavior this time round?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    Peter_Aye is offline Member
    Join Date
    Nov 2012
    Location
    Nigeria
    Posts
    4
    Rep Power
    0

    Default Re: Tripple KeyDispatch events

    Awww. So sorry, I didn't know I was supposed to do that.

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default Re: Tripple KeyDispatch events

    I would expect at least two events - KEY_PRESSED and KEY_RELEASED -- and when the key corresponds to a printable character, an additional KEY_TYPED. Read the API of KeyEvent for a better understanding.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. chosing among the 3 key events
    By sandeshyadav in forum AWT / Swing
    Replies: 4
    Last Post: 02-25-2012, 12:56 AM
  2. Key Events
    By rdjava in forum Java Gaming
    Replies: 0
    Last Post: 04-15-2011, 09:02 AM
  3. typed events vs untyped events.
    By Drun in forum SWT / JFace
    Replies: 0
    Last Post: 11-23-2009, 01:22 PM
  4. Need Help with events
    By Gatts79 in forum AWT / Swing
    Replies: 3
    Last Post: 09-23-2008, 04:18 AM

Tags for this Thread

Posting Permissions

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