• Post Reply Bookmark Topic Watch Topic
  • New Topic

handling TAB in JTable celleditor  RSS feed

 
Manuel Moons
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Does anyone know how I can stop a tablecelleditor from losing focus when the tab key is pressed? I have an editor which contains 2 combo boxes. I want to switch between those 2 combos when pressing tab. At the moment the focus of the editor is lost. How can I fix this?
 
Brian Cole
Author
Ranch Hand
Posts: 947
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Manuel Moons wrote:
Does anyone know how I can stop a tablecelleditor from losing focus when the tab key is pressed? I have an editor which contains 2 combo boxes. I want to switch between those 2 combos when pressing tab. At the moment the focus of the editor is lost. How can I fix this?


By default JTable has an action bound to the tab key. I don't know if this will work, but you can try removing that binding:



Here the string "do-nothing" can be anything so long as it doesn't match anything in the action map. (So "selectNextColumnCell" would be a poor choice.)
 
Manuel Moons
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey thanks,

I actually already came up with that solution myself. It worked. I attached a custom action to my cellEditor component and by doing that I made sure that it (the key) will not be forwarded to the table. So for other editors it will still work and I can handle my own TAB key.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!