File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tabbing in and out of JTable

 
Venita Glasfurd
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Once I press 'Tab' and enter the JTable, I am unable to come out of the JTable component.
(subsequent pressing of the 'Tab' key just takes me from cell to cell). I want to disable this feature of JTable, so that pressing the Tab key takes me to the next component.
Would it be possible to do this without implementing a key listener for the JTable? Any other ideas?
Thanks,
Venita
 
Michael Morris
Ranch Hand
Posts: 3451
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Venita,
I sweated over that too, but decied not to change that behavior. You can still move between components with CTRL+TAB.
If you want to change it though, there is a method called installKeyboardActions() in the BasicTableUI class which extends TableUI. You can get the JTable's UI by calling getUI().
Hope this helps,
Michael Morris
 
John Smith
Ranch Hand
Posts: 2937
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

subsequent pressing of the 'Tab' key just takes me from cell to cell

Some people here pointed out that this is how it should be. To tab out of JTAble, the user presses CTL-TAB, as Michael said. I tried tabbing in JBuilder, for example, and sure enough, that's how it behaves, -- if the focus is on the list box or table, tabbing will move the focus to the next item in the control.
Eugene.
 
Venita Glasfurd
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the replies, Michael and Eugene.
I realise that if I override installKeyboardActions in the BasicTableUI, it would block all other keyboard actions on the table.
I just thought that it would be nice to disable Tab within Jtable, since I don't want to move from cell to cell anyway - Though now I'm beginning to wonder if it is worth the effort, since one can use control+Tab to move between components, as pointed out.
Will remember to put this 'Ctrl+Tab' point down in my user manual documentation.
Venita.
 
Michael Morris
Ranch Hand
Posts: 3451
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Venita,

Will remember to put this 'Ctrl+Tab' point down in my user manual documentation.

That's how I handled it.
Michael Morris
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic