Java Swing: Auto-Scrolling JScrollPane (i.e. Chat Window)

This is just a short tutorial on how to make an auto scrolling pane in Java Swing. I was doing a chat client not too long ago, so I figured I’d assemble this short Swing tutorial for those interested in this particular behavior. This uses a JTextArea and a JScrollPane. I commented most of the lines, but I invite you to refer to the Java API for methods you don’t fully understand. Feel free to ask questions or suggest improvements in the comments section! Click here for the code.

Auto-Scrolling JTextArea/JScrollPane

Read more…