Re: ij.Prefs and IJ_Prefs.txt

Posted by drix on
URL: http://imagej.273.s1.nabble.com/ij-Prefs-and-IJ-Prefs-txt-tp3693279p3693280.html

Hi Colin,

On Tue, Mar 17, 2009 at 12:34 PM, Colin Poczatek
<[hidden email]> wrote:

> I'm having some trouble understanding how to get/set preferences.  So
> lets say that in IJ_Prefs.txt there's a line:
>
> dir.image=/nrims/home3/cpoczatek/biggers_movie/
>
> So when create a new ij.Prefs object based on the API docs it sounds
> like it reads and parses that file, but I don't have a "dir.image" key
> in that Prefs object.  What am I missing?  Do I need to call
> prefs.load(Object ij, Applet a)?  ij should be IJ.getInstance()?  What
> applet?
>
> ij.Prefs prefs = new ij.Prefs();
> System.out.println(prefs.get("dir.image", ""));
>
> Just prints "" because it doesn't have the key.
>
> And that is the default path you get when the user saves/opens/etc
> right?  I mean imagej is looking at that file for the default path?  And
> I should be able to call
>
> prefs.set("dir.image", someotherstring);

Do you use the save command in your code?
Prefs.savePreferences();
Also I use the static version in my plugins, i.e., Prefs and not
ij.Prefs prefs = new ij.Prefs();

Personally, I use the Preference utility from Java to save my
preference and it work great.
import java.util.prefs.Preferences;

Hendrix