Persisting State In java.util.prefs or Somewhere Else?

Posted by Alan Brooks on
URL: http://imagej.273.s1.nabble.com/Persisting-State-In-java-util-prefs-or-Somewhere-Else-tp5024392.html

I am using the newly available Toolbar.setIcon() method to provide the ability to set a visualization configuration that is persistent across ImageJ sessions. I am currently using java.util.prefs.Preferences to accomplish this, as shown below. Is there something for user preferences within ImageJ I should be considering instead?


isOn = eval("script", 'java.util.prefs.Preferences.userRoot().getBoolean("ab.rotator.isOn", false);');
if (isOn=="false") {
   call("ij.gui.Toolbar.setIcon", "Toggle Rotator Action Tool", "Cc00V00ff");
   eval("script", 'java.util.prefs.Preferences.userRoot().putBoolean("ab.rotator.isOn", true);');
   showStatus("Rotator enabled");
} else {
   call("ij.gui.Toolbar.setIcon", "Toggle Rotator Action Tool", "C00cF00ff");
   eval("script", 'java.util.prefs.Preferences.userRoot().putBoolean("ab.rotator.isOn", false);');
   showStatus("Rotator disabled");
}

Thanks,
Alan
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html