ros*_*it3 3 java configuration swing file configuration-files
我创建了一个Swing Application-GUI,其中包含TextFields,Labels,CheckBoxes和ComboBoxes等字段.当用户输入一些信息时,我希望将文本字段,组合框和复选框的详细信息保存到文件中,下次用户打开此窗口时,我想要保存在文件中的详细信息,即那些用户输入的上一次加载到GUI中.有人可以帮我这样做吗?我希望你理解这个问题,如果没有,我会以更详细的方式解释.
非常感谢你提前.
这是一个使用java.util.prefs包的简单示例:
// Retrieve the user preference node for the package com.mycompany
Preferences prefs = Preferences.userNodeForPackage(com.mycompany.MyClass.class);
// Preference key name
final String PREF_NAME = "name_of_preference";
// Set the value of the preference
String newValue = "a string";
prefs.put(PREF_NAME, newValue);
// Get the value of the preference;
// default value is returned if the preference does not exist
String defaultValue = "default string";
String propertyValue = prefs.get(PREF_NAME, defaultValue); // "a string"
Run Code Online (Sandbox Code Playgroud)
保存首选项的方式取决于操作系统.在Windows上,它将使用注册表.
使用示例:http://www.exampledepot.com/egs/java.util.prefs/pkg.html
| 归档时间: |
|
| 查看次数: |
6445 次 |
| 最近记录: |