public class MyApplication extends AbstractMDIApplication { public MyApplication { super("MyApplication"); conf = AppliConfiguration.getInstance(); Preferences pref = Preferences.userRoot(); this.initConfiguration(pref); } }
public class MyApplication extends AbstractMDIApplication { public MyApplication { super("MyApplication"); conf = AppliConfiguration.getInstance(); } }or even:
public class MyApplication extends AbstractMDIApplication { public MyApplication { super("MyApplication"); setConfiguration(AppliConfiguration.getInstance()); } }
put
methods in the Preferences classget
methods in the Preferences classpublic void getConfiguration(Preferences pref, File dir) { boolean bValue = pref.getBoolean("myBooleanValue", false); int intValue = pref.getInt("myIntValue", 0); }
public void putConfiguration(Preferences pref, File dir) { pref.putBoolean("myBooleanValue", bValue); pref.putInt("myIntValue", intValue); }
public class OpenImagePlugin extends AbstractMDIPlugin { public OpenImagePlugin() { } public Configuration getPluginConfiguration() { return MyConfiguration.getInstance(); }
public class MyConfiguration implements Configuration { private static MyConfiguration conf = null; public boolean myBool = false; public int myInt = 0; public static MyConfiguration getInstance() { if (conf == null) { conf = new MyConfiguration(); } return conf; } public void getConfiguration(Preferences pref, File dir) { boolean bValue = pref.getBoolean("myBooleanValue", false); int intValue = pref.getInt("myIntValue", 0); } public void putConfiguration(Preferences pref, File dir) { pref.putBoolean("myBooleanValue", bValue); pref.putInt("myIntValue", intValue); } }
Copyright 2006-2023 Herve Girod. All Rights Reserved. Documentation and source under the LGPL v2 and Apache 2.0 licences