code: public void save() throws IOException {
          JFileChooser fc = FileChooser.getInstance();
          fc.setFileFilter(FileChooser.SimpleFileFilter.getWritableImageFIlter());
          fc.setAcceptAllFileFilterUsed(false);
          fc.setSelectedFiles(new File[0]);
          int returnVal = fc.showSaveDialog(this);
  
          if (returnVal == JFileChooser.APPROVE_OPTION) {
              File file = fc.getSelectedFile();
              save(file);
          }        
      }
docs: Shows a file chooser and exports the plot to the selected image file.
  @throws IOException if an error occurs during writing.