Description
Within the textChanged listener on my TextArea, I (naturally) call getText. This works fine if textChanged was called as a result of typing into the TextArea. But if it was fired because of a call to setText elsewhere in my program, getText throws IndexOutOfBoundsException. The stack looks like this:
ArrayList<T>.verifyIndexBounds(int, int, int) line: 577
ArrayList<T>.get(int) line: 346
TextArea.getParagraphAt(int) line: 853
TextArea.getText(int, int) line: 632
TextArea.getText() line: 606
<mycode>$2.textChanged(TextArea) line: 122
TextArea$TextAreaContentListenerList.textChanged(TextArea) line: 518
TextArea$ParagraphSequence.remove(int, int) line: 421
TextArea.setText(Reader) line: 722
TextArea.setText(String) line: 667
My workaround is to check for getCharacterCount() being positive before calling getText.
Here's a test case:
<Window title="Empty text area bug" maximized="true"
xmlns:bxml="http://pivot.apache.org/bxml"
xmlns="org.apache.pivot.wtk">
<BoxPane orientation="vertical" styles="
">
<PushButton buttonData="Set text">
<buttonPressListeners>
function buttonPressed(button)
</buttonPressListeners>
</PushButton>
<TextArea bxml:id="textArea">
<textAreaContentListeners>
function textChanged(textArea)
</textAreaContentListeners>
</TextArea>
</BoxPane>
</Window>