从GUI保存用户设置 [英] Saving user settings from GUI

查看:76
本文介绍了从GUI保存用户设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当前正在编码一个应用程序,该应用程序具有一个选项框JDialog.该框架包含用户可以配置的各种复选框和文本字段.

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";

通过使用以下内容,我可以获取该字段,但是我需要做类似(对于复选框)myField.isSelected();的操作.这不起作用.

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);

谢谢.

推荐答案

您可以使用java.util.prefs.Preferences将配置存储在JDialog中.这个问题- Java Preference Manager -讨论有关如何通过使用Preferences创建前端+后端解决方案的方法(例如JFace org.eclipse.jface.preference)

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)

这篇关于从GUI保存用户设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆