• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Transfer Focus From JTable To Other Component

 
Syed Muhammad Mubashir Ahmed
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How I transfer focus from jtable to other component usiing tab or shift tab keys.
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The standard keyboard shortcut for that is Ctrl+Tab / Ctrl+Shit+Tab. Why do you want to confuse a user who's accustomed to Tab and Shift+Tab behaving in a standard way?
 
Rob Spoor
Sheriff
Pie
Posts: 20611
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the problem is that Tab / Shift+Tab start behaving differently when the focus comes to a JTable. For just about every other component, Tab gives focus to the "next" component and Shift+Tab gives focus to the "previous" component. When a JTable has focus, Tab and Shift+Tab change cell selection all of a sudden. I myself actually find that a bit annoying.
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When a JTable has focus, Tab and Shift+Tab change cell selection all of a sudden. I myself actually find that a bit annoying.

What about tabbing out of a text component? It's the same there. This has been the normal behavior on GUI platforms that long predated Swing or Java. Screen elements that accept Tab require Ctrl+Tab to move to the next element in the tab order.

The behavior can probably be easily modified by getting the key binding for Ctrl+Tab and mapping it to Tab, in the WHEN_FOCUSED (and maybe WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, to cater to the editing state) map(s). As a user accustomed to using Tab / Shift+Tab to move to the next/previous cells not only in a GUI table, but also in just about any spreadsheet software, I might find that annoying
 
Rob Spoor
Sheriff
Pie
Posts: 20611
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Darryl Burke wrote:What about tabbing out of a text component? It's the same there.

And it can be just as annoying And in a few projects where tabs weren't allowed in text components, I have indeed changed the default behaviour to switch focus instead.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic