0

I have a private message frame of a chat application in which i used a JEditorPane on top of JScrollPane which is used as a conversation pane where both my messages and the messages i receive will be displayed.

For this I get the previous text from JEditorPane and append the new text and then set the text again to JEditorPane.

Now problem is that when I send a message, and space of JEditorPane gets filled and then it need to be scrolled down vertically downward then it works fine. I mean the text got scrolled vertically and the vertical scroll bar also comes to the bottom where my recent text is.

But when message is received by other person where also it is supposed to scroll downward, it does not happen. Although the new text get appended there but scroll bar does not move downward. Similarly when other person send me message and my vertical scroll bar is supposed to move downward it does not happen.

So, conclusion is that the scroll bar automatically scrolls downward only at that end which sends the message but not at the receiving end. Although I used the same way to append the text in both cases, but still its working in an awkward way. Any help!!

2
Contributors
1
Reply
3
Views
6 Years
Discussion Span
Last Post by JamesCherrill
0

Maybe after adding the text you can explicitly force the vertical scroll bar down to the bottom

int y = // some calc based on number of actual lines - size of viewport
myJScrollPane.getVerticalScrollbar().setValue(y);
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.