File tree Expand file tree Collapse file tree 1 file changed +20
-4
lines changed
src/main/java/org/scijava/ui Expand file tree Collapse file tree 1 file changed +20
-4
lines changed Original file line number Diff line number Diff line change 3232import java .awt .GraphicsEnvironment ;
3333import java .io .File ;
3434import java .io .FileFilter ;
35+ import java .lang .reflect .InvocationTargetException ;
3536import java .util .ArrayList ;
3637import java .util .Collections ;
3738import java .util .HashMap ;
@@ -161,10 +162,25 @@ public void showUI(final String name) {
161162 @ Override
162163 public void showUI (final UserInterface ui ) {
163164 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 ();
168184 }
169185 eventService .publish (new UIShownEvent (ui ));
170186 }
You can’t perform that action at this time.
0 commit comments