I have a root layout with short tabs. From my main application, I open the root layout. There I included several FXML with their own controllers. I am trying to transfer the main controller to one of the Tabes controllers.
The problem I ran into, everything works as expected, but I get a null exception when I try to click the action button from a new tab.
RootLayout FXML
<fx:indlue fx:id="myNewTabAnchorPane" source="NewTabFXML.fxml"/>
RootLayout Controller
@FXML NewTabController newTabController; mainTabPane.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Tab>(){ @override public void change(ObservableValue<? extends Tab> observable, Tab oldValue, Tab newValue){ if(newValue == myTab){ newTabController.setMyRootController(this); }
NewTabController
public void setMyRootController(RootController rootController){ this.rootController = rootController; System.out.println(rootController.getID);
However, if I initiate this action, I get empty from the same controller
@FXML public void createAction(ActionEvent event) throws IOException{ System.out.println(rootController.getID);
What am I missing?
javafx
Moe
source share