I'm having some trouble getting my code to compile.
This is a method that uses the class Value to save text to a file
public void saveEventsToFile() throws Exception {
String tmp = getEventsAsString();
value = Value.makeString(tmp);
Value.saveFile(value, "\\events" + "\\" + "YEAR" + "\\" + months[MONTH] + "\\" + DAY);
}
and this is part of a constructor of another object. I've got an actionlistener on a button (OK) and when that button is pressed, I want to call the saveEventsToFile method.
OK.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int h, m;
h = (Integer) hourSpinner.getValue();
m = (Integer) minuteSpinner.getValue();
parentPanel.createNewEvent(parentPanel.selectedBox, parentWindow, textPane.getText(), h, m);
parentPanel.selectedBox.saveEventsToFile();
dispose();
}
});
If I add throws Exception on actionPerformed my code does not compile, and without it I get "Unhandled exception" error on the arentPanel.selectedBox.saveEventsToFile(); line
How could I get this to compile? I've not had much experience with exceptions.