I need to scroll a JScrollPane to the bottom. The JScrollPane contains a JPanel, which contains a number of JLabel\'s.
To scroll to the top, I just do:
After many hours of attempting to find an answer other than one using the scrollRectToVisible() method, I've succeeded. I've found that if you use the following code after you output text to the text area in the scrollpane, it will automatically focus on the bottom of the text area.
textArea.setCaretPosition(textArea.getDocument().getLength());
So, at least for me, my print method looks like this
public void printMessage(String message)
{
textArea.append(message + endL);
textArea.setCaretPosition(textArea.getDocument().getLength());
}