Skip to content

Commit

Permalink
Execute Swing code in Swing event thread.
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentg committed Oct 2, 2014
1 parent 9ef063d commit 1e107d6
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/main/java/org/truffautronic/view/MixerControlView.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()];
}
Expand Down

0 comments on commit 1e107d6

Please sign in to comment.