Program: 142995
Project: 142995
Buggy source:
public void action(){
  final String LAST_PATH="String_Node_Str";
  final String LAST_PATH_DEFAULT="String_Node_Str";
  final ExportController exportController=Lookup.getDefault().lookup(ExportController.class);
  if (exportController == null) {
    return;
  }
  String lastPathDefault=NbPreferences.forModule(GraphFileExporterUI.class).get(LAST_PATH_DEFAULT,null);
  String lastPath=NbPreferences.forModule(GraphFileExporterUI.class).get(LAST_PATH,lastPathDefault);
  FlowLayout layout=new FlowLayout(FlowLayout.RIGHT);
  JPanel optionsPanel=new JPanel(layout);
  final JButton optionsButton=new JButton(NbBundle.getMessage(GraphFileExporterUI.class,"String_Node_Str"));
  optionsPanel.add(optionsButton);
  optionsButton.addActionListener(new ActionListener(){
    public void actionPerformed(    ActionEvent e){
      ExporterUI exporterUI=exportController.getUI(selectedExporter);
      if (exporterUI != null) {
        JPanel panel=exporterUI.getPanel();
        exporterUI.setup(selectedExporter);
        DialogDescriptor dd=new DialogDescriptor(panel,NbBundle.getMessage(GraphFileExporterUI.class,"String_Node_Str",selectedExporter.getName()));
        Object result=DialogDisplayer.getDefault().notify(dd);
        exporterUI.unsetup(result == NotifyDescriptor.OK_OPTION);
      }
    }
  }
);
  final JPanel southPanel=new JPanel(new BorderLayout());
  southPanel.add(optionsPanel,BorderLayout.NORTH);
  GraphFileExporterUIPanel graphSettings=new GraphFileExporterUIPanel();
  graphSettings.setVisibleOnlyGraph(visibleOnlyGraph);
  southPanel.add(graphSettings,BorderLayout.CENTER);
  final JFileChooser chooser=new JFileChooser(lastPath){
    @Override protected JDialog createDialog(    Component parent) throws HeadlessException {
      JDialog dialog=super.createDialog(parent);
      Component c=dialog.getContentPane().getComponent(0);
      if (c != null && c instanceof JComponent) {
        Insets insets=((JComponent)c).getInsets();
        southPanel.setBorder(BorderFactory.createEmptyBorder(insets.top,insets.left,insets.bottom,insets.right));
      }
      dialog.getContentPane().add(southPanel,BorderLayout.SOUTH);
      return dialog;
    }
    @Override public void approveSelection(){
      if (canExport(this)) {
        super.approveSelection();
      }
    }
  }
;
  chooser.setDialogTitle(NbBundle.getMessage(GraphFileExporterUI.class,"String_Node_Str"));
  chooser.addPropertyChangeListener(JFileChooser.FILE_FILTER_CHANGED_PROPERTY,new PropertyChangeListener(){
    public void propertyChange(    PropertyChangeEvent evt){
      DialogFileFilter fileFilter=(DialogFileFilter)evt.getNewValue();
      selectedExporter=getExporter(fileFilter);
      if (selectedExporter != null && exportController.hasUI(selectedExporter)) {
        optionsButton.setEnabled(true);
      }
 else {
        optionsButton.setEnabled(false);
      }
      if (selectedFile != null) {
        String filePath=selectedFile.getAbsolutePath();
        filePath=filePath.substring(0,filePath.lastIndexOf("String_Node_Str"));
        filePath=filePath.concat(fileFilter.getExtensions().get(0));
        selectedFile=new File(filePath);
        chooser.setSelectedFile(selectedFile);
      }
    }
  }
);
  chooser.addPropertyChangeListener(JFileChooser.SELECTED_FILE_CHANGED_PROPERTY,new PropertyChangeListener(){
    public void propertyChange(    PropertyChangeEvent evt){
      if (evt.getNewValue() != null) {
        selectedFile=(File)evt.getNewValue();
      }
    }
  }
);
  for (  FileExporter graphFileExporter : exportController.getGraphFileExporters()) {
    for (    FileType fileType : graphFileExporter.getFileTypes()) {
      DialogFileFilter dialogFileFilter=new DialogFileFilter(fileType.getName());
      dialogFileFilter.addExtensions(fileType.getExtensions());
      chooser.addChoosableFileFilter(dialogFileFilter);
    }
  }
  chooser.setAcceptAllFileFilterUsed(false);
  String defaultExtention=((DialogFileFilter)chooser.getFileFilter()).getExtensions().get(0);
  selectedFile=new File(chooser.getCurrentDirectory(),"String_Node_Str" + defaultExtention);
  chooser.setSelectedFile(selectedFile);
  int returnFile=chooser.showSaveDialog(null);
  if (returnFile == JFileChooser.APPROVE_OPTION) {
    File file=chooser.getSelectedFile();
    file=FileUtil.normalizeFile(file);
    FileObject fileObject=FileUtil.toFileObject(file);
    NbPreferences.forModule(GraphFileExporterUI.class).put(LAST_PATH,file.getAbsolutePath());
    visibleOnlyGraph=graphSettings.isVisibleOnlyGraph();
    exportController.doExport(selectedExporter,fileObject,visibleOnlyGraph);
  }
}

Fixed version (ground truth):
public void action(){
  final String LAST_PATH="String_Node_Str";
  final String LAST_PATH_DEFAULT="String_Node_Str";
  final ExportController exportController=Lookup.getDefault().lookup(ExportController.class);
  if (exportController == null) {
    return;
  }
  String lastPathDefault=NbPreferences.forModule(GraphFileExporterUI.class).get(LAST_PATH_DEFAULT,null);
  String lastPath=NbPreferences.forModule(GraphFileExporterUI.class).get(LAST_PATH,lastPathDefault);
  FlowLayout layout=new FlowLayout(FlowLayout.RIGHT);
  JPanel optionsPanel=new JPanel(layout);
  final JButton optionsButton=new JButton(NbBundle.getMessage(GraphFileExporterUI.class,"String_Node_Str"));
  optionsPanel.add(optionsButton);
  optionsButton.addActionListener(new ActionListener(){
    public void actionPerformed(    ActionEvent e){
      ExporterUI exporterUI=exportController.getUI(selectedExporter);
      if (exporterUI != null) {
        JPanel panel=exporterUI.getPanel();
        exporterUI.setup(selectedExporter);
        DialogDescriptor dd=new DialogDescriptor(panel,NbBundle.getMessage(GraphFileExporterUI.class,"String_Node_Str",selectedExporter.getName()));
        Object result=DialogDisplayer.getDefault().notify(dd);
        exporterUI.unsetup(result == NotifyDescriptor.OK_OPTION);
      }
    }
  }
);
  final JPanel southPanel=new JPanel(new BorderLayout());
  southPanel.add(optionsPanel,BorderLayout.NORTH);
  GraphFileExporterUIPanel graphSettings=new GraphFileExporterUIPanel();
  graphSettings.setVisibleOnlyGraph(visibleOnlyGraph);
  southPanel.add(graphSettings,BorderLayout.CENTER);
  final JFileChooser chooser=new JFileChooser(lastPath){
    @Override protected JDialog createDialog(    Component parent) throws HeadlessException {
      JDialog dialog=super.createDialog(parent);
      Component c=dialog.getContentPane().getComponent(0);
      if (c != null && c instanceof JComponent) {
        Insets insets=((JComponent)c).getInsets();
        southPanel.setBorder(BorderFactory.createEmptyBorder(insets.top,insets.left,insets.bottom,insets.right));
      }
      dialog.getContentPane().add(southPanel,BorderLayout.SOUTH);
      return dialog;
    }
    @Override public void approveSelection(){
      if (canExport(this)) {
        super.approveSelection();
      }
    }
  }
;
  chooser.setDialogTitle(NbBundle.getMessage(GraphFileExporterUI.class,"String_Node_Str"));
  chooser.addPropertyChangeListener(JFileChooser.FILE_FILTER_CHANGED_PROPERTY,new PropertyChangeListener(){
    public void propertyChange(    PropertyChangeEvent evt){
      DialogFileFilter fileFilter=(DialogFileFilter)evt.getNewValue();
      selectedExporter=getExporter(fileFilter);
      if (selectedExporter != null && exportController.hasUI(selectedExporter)) {
        optionsButton.setEnabled(true);
      }
 else {
        optionsButton.setEnabled(false);
      }
      if (selectedFile != null) {
        String filePath=selectedFile.getAbsolutePath();
        filePath=filePath.substring(0,filePath.lastIndexOf("String_Node_Str"));
        filePath=filePath.concat(fileFilter.getExtensions().get(0));
        selectedFile=new File(filePath);
        chooser.setSelectedFile(selectedFile);
      }
    }
  }
);
  chooser.addPropertyChangeListener(JFileChooser.SELECTED_FILE_CHANGED_PROPERTY,new PropertyChangeListener(){
    public void propertyChange(    PropertyChangeEvent evt){
      if (evt.getNewValue() != null) {
        selectedFile=(File)evt.getNewValue();
      }
    }
  }
);
  DialogFileFilter defaultFilter=null;
  for (  FileExporter graphFileExporter : exportController.getGraphFileExporters()) {
    for (    FileType fileType : graphFileExporter.getFileTypes()) {
      DialogFileFilter dialogFileFilter=new DialogFileFilter(fileType.getName());
      dialogFileFilter.addExtensions(fileType.getExtensions());
      if (defaultFilter == null) {
        defaultFilter=dialogFileFilter;
      }
      chooser.addChoosableFileFilter(dialogFileFilter);
    }
  }
  chooser.setAcceptAllFileFilterUsed(false);
  chooser.setFileFilter(defaultFilter);
  selectedFile=new File(chooser.getCurrentDirectory(),"String_Node_Str" + defaultFilter.getExtensions().get(0));
  chooser.setSelectedFile(selectedFile);
  int returnFile=chooser.showSaveDialog(null);
  if (returnFile == JFileChooser.APPROVE_OPTION) {
    File file=chooser.getSelectedFile();
    file=FileUtil.normalizeFile(file);
    FileObject fileObject=FileUtil.toFileObject(file);
    NbPreferences.forModule(GraphFileExporterUI.class).put(LAST_PATH,file.getAbsolutePath());
    visibleOnlyGraph=graphSettings.isVisibleOnlyGraph();
    exportController.doExport(selectedExporter,fileObject,visibleOnlyGraph);
  }
}