title: File open dialog in ImageJ Javascript Script
body: <p>I want to write a macro/script to open a file open dialog, and then import the selected image using BF with various options.</p>
  
  <p>I found this JS script for doing the latter part <a href="http://imagej.net/Scripting_toolbox#Macro_2" rel="nofollow">here</a>: </p>
  
  <pre><code>importClass(Packages.loci.plugins.BF);
  importClass(Packages['loci.plugins.in.ImporterOptions']); // 'in' is a reserved word, hence the different syntax
  importClass(Packages.loci.common.Region);
  
  var path = "/path/to/file";
  var options = new ImporterOptions();
  options.setId(path);
  options.setAutoscale(true);
  options.setCrop(true);
  options.setCropRegion(0, new Region(x, y, w. h));
  options.setColorMode(ImporterOptions.COLOR_MODE_COMPOSITE);
  var imps = BF.openImagePlus(options);
  
  imps[0].show();
  </code></pre>
  
  <p>I also found the regular macro language file open dialog <a href="http://rsb.info.nih.gov/ij/developer/macro/functions.html#F" rel="nofollow">here</a>:</p>
  
  <pre><code>File.openDialog(title)
  </code></pre>
  
  <p>How do I do both of these things in a JS script? Specifically, how do I create the file open dialog in JS?</p>
  
  <p>If it is easier to do both in the macro IJM language, rather than Javascript, then how do I create a BF object and set the import options?</p>