There is an Addlist controller. It is called from the main window and adds a new Tab to the TabPane controller of another class: ManageLists . How to understand when to transfer the tab itself to another controller and how to do it?

Addlist:

 btnCreateList.setOnAction(t -> { if (!tfdListName.getText().isEmpty()) { listName = tfdListName.getText(); Tab tab = new Tab(); tab.setText(listName); /* Как передать tab */ } else { alertStart(); } }); 

ManageLists:

 @FXML TabPane tabPane; @Override public void initialize(URL location, ResourceBundle resources) { /* Как услышать изменение в Addlist и словить tab, передав его в tabPane */ } 
  • You can forward a callback from the ManageLists class to the Addlist class and call it when the corresponding event is caught. - Shockoway
  • I think it can be organized through the Observer. For example, like here - Nick

0