Configuration file in Java
I created a swing application GUI, which contains textfields, labels, Check@R_780_2419 @Es and Combo@R_780_2419 @Es and other fields When the user inputs some information, I want to save the details of text fields, combo boxes and check boxes to the file. The next time the user opens this window, I want to save the details in the file, that is, the last time those user inputs were loaded into the GUI Can someone do this for me? I hope you understand this problem. If not, I will explain it in more detail
Thank you very much for your advance
Solution
Here is how to use Java util. Simple example of prefs package:
// 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"
How preferences are saved depends on the operating system On windows, it will use the registry
Usage example: http://www.exampledepot.com/egs/java.util.prefs/pkg.html