title: How to select a image from a JFrame and then upload it to imgur?
body: <p>I have done some browsing on the internet and have found this code showing how to display multiple photos in a JFrame as seen below. What I want to be able to do is select a photo and be able to upload it to imgur through clicking a button. I know how to upload files to imgur through java but I don't know how to select one image. Anyone Have a Solution?</p>
  
  <pre><code>import java.awt.*;
  import java.awt.image.BufferedImage;
  import javax.swing.*;
  
  import java.io.File;
  import java.io.IOException;
  import javax.imageio.ImageIO;
  
  public class ListView {
  
  public static void main(String[] args) throws IOException {
      String path = "C:/Users/Photos";
      JFrame frame=new JFrame();
      frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  
      File folder = new File(path);
      File[] listOfFiles = folder.listFiles();
      DefaultListModel listModel = new DefaultListModel();
      int count = 0;
      for (int i = 0; i &lt; listOfFiles.length; i++)
      {
          System.out.println("check path"+listOfFiles[i]);
          String name = listOfFiles[i].toString();
          // load only JPEGs
          if ( name.endsWith("png") ) {
              ImageIcon ii = new ImageIcon(ImageIO.read(listOfFiles[i]));
              listModel.add(count++, ii);
          }
      }
      JList lsm=new JList(listModel);
      lsm.setVisibleRowCount(1);
  
      frame.add(new JScrollPane(lsm));
  
      frame.pack();
      frame.setVisible(true);
  }
  }
  </code></pre>