Help coderanch get a
new server
by contributing to the fundraiser
  • 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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
 
a fool thinks himself to be wise, but a wise man knows himself to be a fool - shakespeare. foolish tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic