Skip to content

Commit

Permalink
Merge pull request #481 from scijava/show-ui-edt
Browse files Browse the repository at this point in the history
  • Loading branch information
hinerm committed Jul 22, 2024
2 parents 3074675 + 96827bf commit 08e86be
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/main/java/org/scijava/ui/DefaultUIService.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.awt.GraphicsEnvironment;
import java.io.File;
import java.io.FileFilter;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
Expand Down Expand Up @@ -161,10 +162,25 @@ public void showUI(final String name) {
@Override
public void showUI(final UserInterface ui) {
log.debug("Launching user interface: " + ui.getClass().getName());
ui.show();
// NB: Also show all the current displays.
for (final Display<?> display : displayService.getDisplays()) {
ui.show(display);
Runnable showUI = () -> {
ui.show();
// NB: Also show all the current displays.
for (final Display<?> display : displayService.getDisplays()) {
ui.show(display);
}
};

// Dispatch on EDT if necessary
if (ui.requiresEDT()) {
try {
threadService.invoke(showUI);
}
catch (InterruptedException | InvocationTargetException e) {
throw new RuntimeException(e);
}
}
else {
showUI.run();
}
eventService.publish(new UIShownEvent(ui));
}
Expand Down

0 comments on commit 08e86be

Please sign in to comment.