code: public void save() {
  		int resp = saveChooser.showSaveDialog(this);
  		if (resp == JFileChooser.APPROVE_OPTION) {
  			File file = saveChooser.getSelectedFile();
  			String type = null;
  			if (file.getName().endsWith(".png")) {
  				type = "PNG";
  			}
  			if (file.getName().endsWith(".gif")) {
  				type = "GIF";
  			}
  			if (file.getName().endsWith(".jpg")) {
  				type = "JPG";
  			}
  			if (type == null) {
  				file = new File(file.getAbsolutePath()+".png");
  				type = "PNG";
  			}
  			
  			try {
  				ImageIO.write(imagePanel.getImage(), type, file);
  			} catch (Exception e) {
  				e.printStackTrace();
  				JOptionPane.showMessageDialog(this, "Unable to save file "+file.getName());
  			}
  		}
  	}
docs: Save the current image