Hi Guys!

I am trying to get a scroll bar to go to the lowest position possible. I am using a chat program and it bothers me that I have to scroll down to see new messages! I googled around and found lots of answers for flash, and other languages but nothing that helped me !

THanks PO

Is your chat window in Java? If so is your GUI written in swing or awt? Perhaps some code to describe how you construct your window would help...

When I made a chat application I had the same problem. If you had googled a little harder you could have found this solution.

//incoming is the JTextField that displays the conversation
//doc is a previously initialized Document object. 
doc = incoming.getDocument();
incoming.setCaretPosition(doc.getLength()-1);

Sorry guys, I was adding the textArea wrong, thats why it wasn't working.

Original Code:

add(textArea, borderLayout.NORTH);

Correct Code:

add(scroller, borderLayout.NORTH);

Thanks for the replies!
PO

This question has already been answered. Start a new discussion instead.