title: JList that contains the list of Files in a directory
body: <p>I created a <code>JList</code> that contains a list of files that are in a directory.
  Here is the <code>JList</code>.</p>
  
  <pre><code>JList MList;
  String ListData[]
  // Create a new listbox control
  List = new JList(ListData);
  </code></pre>
  
  <p>I also created a method that reads a list of text files in a directory:</p>
  
  <pre><code>     public String ReadDirectory() {
          String path = "C://Documents and Settings/myfileTxt";
  
          String files = null;
          File folder = new File(path);
          File[] listOfFiles = folder.listFiles();
  
          for (int i = 0; i &lt; listOfFiles.length; i++) {
              if (listOfFiles[i].isFile()) {
                  files = listOfFiles[i].getName();
                  if (files.endsWith(".txt") || files.endsWith(".TXT")) {
                      System.out.println(files);
                  }
              }
          }
          return files;
      }
  </code></pre>
  
  <p>The problem is I want the result of this method (the list of text files) in a <code>JList</code>. 
  How can I put the <code>File</code> objects in the <code>JList</code>?</p>