Text Area Tab Handling

I would like a setting on a Text Area that would cause focus to go to the next component when the user presses TAB. Also, it should not insert the tab character into the text area. (The default value of the setting should be to treat TAB the way it does now)

I am using text area components, along with text fields and numeric fields to do data entry on a screen with a bunch of components. The fields may already have values and the users like to tab through the fields to get to the one they want. This works really well until you get to the text area component.

The tab bahavior in a text area is the java default, it is possible to change this with a bit of java magic. Try the following code in the ‘focusGained’ event of a text area:

from java.awt import KeyboardFocusManager

# Prevent the scrollbars from gaining focus
event.source.getVerticalScrollBar().setFocusable(0)
event.source.getHorizontalScrollBar().setFocusable(0)

# Reset default traversal keys for the text area
textArea=event.source.getViewport().getView()
textArea.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, None);
textArea.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, None);