• 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:

handling TAB in JTable celleditor

 
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Author
Posts: 986
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic