In my JTextAreas, I want the TAB key to behave as it does with
JTextFields, i.e., change the focus to the next component, and not
enter a tab into the text. I've done a thorough Googling and every
solution I've found fails to work in Sun's JDK 1.4.2 on Linux. What's
the current favoured method of doing this?
John
Adam - 15 Dec 2003 15:13 GMT
> In my JTextAreas, I want the TAB key to behave as it does with
> JTextFields, i.e., change the focus to the next component, and not
> enter a tab into the text. I've done a thorough Googling and every
> solution I've found fails to work in Sun's JDK 1.4.2 on Linux. What's
> the current favoured method of doing this?
I don't know.
Maybe you should subclass JTextArea, override processKeyEvent
and transferFocus() if keyEvent is VK_TAB
otherwise call super.processKeyEvent ?
Adam
John Moore - 15 Dec 2003 18:27 GMT
>Maybe you should subclass JTextArea, override processKeyEvent
>and transferFocus() if keyEvent is VK_TAB
>otherwise call super.processKeyEvent ?
This works pretty well, it seems. Thanks!
John
Andrew Thompson - 15 Dec 2003 15:45 GMT
> In my JTextAreas, I want the TAB key to behave as it does with
> JTextFields, i.e., change the focus to the next component, and not
> enter a tab into the text. I've done a thorough Googling and every
> solution I've found fails to work in Sun's JDK 1.4.2 on Linux. What's
> the current favoured method of doing this?
ctrl^tab ..in both Windows and Metal L&F's
--
Andrew Thompson
* http://www.PhySci.org/ PhySci software suite
* http://www.1point1C.org/ 1.1C - Superluminal!
* http://www.AThompson.info/andrew/ personal site
Andrew Thompson - 15 Dec 2003 15:47 GMT
> > In my JTextAreas, I want the TAB key to behave as it does with
....
> > .....fails to work in Sun's JDK 1.4.2 on Linux. What's
> > the current favoured method of doing this?
>
> ctrl^tab ..in both Windows and Metal L&F's
Sorry, of course that is windows, when you
are using Linux! (shrugs) Give it a try..
John Moore - 15 Dec 2003 18:17 GMT
>> ctrl^tab ..in both Windows and Metal L&F's
>
>Sorry, of course that is windows, when you
>are using Linux! (shrugs) Give it a try..
Well, actually what I want is to get Tab to behave the same as for
other fields, rather than what to use instead. It beats me why this is
so tricky, and why the solution for 1.3 broke in 1.4.
John
Alan Moore - 15 Dec 2003 20:40 GMT
>In my JTextAreas, I want the TAB key to behave as it does with
>JTextFields, i.e., change the focus to the next component, and not
[quoted text clipped - 3 lines]
>
>John
Keyboard focus traversal underwent a major change in v1.4.0, as
described in this article:
http://java.sun.com/j2se/1.4.2/docs/api/java/awt/doc-files/FocusSpec.html
To get TAB (and Shift-TAB) to function as focus traversal keys, you
have to use the setFocusTraversalKeys(int, java.util.Set) method of
java.awt.Container.