public ChooserUtil () {
}
public static void saveSurveyChooser(JFrame frame, Survey survey) {
WarnIfExistsChooser chooser = new WarnIfExistsChooser() {
protected String currentFileFilterExtension() {
//if the file filter is "All Files", WarnIfExistsChooser won't use this value
return "xml";
}
};
chooser.addChoosableFileFilter(new FileNameExtensionFilter("XML Files", "xml"));
if (chooser.showSaveDialog(frame) == JFileChooser.APPROVE_OPTION) {
try {
survey.saveXMLAnswers(chooser.getSelectedFile().getAbsolutePath());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}