0

I'm new to JavaFX, and beginner in Java. Using Scene Builder, I created a table view in my main view FXML controller. I want a secondary window to show up my tableview. I already know how to create this popup window, but I can't figure out how to "send" my TableView to my secondary FXML Controller. I know I may be missing something fundamental here but I don't get what... Thanks for your help.

Flo Fst
  • 17
  • 3

1 Answers1

1

One way is to try extracting the table design to it's own xml and then you can include it in both views using fxml include. That means both controllers for the main window and the popup will need similar code to handle the table.

The fxml will be something like this:

    <VBox fx:controller="com.foo.MainController">
       <fx:include fx:id="table" source="table.fxml"/>
       ...
    </VBox>

For more check out this answer on nesting controllers and this tutorial

Community
  • 1
  • 1
  • Thanks it helps a lot, but actually I don't want the TableView to be displayed in my main window, I just need to manipulate my object created in the primary controller from my secondary controller, is there a way to "pass" it (while loading maybe? Through _initialize_ ?) – Flo Fst May 09 '17 at 14:59
  • 1
    @FloFst For passing data to controllers, see http://stackoverflow.com/questions/14187963/passing-parameters-javafx-fxml/14190310#14190310 – James_D May 09 '17 at 15:24