title: JavaFX tree view showing default selection
body: <p>I am using JavaFX8.</p>
  
  <p>I have a tree view and it contains some objects.</p>
  
  <p>The tree view gets displayed with all the nodes expanded.</p>
  
  <p>I would like to have a default item on the treeview selected when the UI startsup.</p>
  
  <p>I have tried the following but it doesn't work. </p>
  
  <pre><code>rootNode.setExpanded(true);
  popupTree.setShowRoot(false);
  popupTree.setRoot(rootNode);
  popupTree.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
  
  popupTree.requestFocus();
  popupTree.getSelectionModel().select(new TreeItem&lt;FinancialAccount&gt;(selectedAccount));
  popupTree.getFocusModel().focus(popupTree.getSelectionModel().getSelectedIndex());
  </code></pre>
  
  <p>If I replace the code with a static integer value like this</p>
  
  <pre><code>popupTree.requestFocus();
  popupTree.getSelectionModel().select(5);
  popupTree.getFocusModel().focus(5);
  </code></pre>
  
  <p>This selects the 5th item on the tree and its highlighted on the UI.</p>
  
  <p>To determine the index of the object in the tree, I am using the methods in my first snippet, they always return -1</p>
  
  <p>Obviously the select(object) method in the SelectionModel class is not correctly evaluating the passed object. I tried overriding the equals method in my FinancialAccount Object but it doesn't make a difference.</p>
  
  <p>Any thoughts on how to get this working</p>