There is a jTextArea created in the Netbeans IDE visual editor. When a large amount of text appears in it, a scroll appears.

How to make the jTextArea itself scroll down when adding text?

  • Doesn’t jtextarea automatically scroll down that when manually typing text that when inserting text? either I did not understand the question. - Denis
  • No, it does not scroll. Well, my text increases gradually - andrshpa

1 answer 1

You can either put the caret at the end of the text:

 textArea.append("Тут текст"); textArea.setCaretPosition(textArea.getDocument().getLength()); 

Or that it is always automatic:

 DefaultCaret caret = (DefaultCaret) textArea.getCaret(); caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); 

Source0 and Source1 .