9
9
10
10
import javax .swing .JCheckBoxMenuItem ;
11
11
import javax .swing .JMenu ;
12
+ import javax .swing .SwingUtilities ;
12
13
import java .util .HashMap ;
13
14
import java .util .Map ;
14
15
16
+ import static java .util .concurrent .CompletableFuture .runAsync ;
17
+
15
18
public class StatsMenu extends AbstractEnigmaMenu {
16
19
private final JCheckBoxMenuItem enableIcons = new JCheckBoxMenuItem ();
17
20
private final JCheckBoxMenuItem includeSynthetic = new JCheckBoxMenuItem ();
@@ -67,17 +70,17 @@ public void updateState(boolean jarOpen, ConnectionState state) {
67
70
68
71
private void onEnableIconsClicked () {
69
72
Config .main ().features .enableClassTreeStatIcons .setValue (this .enableIcons .isSelected ());
70
- this .gui . getController (). regenerateAndUpdateStatIcons ();
73
+ this .updateIconsLater ();
71
74
}
72
75
73
76
private void onIncludeSyntheticClicked () {
74
77
Config .main ().stats .shouldIncludeSyntheticParameters .setValue (this .includeSynthetic .isSelected ());
75
- this .gui . getController (). regenerateAndUpdateStatIcons ();
78
+ this .updateIconsLater ();
76
79
}
77
80
78
81
private void onCountFallbackClicked () {
79
82
Config .main ().stats .shouldCountFallbackNames .setValue (this .countFallback .isSelected ());
80
- this .gui . getController (). regenerateAndUpdateStatIcons ();
83
+ this .updateIconsLater ();
81
84
}
82
85
83
86
private void onCheckboxClicked (StatType type ) {
@@ -89,6 +92,10 @@ private void onCheckboxClicked(StatType type) {
89
92
Config .stats ().includedStatTypes .value ().remove (type );
90
93
}
91
94
92
- this .gui .getController ().regenerateAndUpdateStatIcons ();
95
+ this .updateIconsLater ();
96
+ }
97
+
98
+ private void updateIconsLater () {
99
+ SwingUtilities .invokeLater (() -> runAsync (() -> this .gui .getController ().regenerateAndUpdateStatIcons ()));
93
100
}
94
101
}
0 commit comments