I'm making a chat room with a JTextPane
with html function. Users are able to input html tag to show image on the screen. But I'm having a problem to keep the scrollbar at bottom. I already try to do
SwingUtilities.invokeLater(new Runnable() {
public void run() {
vertical.setValue(vertical.getMaximum());
}
});
but the scrollbar scroll down then scroll up again. It seems like the picture finish loading after the function been called. I also tried:
ClientScreen._chatMsgPane.setCaretPosition(_chatMsgPane.getDocument().getLength());
but the result are the same. Is there's any event will trigger after all image finish loading? Or is there any other way to fix this?