my dog learned polymorphism
The moose likes Swing / AWT / SWT and the fly likes VK_TAB event not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "VK_TAB event not working" Watch "VK_TAB event not working" New topic

VK_TAB event not working

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

Ok, here is my code

However, when I press the tab key while on that text field, nothing is printed out. Does anyone know why?
[ July 11, 2002: Message edited by: Gregg Bolinger ]

GenRocket - Experts at Building Test Data
Rene Liebmann
Ranch Hand

Joined: May 02, 2002
Posts: 196
Hi Gregg,
I don't know why this happens, but if you want to catch this event to know, that the JTextField will lose the focus, then I would better do it with a FocusListener.
Anyway, it is strange. I could imagine that the Focus behavior will catch the key event somehow. And then the key event will be lost.
[ July 11, 2002: Message edited by: Rene Liebmann ]
Nathan Pruett

Joined: Oct 18, 2000
Posts: 4121

I think the event is being consumed in the InputMap of the JTextArea...

look at this bug report on Sun's site... down in the "Evaluation" section it shows an example of setting things in the InputMap... maybe you could clear out the InputMap of your JTextArea or replace the action that is invoked in the InputMap?

Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

Actually I figured it out. YOu have to disable the traversable tabbing event and just handle it yourself. So when you press tab, you capture the keyPressed Event, and after you do whatever you do, you handle going to the next focusable component you want it to go to.
I agree. Here's the link:
subject: VK_TAB event not working
It's not a secret anymore!