Saving user settings from GUI

帅比萌擦擦* 提交于 2019-12-02 07:49:02

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!