• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

How to catch key event in JTable

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, all
I add KeyListener to my JTable and hope it can catch the key event such as TAB key or ENTER key pressed. But after I edit one cell and press TAB, it does not fire the KeyEvent, only after I press TAB again, it catch the event and do the relevant business logic.
I wonder why the first TAB key pressed is not caught?
P.S. if I do not edit one cell and press TAB, it will catch the TAB key pressed event.
 
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Joy,
some days ago we had a similar post in this forum. Somebody had the problem, that he was not able to catch TAB key event in JTextField. We found out, that we need to call the method setFocusTraversalKeysEnabled(true) to the JTextField.
I think, the same happens to you, because the JTextField is probably your TableCellEditor.
So it seems to me, that you need to writ your own TableCellEditor, where you call the above mentioned method.
Good Luck
Rene
 
reply
    Bookmark Topic Watch Topic
  • New Topic