I searched the tutorials and the Javadoc but couldn't find how to force a read-only JTextArea in a JScrollPane to keep scrolling to the end of the display when I append text.
At the moment the vertical scroll bar sits at the beginning, while appended text just disappears out of sight.
This is my code:
progressText = new JTextArea(10, 20);
progressText.setEditable(false);
progressScroll = new JScrollPane(progressText, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
There must be a simple solution to this, but I can't find it!
I suspect I need to implement a DocumentListener, but don't know what to put in it.