title: Drawing a sub-table in a separate window from object within object
body: <p>Let's say I have <code>List&lt;String&gt; lstcat</code> which contains the entire list of categories I need in both tables.</p>
  
  <p>I also have <code>ObservableList&lt;ObjectA&gt; lstObject</code> which is defined like this:</p>
  
  <pre><code>public class ObjectA {
      String MPID;
      String Date;
      ObjectB insideObject;
      }
  </code></pre>
  
  <p>with Object B defined as:</p>
  
  <pre><code>public class ObjectB {
      String Symbol;
      int Age;
      }
  </code></pre>
  
  <p>so <code>lstObject = [ObjectA1, ObjectA2, ...]</code></p>
  
  <p>What my goal is is to have a table appear with all of object A's members, and when I click on a row in that table, another table appears with the corresponding Object B's members.</p>
  
  <p>I have the code for the first table:</p>
  
  <pre><code>private TableView init(Stage primaryStage) throws Exception {
      Group root = new Group();
      primaryStage.setScene(new Scene(root));
      TableView&lt;ObjectA&gt; tableView = new Tableview&lt;&gt;;
      List&lt;String&gt; lstCat = ...
      ObservableList&lt;ObjectA&gt; lstObject = ...
  
      for (int i =0; lstCat.get(i).equals("Symbol") == false;i++) {
          TableColumn&lt;ObjectA,String&gt; col = new TableColumn&lt;&gt;(lstCat.get(i));
          col.setCellValueFactory(new PropertyValueFactory&lt;&gt;(lstCat.get(i)));
          tableView.getColumns().add(col);
          }
      tableView.setItems(lstObject);
      return tableView;
  }
  
  
  public void start(stage primaryStage) throws Exception {
      TableView firstTable = init(primaryStage);
      // Here's the code I need help with. Right now I just have a print statement, 
      // I need this to generate a new table with the corresponding objectB.
      firstTable.setOnMouseClicked(new EventHandler&lt;MouseEvent&gt;()
      {
          @Override
          public void handle(MouseEvent t) {
              System.out.println("print when click")
              }
              });
      Scene scene = new Scene(test);
      primarystage.setScene(scene);
      primaryStage.show();
      }
  </code></pre>
  
  <p>The first table appears nicely, no problems at all.</p>
  
  <p>My work so far:</p>
  
  <p>I know to make the columns of the new table it would be:
  This would go inside the <code>handle</code> method.</p>
  
  <pre><code>TableView&lt;ObjectB&gt; innerTable = ....
  for (int i = //element in lstCat where objectB members start; i&lt;lstCat.size();i++) {
      TableColumn&lt;ObjectA,String&gt; col = new TableColumn&lt;&gt;(lstCat.get(i));
          col.setCellValueFactory(new PropertyValueFactory&lt;&gt;(lstCat.get(i)));
          innerTable.getColumns().add(col);
          }
  </code></pre>
  
  <p>However, this doesn't work because <code>lstObject</code> is of type <code>ObjectA</code> but my <code>innerTable</code> is of type <code>ObjectB</code>. So I am getting errors.</p>
  
  <p>What am I missing here?</p>
  
  <p>(And the reason I am doing this all dynamically is because the tables I am actually working with have much more columns than this, so statically is not really an option.</p>
  
  <p>Thank you!</p>
  
  <p>EDIT:</p>
  
  <p>I believe I may have figured it out.</p>
  
  <p>I can interate over <code>lstObject</code> and make a <code>lstObjectB</code> and add each <code>ObjectB</code> from each <code>ObjectA</code> to that <code>ObservableList</code> then just make an <code>innerTable</code> that way.</p>
  
  <p>Unless there is a better way?</p>
  
  <p>Also how would I use the mouseEvent to have a new window appear with the new <code>innertable</code>?</p>
  
  <p>It could also just be a sub-row or something. Not necessarily a new window, just something else that pops up displaying the new information.</p>