title: JFileChooser open multiple files in the order they are clicked
body: <p>I have an application that takes multiple files and applies some operation that depends on their order (e.g. merge them one after another).</p>
  
  <p>The user can select files in any order by Ctrl+click, or by Shift+click.</p>
  
  <p>The list files returned by the chooser does not have the same order as the user clicked them. I'd like them to be returned in the same order the user clicked them.</p>
  
  <p>Disclaimer: I'm "the user"</p>
  
  <p>I'm using the <code>JFileChooser</code> class with Java look and feel on Windows 7 64bits, with JDK 7.</p>
  
  <p>Here's a minimal example</p>
  
  <pre><code>package choosertest;
  
  import java.io.File;
  import javax.swing.JFileChooser;
  import javax.swing.JFrame;
  
  public class ChooserTest extends JFrame {
  
      JFileChooser chooser;
  
      public ChooserTest() {
          chooser = new JFileChooser();
          chooser.setMultiSelectionEnabled(true);
  
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          setVisible(true);
  
          testOpen();
      }
  
      public static void main(String[] args) {
          new ChooserTest();
      }
  
      private void testOpen() {
          int choice = chooser.showOpenDialog(this);
  
          if (choice == JFileChooser.APPROVE_OPTION) {
  
              File[] inputFiles = chooser.getSelectedFiles();
              for (File f: inputFiles) {
                  System.out.println(f.getName());
              }
          }
      }
  
  }
  </code></pre>