Re: Possible to set default directory
Posted by
Michael Schmid on
Apr 05, 2015; 6:52pm
URL: http://imagej.273.s1.nabble.com/Possible-to-set-default-directory-tp5012356p5012357.html
On Sun, April 5, 2015 20:10, Jon Harman wrote:
> When my plugin is executed from a command line sometimes the default
> directory gets incorrectly set (to c:\windows).
> So far I have not not figured out what is going on, but a possible fix
> would be to set that default directory to be the directory of the image
> opened in my plugin. Any way to do that? I don't see any way in the
> ImageJ open code.
Hi Jon,
ij.io.OpenDialog has a method
public OpenDialog(String title, String defaultDir, String defaultName)
where you can set the default directory. If you use some other way of
opening the file, you can use the OpenDialog method
public static void setDefaultDirectory(String defaultDir)
to set the default directory.
You can get the directory of an image via the ImagePlus method
String dir = imp.getOriginalFileInfo().directory;
Note that the directory many be null (if the image was not read from disk).
Michael
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html