wood burning stoves 2.0*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Tabbing in and out of JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Tabbing in and out of JTable" Watch "Tabbing in and out of JTable" New topic
Author

Tabbing in and out of JTable

Venita Glasfurd
Greenhorn

Joined: Sep 11, 2002
Posts: 12
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

Joined: Jan 30, 2002
Posts: 3451
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


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
John Smith
Ranch Hand

Joined: Oct 08, 2001
Posts: 2937

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

Joined: Sep 11, 2002
Posts: 12
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

Joined: Jan 30, 2002
Posts: 3451
Hi Venita,

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

That's how I handled it.
Michael Morris
 
wood burning stoves
 
subject: Tabbing in and out of JTable
 
Similar Threads
Focus traversal problem in JTable
Issues with JTextArea as cellEditor of JTable Column.
Validating JTable Cell
JTable focus issue
Not focusing cells in JTable