From 1e107d66e12a2add8831d9d1fecd6e5bded3fd66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurent=20Gr=C3=A9goire?= Date: Thu, 2 Oct 2014 18:02:59 +0200 Subject: [PATCH] Execute Swing code in Swing event thread. --- .../org/truffautronic/view/MixerControlView.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/truffautronic/view/MixerControlView.java b/src/main/java/org/truffautronic/view/MixerControlView.java index 4b5c7aa..24cf241 100644 --- a/src/main/java/org/truffautronic/view/MixerControlView.java +++ b/src/main/java/org/truffautronic/view/MixerControlView.java @@ -34,6 +34,7 @@ import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JSlider; +import javax.swing.SwingUtilities; import javax.swing.border.EtchedBorder; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; @@ -175,12 +176,20 @@ public void run() { int currValue = mixSlider.getValue(); int timeout = 10000; if (automixTarget >= 0 && currValue != automixTarget) { - int newValue = currValue < automixTarget ? currValue + 1 + final int newValue = currValue < automixTarget ? currValue + 1 : currValue - 1; - mixSlider.setValue(newValue); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + mixSlider.setValue(newValue); + } + }); if (newValue == automixTarget) { automixTarget = -1; - updateAutomixIcon(); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + updateAutomixIcon(); + } + }); } timeout = AUTOMIX_DELAY_MS[automixSpeedSlider.getValue()]; }