Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTable -> listening to keyevents on the header

el duente
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to listen to keyevents on the JTableHeader of a JTable by adding a keyListener directly on it but it seems not to work...
As told in Sun Swing tutorial, only components with keyboard focus can send such events. So I tried to force the focus on the header but this didn't work either...
The only workaround I found was to override addKeyListener() on the header to register the listener to the parent JTable instead of the header itself...
The problem is I don't find this is a good solution... Has anybody tried this and has found a better way to achieve this ?
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic