private File selectExportFile(final String title,FileNameExtensionFilter fileNameExtensionFilter){
  if (Boolean.parseBoolean(System.getProperty("use.native.choosers",Boolean.toString(OSType.isMac())))) {
    FileDialog exportDialog=fileDialogs.get(title);
    if (exportDialog == null) {
      exportDialog=new FileDialog(this,title,FileDialog.SAVE);
      fileDialogs.put(title,exportDialog);
    }
    exportDialog.setFile(options.fileNameStem + ".xml");
    exportDialog.setVisible(true);
    if (exportDialog.getFile() != null) {
      return new File(exportDialog.getDirectory(),exportDialog.getFile());
    }
  }
 else {
    JFileChooser exportChooser=fileChoosers.get(title);
    if (exportChooser == null) {
      exportChooser=new JFileChooser(Utils.getCWD());
      exportChooser=new JFileChooser(Utils.getCWD());
      exportChooser.setFileFilter(fileNameExtensionFilter);
      exportChooser.setDialogTitle(title);
      fileChoosers.put(title,exportChooser);
    }
    exportChooser.setSelectedFile(new File(options.fileNameStem + ".xml"));
    final int returnVal=exportChooser.showSaveDialog(this);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
      File file=exportChooser.getSelectedFile();
      int n=JOptionPane.YES_OPTION;
      if (file.exists()) {
        n=JOptionPane.showConfirmDialog(this,file.getName(),"Overwrite the existing file?",JOptionPane.YES_NO_OPTION);
      }
      if (n == JOptionPane.YES_OPTION) {
        return file;
      }
    }
  }
  return null;
}

private File selectExportFile ( final String title , FileNameExtensionFilter fileNameExtensionFilter ) { if ( Boolean . parseBoolean ( System . getProperty ( "use.native.choosers" , Boolean . toString ( OSType . isMac ( ) ) ) ) ) { FileDialog exportDialog = fileDialogs . get ( title ) ; if ( exportDialog == null ) { exportDialog = new FileDialog ( this , title , FileDialog . SAVE ) ; fileDialogs . put ( title , exportDialog ) ; } exportDialog . setFile ( options . fileNameStem + ".xml" ) ; exportDialog . setVisible ( true ) ; if ( exportDialog . getFile ( ) != null ) { return new File ( exportDialog . getDirectory ( ) , exportDialog . getFile ( ) ) ; } } else { JFileChooser exportChooser = fileChoosers . get ( title ) ; if ( exportChooser == null ) { exportChooser = new JFileChooser ( Utils . getCWD ( ) ) ; exportChooser = new JFileChooser ( Utils . getCWD ( ) ) ; exportChooser . setFileFilter ( fileNameExtensionFilter ) ; exportChooser . setDialogTitle ( title ) ; fileChoosers . put ( title , exportChooser ) ; } exportChooser . setSelectedFile ( new File ( options . fileNameStem + ".xml" ) ) ; final int returnVal = exportChooser . showSaveDialog ( this ) ; if ( returnVal == JFileChooser . APPROVE_OPTION ) { File file = exportChooser . getSelectedFile ( ) ; int n = JOptionPane . YES_OPTION ; if ( file . exists ( ) ) { n = JOptionPane . showConfirmDialog ( this , file . getName ( ) , "Overwrite the existing file?" , JOptionPane . YES_NO_OPTION ) ; } if ( n == JOptionPane . YES_OPTION ) { return file ; } } } return null ; }
use the native file dialog on the mac because the swing one is bad . on linux , the native one is bad . no preference on windows .
