code: private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveButtonActionPerformed
  		final File dir = lastSaveDirectory();
  		final JFileChooser chooser = dir != null
  			? new JFileChooser(dir)
  			: new JFileChooser();
  		chooser.setDialogTitle("Save Polygon Image");
  		chooser.setDialogType(JFileChooser.SAVE_DIALOG);
  		chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
  		chooser.setMultiSelectionEnabled(false);
  		chooser.addChoosableFileFilter(new FileNameExtensionFilter(
  			"Images (*.png)",
  			ImageIO.getReaderFileSuffixes()
  		));
  
  		final int returnVal = chooser.showSaveDialog(this);
  		if (returnVal == JFileChooser.APPROVE_OPTION) {
  			final String name = chooser.getSelectedFile().getAbsolutePath();
  			final File imageFile = name.toLowerCase().endsWith(".png")
  				? new File(name)
  				: new File(name + ".png");
  
  			try {
  				final Dimension dim = _polygonPanel.getDimension();
  				final PolygonChromosome ch = _polygonPanel.getChromosome();
  				writeImage(imageFile, ch, dim.width, dim.height);
  
  				if (imageFile.getParentFile() != null) {
  					lastSaveDirectory(imageFile.getParentFile());
  				}
  			} catch (Exception e) {
  				JOptionPane.showMessageDialog(
  					rootPane,
  					format("Error while saving image '%s'.", imageFile),
  					e.toString(),
  					JOptionPane.ERROR_MESSAGE
  				);
  			}
  		}
      }
docs: GEN-LAST:event_pauseButtonActionPerformed