1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-17 22:23:10 +03: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,6 +175,9 @@ 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) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
// only if new text has been added // only if new text has been added
if (consoleDoc.hasAppendage) { if (consoleDoc.hasAppendage) {
// insert the text that's been added in the meantime // insert the text that's been added in the meantime
@ -183,6 +186,8 @@ public class EditorConsole extends JScrollPane {
consoleTextPane.setCaretPosition(consoleDoc.getLength()); consoleTextPane.setCaretPosition(consoleDoc.getLength());
} }
} }
});
}
}).start(); }).start();
} }

View File

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