Linda helped me out:
To transfer the focus from the JTextArea to the next component
with the Tab-key I overrode once processComponentKeyEvent in a
JTextArea subclass to do that (transferFocus();), which worked
then ok for me so far.
Linda
--
(=)
/ linda@jalice.ch -
http://www.jalice.net
(=)
/ l.radecke@hswzfh.ch -
http://www.hswzfh.ch
(=)
"Gunnar" <nogen@mail.dk> skrev i en meddelelse
news:3cf694a3$0$218$edfadb0f@dspool01.news.tele.dk...
> I wanted to focus on another component when I use the tab key in a
JTextArea
> (instead of tabbing inside the JTextArea).
>
> This was not a problem. I did it by using setTabSize(0) and adding a
> KeyListener to the JTextArea, that makes the next component grab focus
when
> the keyEvent = VK_TAB.
>
> But when I AT THE SAME TIME set the linewrap in the JTextArea to true
(like
> this: textArea.setLineWrap(true)), I get a "divide-by-zero"-exception:
>
> Exception occurred during event dispatching:
>
> java.lang.ArithmeticException: / by zero
>
> at javax.swing.text.WrappedPlainView.nextTabStop(Unknown Source)
>
> at javax.swing.text.Utilities.getTabbedTextOffset(Unknown Source)
>
> at javax.swing.text.Utilities.getTabbedTextOffset(Unknown Source)
>
> at javax.swing.text.WrappedPlainView.calculateBreakPosition(Unknown
Source)
>
> at
javax.swing.text.WrappedPlainView$WrappedLine.calculateLineCount(Unknown
> Source)
>
> at javax.swing.text.WrappedPlainView$WrappedLine.insertUpdate(Unknown
> Source)
>
> at javax.swing.text.WrappedPlainView.insertUpdate(Unknown Source)
>
> at javax.swing.plaf.basic.BasicTextUI$RootView.insertUpdate(Unknown
Source)
>
> at javax.swing.plaf.basic.BasicTextUI$UpdateHandler.insertUpdate(Unknown
> Source)
>
> at javax.swing.text.AbstractDocument.fireInsertUpdate(Unknown Source)
>
> at javax.swing.text.AbstractDocument.insertString(Unknown Source)
>
> at javax.swing.text.JTextComponent.replaceSelection(Unknown Source)
>
> at
javax.swing.text.DefaultEditorKit$InsertTabAction.actionPerformed(Unknown
> Source)
>
> at javax.swing.SwingUtilities.notifyAction(Unknown Source)
>
> at javax.swing.JComponent.processKeyBinding(Unknown Source)
>
> at javax.swing.JComponent.processKeyBindings(Unknown Source)
>
> at javax.swing.JComponent.processKeyEvent(Unknown Source)
>
> at javax.swing.JTextArea.processKeyEvent(Unknown Source)
>
> at java.awt.Component.processEvent(Unknown Source)
>
> at java.awt.Container.processEvent(Unknown Source)
>
> at java.awt.Component.dispatchEventImpl(Unknown Source)
>
> at java.awt.Container.dispatchEventImpl(Unknown Source)
>
> at java.awt.Component.dispatchEvent(Unknown Source)
>
> at java.awt.LightweightDispatcher.processKeyEvent(Unknown Source)
>
> at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
>
> at java.awt.Container.dispatchEventImpl(Unknown Source)
>
> at java.awt.Window.dispatchEventImpl(Unknown Source)
>
> at java.awt.Component.dispatchEvent(Unknown Source)
>
> at java.awt.EventQueue.dispatchEvent(Unknown Source)
>
> at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
>
> at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
>
> at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
>
> at java.awt.EventDispatchThread.run(Unknown Source)
>
>
> Any help will make me a lot happier!
>
> /Luffi
>
>
>
>