From 027f7c7403a329bdac160f190bfe4755c4074790 Mon Sep 17 00:00:00 2001 From: Federico Fissore Date: Tue, 15 Oct 2013 18:09:52 +0200 Subject: [PATCH] Forcing GUI update events to happen in the Event Dispatch Thread --- app/src/processing/app/EditorConsole.java | 19 ++++++++++++------- .../processing/app/syntax/JEditTextArea.java | 11 ++++++++--- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/app/src/processing/app/EditorConsole.java b/app/src/processing/app/EditorConsole.java index 7b8e3656f..786fd8a16 100644 --- a/app/src/processing/app/EditorConsole.java +++ b/app/src/processing/app/EditorConsole.java @@ -175,13 +175,18 @@ public class EditorConsole extends JScrollPane { // should the interval come from the preferences file? new javax.swing.Timer(250, new ActionListener() { public void actionPerformed(ActionEvent evt) { - // only if new text has been added - if (consoleDoc.hasAppendage) { - // insert the text that's been added in the meantime - consoleDoc.insertAll(); - // always move to the end of the text as it's added - consoleTextPane.setCaretPosition(consoleDoc.getLength()); - } + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + // only if new text has been added + if (consoleDoc.hasAppendage) { + // insert the text that's been added in the meantime + consoleDoc.insertAll(); + // always move to the end of the text as it's added + consoleTextPane.setCaretPosition(consoleDoc.getLength()); + } + } + }); } }).start(); } diff --git a/app/src/processing/app/syntax/JEditTextArea.java b/app/src/processing/app/syntax/JEditTextArea.java index aa7e220e3..fb99d663b 100644 --- a/app/src/processing/app/syntax/JEditTextArea.java +++ b/app/src/processing/app/syntax/JEditTextArea.java @@ -1998,9 +1998,14 @@ public class JEditTextArea extends JComponent { public void actionPerformed(ActionEvent evt) { - if(focusedComponent != null - && focusedComponent.hasFocus()) - focusedComponent.blinkCaret(); + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + if(focusedComponent != null + && focusedComponent.hasFocus()) + focusedComponent.blinkCaret(); + } + }); } }