Here is a snippet
kit.insertHTML(doc, doc.getLength(), \"Hello\", 0, 0, null);
try{
Thread.sleep(1000);
}catch(Exception e){}
I am using
Thread.sleep is a long running task. When you a running such a task in the EDT it blocks all repaint requests from being executed. All repaint requests which are pending and which were sent during the sleep phase are queued for future processing.
As a result when the EDT comes out of the sleep phase it coalesce all such repaint request (if coalescing is enabled which is the default property) into a single repaint which gets executed. If coalescing is not enabled then all queued request are executed serially without any time gap in between. As a result it seems that the UI did not update.
To correct the situation use a SwingTimer which triggers periodically after specific intervals of time, or a SwingWorker.