问题
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.
回答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
)
来源:https://stackoverflow.com/questions/14455801/saving-user-settings-from-gui