Login  Register

Re: Preselected path for ij.io.DirectoryChooser?

Posted by Michael Schmid on May 10, 2010; 11:47am
URL: http://imagej.273.s1.nabble.com/Preselected-path-for-ij-io-DirectoryChooser-tp3688355p3688358.html

Hi Tamjid,

DirectoryChooser.setDefaultDirectory is a static method, you can call  
it without any instance of DirectoryChooser but rather with the class  
name:

    DirectoryChooser.setDefaultDirectory(defaultdir);
    DirectoryChooser dc = new DirectoryChooser("Preferred Directory:");

The default directory is a static variable, it survives in memory  
without any instance of DirectoryChooser.

Michael
________________________________________________________________

On 10 May 2010, at 13:12, Tamjid wrote:

> Hi Michael
>
>           thanks but I am not clear yet, perhaps I have to clarify my
> problem:
>
>                line #1: DirectoryChooser dc = new
> DirectoryChooser("Preferred Directory:");
>                line #2:            dc.setDefaultDirectory(t2.getText
> ());
>
>
>           The instance of DirectoryChooser is created first - so it  
> will
> already be loaded with the path/directory that was selected last,  
> but I want
> the "instance of DirectoryChooser" to come up with whatever is  
> currently in
> t2.getText() (BTW: t2 is a TextArea where a path is pasted).
>
>
> In summary, the question could be, how can the line#2 be executed  
> before
> executing line # 1? Is it possible?
>
> Obviously, instance of DirectoryChooser, when created and loaded,  
> reads the
> last selected directory from somewhere (I don't know where is that  
> place and
> how to access that?- so need to that)  - can we write our preferred
> directory/path in that place first?
>
>
> Any help/suggestion?
>
> Thanks
> Tamjid
>
>
>
>
> On Mon, May 10, 2010 at 6:08 PM, Michael Schmid  
> <[hidden email]>wrote:
>
>> Hi Tamjid,
>>
>> you can use setDefaultDirectory(String dir), that's what it is  
>> good for.
>> You can even use it from a macro with a
>> call("ij.io.DirectoryChooser.setDefaultDirectory", dir); macro  
>> command.
>>
>> Michael
>> ________________________________________________________________
>>
>>
>> On 10 May 2010, at 06:20, Md Tamjidul Hoque wrote:
>>
>>  Dear All
>>>
>>>           is it possible to call DirectoryChooser such a way that  
>>> it can
>>> start with a particular path / directory?
>>>
>>> By the way, I think "setDefaultDirectory" can not be used or can we?
>>>
>>> Any suggestion?
>>>
>>> Thanks
>>> Tamjid
>>>
>>>