boolean htmlSelected = fileChooser.getFileFilter() == htmlFilter; if(htmlSelected) { selectedFile = FileName.extend(selectedFile, ".html"); } else { selectedFile = FileName.extend(selectedFile, ".csv"); }
selectedFile = ((SuffixFileFilter)fileChooser.getFileFilter()).makeAcceptable(selectedFile);
	public void export() {		JFileChooser fileChooser = new JFileChooser();		FileFilter htmlFilter = Filters.HTML;		FileFilter csvFilter = Filters.CSV;		fileChooser.setFileFilter(null);		fileChooser.addChoosableFileFilter(htmlFilter);		fileChooser.addChoosableFileFilter(csvFilter);		int retVal = fileChooser.showSaveDialog(this);		if (retVal == JFileChooser.APPROVE_OPTION) {			File selectedFile = fileChooser.getSelectedFile();			boolean htmlSelected = fileChooser.getFileFilter() == htmlFilter;			if(htmlSelected) {				selectedFile = FileName.extend(selectedFile, ".html");			} else {				selectedFile = FileName.extend(selectedFile, ".csv");			}			if (selectedFile.exists()) {				if (selectedFile.canWrite()) {					int chosen = JOptionPane							.showConfirmDialog(									this,									Messages.getString("Main.11"), Messages.getString("Main.12"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); //$NON-NLS-1$ //$NON-NLS-2$					if (chosen == JOptionPane.NO_OPTION) {						return;					}				} else {					JOptionPane							.showMessageDialog(									this,									Messages.getString("Main.13"), Messages.getString("Main.14"), JOptionPane.ERROR_MESSAGE); //$NON-NLS-1$ //$NON-NLS-2$					return;				}			}			PrintStream ps;			try {				ps = new PrintStream(new FileOutputStream(selectedFile));				if(htmlSelected) {					String imageURL = selectedFile.getAbsolutePath().substring(0, selectedFile.getAbsolutePath().length()-4)+"png";					File imageFile = new File(imageURL);					FileOutputStream fos = new FileOutputStream(imageFile);					DriveTrainPNGWriter.writePNG(fos, driveTrainDrawing, driveTrainDrawing.getSize().width, driveTrainDrawing.getSize().height);					fos.close();					DriveTrainHTMLWriter.writeHTML(ps, new TableAdapter(model, style), imageFile.getName());				} else {					DriveTrainCSVWriter.writeCSV(ps, model);				}				ps.close();			} catch (IOException e) {				JOptionPane.showMessageDialog(this, Messages.format(						"Main.15", e.getLocalizedMessage()), //$NON-NLS-1$ 						Messages.getString("Main.16"), JOptionPane.ERROR_MESSAGE); //$NON-NLS-1$			}		}	}