handling keyTyped events in JTable for TAB key
843806Sep 28 2007 — edited Sep 28 2007In my app, I have a JTable. Some columns are non-editable.
I have attached a keyListener to the table and have overridden keyTyped() and keyReleased() methods.
In keyReleased(), I do something depending on the key code. For example: if its the VK_DELETE, I delete the row. If its some other user configured key, then I show a popup dialog where the user can enter some data, etc...
In keyTyped(), I first check if the column is one of the specific columns. Then I get the keyChar. After this, I show a dialog and pre-populate a JTextField on this dialog with that keyChar.
My issue is that 'TAB' key events arrive in keyTyped() and not in keyReleased(). As a result, the dialog is shown and the tab takes place inside the JTextfield which is incorrect.
I would like to ignore TAB keyTyped events. When I look up the keyCode in keyTyped() method, it is 0. So there is no way for me to tell what key was typed.
How can I ignore TAB events in my keyTyped() method?
thx