File tree 1 file changed +20
-4
lines changed
src/main/java/org/scijava/ui
1 file changed +20
-4
lines changed Original file line number Diff line number Diff line change 32
32
import java .awt .GraphicsEnvironment ;
33
33
import java .io .File ;
34
34
import java .io .FileFilter ;
35
+ import java .lang .reflect .InvocationTargetException ;
35
36
import java .util .ArrayList ;
36
37
import java .util .Collections ;
37
38
import java .util .HashMap ;
@@ -161,10 +162,25 @@ public void showUI(final String name) {
161
162
@ Override
162
163
public void showUI (final UserInterface ui ) {
163
164
log .debug ("Launching user interface: " + ui .getClass ().getName ());
164
- ui .show ();
165
- // NB: Also show all the current displays.
166
- for (final Display <?> display : displayService .getDisplays ()) {
167
- ui .show (display );
165
+ Runnable showUI = () -> {
166
+ ui .show ();
167
+ // NB: Also show all the current displays.
168
+ for (final Display <?> display : displayService .getDisplays ()) {
169
+ ui .show (display );
170
+ }
171
+ };
172
+
173
+ // Dispatch on EDT if necessary
174
+ if (ui .requiresEDT ()) {
175
+ try {
176
+ threadService .invoke (showUI );
177
+ }
178
+ catch (InterruptedException | InvocationTargetException e ) {
179
+ throw new RuntimeException (e );
180
+ }
181
+ }
182
+ else {
183
+ showUI .run ();
168
184
}
169
185
eventService .publish (new UIShownEvent (ui ));
170
186
}
You can’t perform that action at this time.
0 commit comments