> I have a panel in which I placed 4 JTextPanes. I want to move cursor
> with TAB key between JTextPanes but when I pressed TAB it inserts TAB
> char.
>
> How could I achieve to move between JTextPanes with TAB key?
I'm not sure if this is the most compact code to do it, but:
HashSet keys = new
HashSet(ta.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS));
keys.add(AWTKeyStroke.getAWTKeyStroke("pressed TAB")) ;
ta.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,
keys) ;
keys = new
HashSet(ta.getFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS));
keys.add(KeyStroke.getKeyStroke("shift pressed TAB")) ;
ta.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS,
keys) ;
--
Morten
Morten Alver - 26 May 2004 17:01 GMT
> HashSet keys = new
> HashSet(ta.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS));
[quoted text clipped - 9 lines]
> ta.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS,
> keys) ;
... and assume that "ta" is your JTextArea.
--
Morten