title: How to generate FileTree in JavaFX?
body: <p>I am newbie in Java and JavaFX and I am working on a GUI application which use SplitPane. In one pane i am trying to display filetree and in other i have successfully added TabPane.
  Using filetree users will be open the files in the form of tabs.</p>
  
  <p>I am using this code to generate the file tree.</p>
  
  <pre><code>public class FilesTree1 implements Runnable {
  
  static CustomTree filetree = new CustomTree();
  
  public static TreeView treeview;
  
  //File f = new File("workspace");
  int timeout = 0;
  
  public FilesTree1() {
  
      //  this.getTree();
  }
  
  private TreeView buildFileSystemBrowser() {
      TreeItem root = createNode(new File("workspace"));
      return new TreeView(root);
  }
  
  
  private TreeItem createNode(final File f) {
      TreeItem treeItem = null;
      if (f.isDirectory() &amp;&amp; f.listFiles() == null) {
          return treeItem = new TreeItem("Empty");
  
      }
      File[] tempfilelist = f.listFiles();
  
      for (int i = 0; i &lt; tempfilelist.length; i++) {
          if (tempfilelist[i].isDirectory()) {
              System.out.println("- " + tempfilelist[i]);
              treeItem = new TreeItem(createNode(tempfilelist[i]));
          } else {
              treeItem = new TreeItem((tempfilelist[i].getAbsolutePath()));
              System.out.println("- " + tempfilelist[i]);
  
          }
  
      }
      return treeItem;
  }
  
  @Override
  public void run() {
      while (true) {
          try {
              //        filetree.setSimpleRoot(f.getName());
  
              treeview = this.buildFileSystemBrowser();
              treeview.getRoot().setExpanded(true);
              Thread.sleep(100000);
          } catch (InterruptedException ex) {
          }
      }
  }
  }
  </code></pre>
  
  <p>In main class i am calling this function to add tree in the Pane. </p>
  
  <pre><code>static Tab tab41 = new Tab("Files");
  
  public void synchroniseUi() {
     Platform.runLater(new Runnable() {
          @Override
          public void run() {
              tab41.setContent(FilesTree1.treeview);
          }
      });
   }
  </code></pre>
  
  <p>But the problem is that tree is not appearing in the Pane.</p>
  
  <p>Edit: tab41 is a Tab in SplitPane :)</p>