title: Creating objects depending on an Array
body: <p>I've got an Array holding the amount of directories located in an another directory. However my problem is I have to create a <code>JPanel</code> for each folder.</p>
  
  <p>For example:</p>
  
  <pre><code>File folder = new File("...");
  File[] listOfFiles = folder.listFiles(); &lt;- this contains the folders ({"folder1","folder2","folder3",...}).
  </code></pre>
  
  <p>Now I don't know how to fix this.</p>
  
  <p>Some code I have written:</p>
  
  <pre><code>SystemAPI sapi = new SystemAPI(); &lt;- custom written API  
  File folder = new File(sapi.getHomeDir+"\\Documents\\*programname*\\default");  
  File[] listOfFiles = folder.listFiles();
  
      try{
          for (int i = 0; i &lt; listOfFiles.length; i++) {
              if (listOfFiles[i].isFile()) {
                  System.out.println(listOfFiles[i].getName());
              } else if (listOfFiles[i].isDirectory()) {
                  System.out.println(listOfFiles[i].getName());
              }
          }   
      }catch(Exception a){
          JOptionPane.showMessageDialog(null, "Error Occurred", "Error Dialog", JOptionPane.ERROR_MESSAGE);
      }
  </code></pre>