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

Recommended Answers

All 3 Replies

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.