Nathalie
Nathalie

Reputation: 192

ImageJ dialog path

I have a Dialog asking for Preferences, in this Dialog I would like to aks for a path. I'm doing this: Dialog.addString("Saving directory", directory); ... I'm asking for lot more.

but I would like to have open up a new window, where you can search the path, like with this command but with more questions and answers in the Dialog. path = File.openDialog("Select a File");

thank you

Upvotes: 0

Views: 2570

Answers (1)

Jan Eglinger
Jan Eglinger

Reputation: 4090

If you're using Fiji, you can try its GenericDialogPlus class, e.g. in Javascript:

importClass(Packages.fiji.util.gui.GenericDialogPlus);

gdp = new GenericDialogPlus("New dialog");
gdp.addDirectoryField("Directory", "/");
gdp.addCheckbox("Other option", true);
gdp.showDialog();

In plain ImageJ 1.x macro language, the preferred way of asking for directories and additional parameters is to have several consecutive dialogs. Use getDirectory("Choose a Directory") to ask for a directory, and use the Dialog functions to ask for other parameters:

path = getDirectory("Choose a Directory");
Dialog.create("Choose parameters");
Dialog.addString("Title:", title);
Dialog.show();
title = Dialog.getString();

print path;
print title;

Upvotes: 2

Related Questions