public File getFileChoice(Component parent) {
    if (chooser.showSaveDialog(parent) == JFileChooser.APPROVE_OPTION) {

      File newFile = chooser.getSelectedFile();

      if (chooser.getFileFilter() == zipFilter) {
        // ZIP was selected...add .zip to the end of the filename
        // if it doesnt exist already.

        if (!newFile.getName().toUpperCase().endsWith(".ZIP")) {
          newFile = new File(newFile.getAbsoluteFile() + ".zip");
        }
      }

      if (newFile.exists()) {
        int confirmChoice = JOptionPane.showConfirmDialog(parent, "File already exists. Do you want to replace it?");

        if (confirmChoice == JOptionPane.YES_OPTION) {
          newFile.delete();
        } else if (confirmChoice == JOptionPane.NO_OPTION) {
          return getFileChoice(parent); // Try again..
        } else {
          // Cancelled...
          return null;
        }
      }

      if (!newFile.exists()) {
        boolean fileCreated = false;
        try {
          fileCreated = newFile.createNewFile();
        } catch (Exception e) {
        } finally {
          if (!fileCreated) {
            JOptionPane.showMessageDialog(parent, "An Error Occurred");
            return null;
          }
        }
      }

      return newFile;
    } else {
      return null;
    }
  }