I have a background Thread that gets text data from an InputStream and tries to insert it into a JTextPane:
iLen = doc.getLength();
doc.insertString(iLen, lineS, normalStyle);
if ( iLen > 0 )
textPane.setCaretPosition(doc.getLength() - 1);
Basically my problem is that a lot of the time text is coming through, and it's calling this section of code, but nothing gets drawn till a large section of text has come through.
I understand that a lot is going on behind the scenes and I don't have any Listener or anything.
So is there any fairly simple way I can get it to draw almost every time that it's called?
Or at least more often than it is now?
Try to use
textPane.repaint()
after setting the position of the caret.