1

I am currently coding an application, which has an option frame JDialog. This frame contains various checkboxes and text fields that the user can configure.

I want to save the changes the user made to the options.

What is the best way of doing so?

My first thought was implementing it by saving it in a file with the format of e.g.

checkBox1=value;
textArea1="value";

By using the following I could get the field, but I would need to do something like (for the checkbox) myField.isSelected(); which does not work.

Field myField = MyClass.class.getDeclaredField(name);

Thank you in advance.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Max Ni
  • 183
  • 1
  • 1
  • 7
  • Possible duplicate of [Object persistence in Java applets](http://stackoverflow.com/questions/7954183/object-persistence-in-java-applets). – Andrew Thompson Jan 22 '13 at 10:01
  • 1
    Thanks for the link, didnt found it since I looked for the wrong keywords, duh. – Max Ni Jan 25 '13 at 14:03

1 Answers1

1

You can use java.util.prefs.Preferences to store the configuration in your JDialog. This question - Java Preference Manager - discuss about how to create frontend+backend solution by using Preferences (something like JFace org.eclipse.jface.preference)

Community
  • 1
  • 1
jocki
  • 1,728
  • 16
  • 26