Re: Different directorychooser behavior
Posted by
Raymond Martin-2 on
Dec 14, 2009; 11:50pm
URL: http://imagej.273.s1.nabble.com/Different-directorychooser-behavior-tp3690099p3690101.html
Hi,
> I use the directoryChooser in a plugin and have noticed different
> behavior in it lately. Maybe due to a Java update?
> The behavior (on Windows XP) is this:
> I use it twice, since I need to choose input and output directories for
> the plugin. The first time all is well, it opens in My Documents. I
> choose a subdirectory.
>
> Then the second time it opens two directories above the one that I
> chose, which requires more navigating to get back to where I was. This
> is confusing to Windows users who are not used to navigating above My
> Documents.
>
> The behavior used to be that it would open in the directory above the
> one I choose. It opens two directories above even when I set the
> default directory for the second choice. Here is my code:
>
> DirectoryChooser idc =
> new DirectoryChooser("Choose the input directory of RGB images");
> indir = idc.getDirectory();
> if(indir == null) return;
> idir = new File(indir);
> if (!idir.isDirectory() || !idir.exists()) {
> IJ.showMessage("Input directory error");
> return;
> }
> DirectoryChooser odc = new DirectoryChooser("Choose the output
> directory for enhanced images");
> odc.setDefaultDirectory(idir.getParent());
> outdir = odc.getDirectory();
> if(outdir == null) {
> return;
> }
>
> What am I doing wrong?
Nothing. Problem must be in DirectoryChooser or Java.
Raymond