1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-01-29 18:52:13 +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? // should the interval come from the preferences file?
new javax.swing.Timer(250, new ActionListener() { new javax.swing.Timer(250, new ActionListener() {
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
// only if new text has been added SwingUtilities.invokeLater(new Runnable() {
if (consoleDoc.hasAppendage) { @Override
// insert the text that's been added in the meantime public void run() {
consoleDoc.insertAll(); // only if new text has been added
// always move to the end of the text as it's added if (consoleDoc.hasAppendage) {
consoleTextPane.setCaretPosition(consoleDoc.getLength()); // 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(); }).start();
} }

View File

@ -1998,9 +1998,14 @@ public class JEditTextArea extends JComponent
{ {
public void actionPerformed(ActionEvent evt) public void actionPerformed(ActionEvent evt)
{ {
if(focusedComponent != null SwingUtilities.invokeLater(new Runnable() {
&& focusedComponent.hasFocus()) @Override
focusedComponent.blinkCaret(); public void run() {
if(focusedComponent != null
&& focusedComponent.hasFocus())
focusedComponent.blinkCaret();
}
});
} }
} }