I'm trying to add an options menu to my program, with the options changeable using JCheckBoxMenuItems. Whatever the value of these options is will be saved to a file when the program closes. The file will be read when the program starts and the values set to the boolean read in. (ie. a check mark appears next to an item if the value read in is true, and one isn't there if the value is false).
This is what I have so far:
boolean soundEnabled = true;
JMenu fmOptionsMenu = new JMenu("Options");
fileMenu.add(fmOptionsMenu);
JCheckBoxMenuItem omSoundEnable = new JCheckBoxMenuItem("Enable Sound");
omSoundEnable.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent arg0) {
soundEnabled = !soundEnabled;
}
});
fmOptionsMenu.add(omSoundEnable);
How can I set the default values, and is a PropertyChangeListener the correct one to use?