public static File chooseSaveFileCheckOverwrite(Component parent,
JFileChooser chooser, final String suffix,
Preferences prefs, String prefsKey)
{
	String path = null;
	String fname = null;
	if (prefs != null) {
		String sdir = prefs.get(prefsKey, null);
		if (sdir != null) chooser.setCurrentDirectory(new File(sdir));
	}
	for (;;) {
		chooser.showSaveDialog(parent);

		path = chooser.getCurrentDirectory().getAbsolutePath();
		prefs.put(prefsKey, path);
		if (chooser.getSelectedFile() == null) return null;
		fname = chooser.getSelectedFile().getPath();
		if (!fname.endsWith(suffix)) fname = fname + suffix;
		File f = new File(fname);
		if (!f.exists()) return f;
		if (JOptionPane.showConfirmDialog(parent,
			"The file " + f.getName() + " already exists.\nWould you like to ovewrite it?",
			"Overwrite File?", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) break;
	}
	return null;
//	return chooser.getSelectedFile();
}