For a given controller is there anyway built-in way to access the node that controller is "attached" to without having to give it a FXML ID and specific annotation? I can't find anything relevant to this in the official documentation or searching online.
For example, how do I access the HBox from org.example.FooController
<HBox xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.example.FooController">
<children>
<Button mnemonicParsing="false" text="Button" />
</children>
</HBox>
For now I've just been giving the node a FXML ID of "root" and then using the following in my controller, but it feels like I'm missing a trick...
@FXML
private Node root
Consensus appears to be there is no magic way to do this if your controller is nested or not involved in the loading process.
I've been sticking to the convention of fx:id of "root", and matching @FXML
@FXML
private Node root
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With