public static File getFile(Component parent, String title, boolean write) {
		JFileChooser fc = new JFileChooser();
		fc.setDialogTitle(title);
		if (write) {
			fc.showSaveDialog(parent);
		} else {
			fc.showOpenDialog(parent);
		}
		File f = fc.getSelectedFile();
		if (f == null || (!write && !f.exists()) || (f.exists() && !f.isFile())) {
			return null;
		}
		if (write && f.exists()) {
			int r = JOptionPane.showConfirmDialog(parent, "File \""
					+ f.getName() + "\" exists. Overwrite?");
			if (r != 0) {
				return null;
			}
		}
		return f;
	}