1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-01-17 06:52:18 +01:00

Forcing GUI update events to happen in the Event Dispatch Thread

This commit is contained in:
Federico Fissore 2013-10-15 18:09:52 +02:00
parent f7f616c3bb
commit 027f7c7403
2 changed files with 20 additions and 10 deletions

View File

@ -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();
}

View File

@ -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();
}
});
}
}