Setting the a caret in an JEditor Pane causes an exception.
Posted
by Elliott
on Stack Overflow
See other posts from Stack Overflow
or by Elliott
Published on 2010-03-26T02:47:59Z
Indexed on
2010/03/26
2:53 UTC
Read the original article
Hit count: 508
I have a JeditorPane which has some text in HTML format. When I execute the following command
int len = editorPane.getText().length();
The value for len is 7473. But then I try to do the following:
editorPane.setCaretPosition(4995);
And I get the following exception: java.lang.IllegalArgumentException: bad position: 4995
My understanding is that I should only get this exception if the position at which I'm trying to set the caret is less than 0 or greater than the text length. It is neither. How can this be.
Thank you,
Elliott
© Stack Overflow or respective owner