title: Creating dynamic JTree from absolute file path
body: <pre><code>private void createNodes(DefaultMutableTreeNode top) {
      List &lt;String&gt; files = new ArrayList&lt;String&gt;();      
      //getFileNames() returns array list of file name with complete path
      //eg C:/lanceTest1/directory1/sample.txt
      files = getFileNames();     
      DefaultMutableTreeNode node = null;
      for (String fileName : files) {
          node = new DefaultMutableTreeNode(fileName);
          top.add(node);               
      }
  }
  </code></pre>
  
  <p>Above function creates below window.</p>
  
  <p><img src="https://i.stack.imgur.com/wT4wL.jpg" alt="enter image description here"></p>
  
  <p>I want to show it as below (for eg for the first file),</p>
  
  <pre><code>The Java Series
   |__C
    |__lanceTest
     |__directory1
      |__PDxxxx_Splunk_Solution_Architecture_Doc_v0.9.doc
  </code></pre>
  
  <p>I am new to swing, awt. Can someone help?</p>