Wednesday, 28 August 2013

How to put caret at the end of jEditorPane - Java

How to put caret at the end of jEditorPane - Java

I have a jEditorPane in Java with html editor kit. I have a function that
when I press the ENTER key on my keyboard it automatically put a breakline
(
) in the jEditorPane. The problem is that when I press ENTER, I have to go
again to the end of the text.
For example if I have in my editor pane this text: My name is Albert. And
then I press ENTER, I will have something like that: My na(here will be my
caret/cursor)me is Albert.
I already tried this function but with no success:
.setCaretPosition(textAreaStatus.getText().length());

No comments:

Post a Comment