Skip to content

Instantly share code, notes, and snippets.

@mutterer
Last active July 4, 2020 11:45
Show Gist options
  • Save mutterer/0bdb047c6b7e3a5b82ced6e68e3187f8 to your computer and use it in GitHub Desktop.
Save mutterer/0bdb047c6b7e3a5b82ced6e68e3187f8 to your computer and use it in GitHub Desktop.
example for using the new directory chooser field in generic dialogs in ImageJ
import ij.*;
import ij.gui.*;
import ij.plugin.*;
// requires ImageJ 1.53d8 or later
public class My_DialogWithDirChooser implements PlugIn {
String dir;
public void run(String arg) {
dir = "empty";
if (!showDialog()) return;
IJ.log("you chose: "+dir);
}
boolean showDialog() {
GenericDialog gd = new GenericDialog("Dialog with dir chooser");
gd.addMessage("\u2606"+" Instructions here !");
gd.addDirectoryField("dir chooser \u261E", IJ.getDirectory("home"));
gd.showDialog();
if (gd.wasCanceled())
return false;
dir = gd.getNextString();
return true;
}
}
@mutterer
Copy link
Author

mutterer commented Jul 4, 2020

removed the unicode char from label's first word as this is what gets recorded!
run("My DialogWithDirChooser", "dir=/Users/jeromemutterer/");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment