I had code from stackoverflow on \"access child controller from parent controller\" as below.
ParentController.java
public class ParentController i
I did as following -
public class childController implements Initializable{
@FXML public Label sessionLabel;
@FXML private AnchorPane child;
@Override
public void initialize(URL location, ResourceBundle resources) {
}
@FXML
private void mClicked (){
System.out.println(child.getParent().lookup("#lebelInParent"));
}
}
child.fxml
<AnchorPane fx:id="child" xmlns:fx="http://javafx.com/fxml" fx:controller="childController">
<children>
<HBox id="hbox_top" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
<Label fx:id="sessionLabel" prefHeight="20.0" text="" onMouseClicked="#mClicked"/>
</HBox>
</children>
</AnchorPane>
explaination - it loads parent.fxml and when I click on sessionLabel, it calls mClicked method of childController and child.getParent().lookup, search for Id and return Node.