When are document inserts written to screen?


I was curious about the visual/repaint lifecycle of the Document. I'm doing something like the following.

                         final VisualPosition position = editor.getCaretModel().getVisualPosition();

            for (int i = 0; i < text.length(); i++) {
                final int offset = i;
                Document document = editor.getDocument();
                document.insertString(position.column + offset, Character.toString(text.charAt(offset)));
                try {
                } catch (InterruptedException e) {
                } finally {

As an experiement to see if a character would be placed in the document one at a time. Apart from getting the offset wrong somehow (they all apear on the first line of the editor), the text appears all at once. I can't seem to force the UI to update.

So my question is around understanding how to affect the screen or force a repaint. I'm doing the above in the event dispatching thread.


Comment actions Permalink

Maybe try do this after each insertString:


Comment actions Permalink

Nah, didn't help :(


Please sign in to leave a comment.