The only solution I've found through searching which comes close to working involves setting the caret position for the JTextPane, but that still has issues. First, the relevant code:
public synchronized void updateChat(){
JScrollBar scrollBar = chatView.getVerticalScrollBar();
boolean scrollBarVisible = scrollBar.isVisible();
boolean scrollBottom = false;
if(scrollBarVisible)
scrollBottom = scrollBar.getMaximum() == scrollBar.getValue() + scrollBar.getVisibleAmount();
recentChat.setText(Utils.buildRecentHistory(chatManager.getMessages()));
if(!scrollBarVisible && scrollBar.isVisible() || scrollBottom) {
recentChat.setCaretPosition(recentChat.getDocument().getLength());
}
}
chatView is a JScrollPane. The problem with this method is that even though the caret is set to the maximum value, the scroll bar will actually just be ever-so-slightly away from all the way down. Then, when another message comes in, it doesn't think it should continue to scroll down since it's only close to bottom, but not actually.
What it looks like after the caret reset:

What it should look like:

Thanks for any help guys!






