title: Screenshot of gui, choose where to save question
body: <p>I have a program that takes a screenshot of my gui. It automatically saves the .gif file to the eclipse project directory. What I would like is to have it asking a user where to save the image.  Basically so the user can browse the file directory and choose the directory.
  Here's the code I have:</p>
  
  <pre><code>public void actionPerformed(ActionEvent event) {
  try{
         String fileName = JOptionPane.showInputDialog(null, "Save file", 
  null, 1);
  
         if (!fileName.toLowerCase().endsWith(".gif")){
           JOptionPane.showMessageDialog(null, "Error: file name must end with \".gif\".",
             null, 1);
         }
         else{             
           BufferedImage image = new BufferedImage(panel2.getSize().width, 
             panel2.getSize().height, BufferedImage.TYPE_INT_RGB);
           panel2.paint(image.createGraphics());
           ImageIO.write(image, "gif", new File(fileName));
           JOptionPane.showMessageDialog(null, "Screen captured successfully.",
  null, 1);
         }
  }
  catch(Exception e){}
  </code></pre>