Skip to content

Commit 027f7c7

Browse files
author
Federico Fissore
committed
Forcing GUI update events to happen in the Event Dispatch Thread
1 parent f7f616c commit 027f7c7

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

app/src/processing/app/EditorConsole.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,18 @@ public EditorConsole(Editor editor) {
175175
// should the interval come from the preferences file?
176176
new javax.swing.Timer(250, new ActionListener() {
177177
public void actionPerformed(ActionEvent evt) {
178-
// only if new text has been added
179-
if (consoleDoc.hasAppendage) {
180-
// insert the text that's been added in the meantime
181-
consoleDoc.insertAll();
182-
// always move to the end of the text as it's added
183-
consoleTextPane.setCaretPosition(consoleDoc.getLength());
184-
}
178+
SwingUtilities.invokeLater(new Runnable() {
179+
@Override
180+
public void run() {
181+
// only if new text has been added
182+
if (consoleDoc.hasAppendage) {
183+
// insert the text that's been added in the meantime
184+
consoleDoc.insertAll();
185+
// always move to the end of the text as it's added
186+
consoleTextPane.setCaretPosition(consoleDoc.getLength());
187+
}
188+
}
189+
});
185190
}
186191
}).start();
187192
}

app/src/processing/app/syntax/JEditTextArea.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1998,9 +1998,14 @@ static class CaretBlinker implements ActionListener
19981998
{
19991999
public void actionPerformed(ActionEvent evt)
20002000
{
2001-
if(focusedComponent != null
2002-
&& focusedComponent.hasFocus())
2003-
focusedComponent.blinkCaret();
2001+
SwingUtilities.invokeLater(new Runnable() {
2002+
@Override
2003+
public void run() {
2004+
if(focusedComponent != null
2005+
&& focusedComponent.hasFocus())
2006+
focusedComponent.blinkCaret();
2007+
}
2008+
});
20042009
}
20052010
}
20062011

0 commit comments

Comments
 (0)