title: In JavaFX treeview, how to set icons for all the items?
body: <p>I have a treeview with folders and sub folders. Leaves of the subfolder are json files. I have set icons for folders as well as leaves. Now, only the root folder is having the image. On expansion, subfolders gets listed with arrow marks but not folder icons. On expanding the arrows, icons get displayed. How to fix this? </p>
  
  <pre><code>  private  Node rootIcon = new ImageView(new Image(Main.class.getResourceAsStream("images/folder2.png")));
    private  Node jsonImage = new ImageView(new Image(Main.class.getResourceAsStream("images/jsonImage1.png")));
  
  public ObservableList&lt;TreeItem&lt;File&gt;&gt; buildChildren(TreeItem&lt;File&gt; treeItem) {
      File f = treeItem.getValue();
      f.getName();
      if(treeItem.getValue().isDirectory()){
      treeItem.setGraphic(rootIcon);
      }else{
          treeItem.setGraphic(jsonImage);
      }
          if (f != null) {
          File[] files = f.listFiles();
          if (files != null) {
              ObservableList&lt;TreeItem&lt;File&gt;&gt; children = FXCollections.observableArrayList();
              ChildTreeItem child2=null;
              ChildFileTreeItem childFiles=null;
              for (File childFile : files) {
                  try {
                      if(childFile.isDirectory()){
                      child2 = new ChildTreeItem(childFile);
                      //child2.setSplitPane(ApplicationContext.getSplitPane());
                      children.add(child2);
                      }else{
                          childFiles=new ChildFileTreeItem(childFile);
                          //childFiles.setSplitPane(ApplicationContext.getSplitPane());
                          childFiles.setGraphic(jsonImage);
                          children.add(childFiles);
                      }
                  } catch (Exception e) {
                      e.printStackTrace();
                  }
  
              }
  
              return children;
          }
      }
  
      return FXCollections.emptyObservableList();
  }
  </code></pre>