Try the following:
jTextArea.selectAll();
int last = jTextArea.getSelectionEnd();
jTextArea.select(last, last);
Where jTextAreais the link to your TextArea.
However, the previous example can be very slow if there is a lot of text, so I provided another way to do this:
jTextArea.setCaretPosition(jTextArea.getDocument().getLength());
EDIT: After browsing the internet for alternative solutions and reading this answer to a similar question, I realized that @kleopatra's solution is more efficient. Nevertheless, it is entirely your prerogative to accept any answer that you consider necessary (I see you accepted mine).
@kleopatra I supported you to compensate. :)
source
share