Skip to content
Permalink
Browse files

LoadAndDisplayDataset: fix showing of the dataset

It was previously assumed that the Swing UI was active and visible, such
that calling DisplayService#createDisplay would result in the new
display being automatically shown. But since the example is currently
written *not* to show any UI, we must explicitly tell the UI service to
show the dataset instead, by calling UIService#show(Object).

The alternative would be to instead call UIService#showUI() before
creating the display. The difference would be that the ImageJ main
window would then also be visible.
  • Loading branch information...
ctrueden committed Jan 18, 2013
1 parent a2802ad commit 4b8f5337ea614c3f6f39a3111c760c1c07521613
Showing with 3 additions and 4 deletions.
  1. +3 −4 load-and-display-dataset/src/main/java/LoadAndDisplayDataset.java
@@ -8,8 +8,8 @@

import imagej.ImageJ;
import imagej.data.Dataset;
import imagej.display.DisplayService;
import imagej.io.IOService;
import imagej.ui.UIService;

import java.io.File;

@@ -33,9 +33,8 @@ public static void main(final String... args) throws Exception {
final Dataset dataset = ioService.loadDataset(file.getAbsolutePath());

// display the dataset
final DisplayService displayService =
context.getService(DisplayService.class);
displayService.createDisplay(file.getName(), dataset);
final UIService uiService = context.getService(UIService.class);
uiService.show(dataset);
}

}

0 comments on commit 4b8f533

Please sign in to comment.
You can’t perform that action at this time.