JavaFX - accessing a dyinamically created tab's controller
<p>I have a stage that has a <code>TabPane tabPane</code> inside it, with one "main" tab and a <code>HashMap&lt;Connection,Tab&gt; connectionTabs</code> of other tabs (<code>Connection</code> is a custom class).</p>

<p>I implement those tabs dynamically.</p>

<pre><code>@Override
public void connectionCreatedEvent(Connection connection) {
    try {
        Tab tab = new Tab();
        //...
        tab.setContent(FXMLLoader.load(getClass().getResource("../fxml/connectionTab.fxml")));
        Platform.runLater(() -&gt; {
            tabPane.getTabs().add(tab);
            tabPane.getSelectionModel().select(tab);
        });
        connectionTabs.put(connection, tab);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
</code></pre>

<p>Now, in the <code>connectionTab.fxml</code> I declare a controller (<code>ConnectionTabController</code>).</p>

<p>How can I access this tabs controller from this class? Or do I have to it another way?</p>

<p>I'm stuck at:</p>

<pre><code>@Override
public void connectionLogEvent(Connection connection, String msg) {
    System.out.println("-t-connection log : " + connection + " : " + msg);
    for(Object o : connectionTabs.entrySet()) {
        Map.Entry ct = (Map.Entry)o;
        if(ct.getKey() == connection)
            /* ???(Tab)ct.getKey().getController();??? */
    }
}
</code></pre>

<p>It's only logical to me that it's somewhere within the <code>Content</code> (since I'm setting it up earlier), but I still can't find out how to reach it, or if it's even possible.</p>

<p>Any sort of help is more than welcome!</p>