jQuery in Action, 2nd edition*
The moose likes Swing / AWT / SWT and the fly likes Transfer Focus From JTable To Other Component Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Transfer Focus From JTable To Other Component" Watch "Transfer Focus From JTable To Other Component" New topic
Author

Transfer Focus From JTable To Other Component

Syed Muhammad Mubashir Ahmed
Greenhorn

Joined: May 20, 2012
Posts: 2
How I transfer focus from jtable to other component usiing tab or shift tab keys.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

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?


luck, db
There are no new questions, but there may be new answers.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19653
    
  18

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

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

Joined: Oct 27, 2005
Posts: 19653
    
  18

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Transfer Focus From JTable To Other Component
 
Similar Threads
basic Question about JTable in Swing
JTable Cell and Tab Problem[jdk1.3 ]
TAB Key Functionality on JTable
JTable question
Focus lost problem with JTable in the jdk1.5.0_11