I have a small question. I have a Menu.FXML which has a Controller (MenuController). Inside the Menu.FXML I Include another .FXMl (Inner.FXML) and it includes a Label. The Inner.FXML has a MouseClick event handler, so when I Click the Inner.FXML it does something, I want my Inner.FXML mouse listener to change the text which is inside the Menu.FXML. How can I do this? Thank you very much.
[CODE]
public class Main extends Application{
@Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("Menu.fxml"));
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
}
}
InnerController:
public class InnerController implements Initializable {
public void buttonClick(ActionEvent event){
System.out.println("change label!");
}
@Override
public void initialize(URL url, ResourceBundle rb) {
}
}
Menu FXML:
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="nestedcontroller.MenuController">
<children>
<Label text="Label" />
<fx:include source="Inner.fxml" />
</children>
</VBox>
InnerFXML.
<Pane fx:id="pane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" style="-fx-background-color: green;" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="nestedcontroller.InnerController">
<children>
<Button layoutX="271.0" layoutY="187.0" mnemonicParsing="false" onAction="#buttonClick" text="Button" />
</children>
</Pane>