Forums Register Login
Refresh TableView (in fxml A controller) on button event in fxml B controller

I'm trying to make a table, which would refresh and display all new values whenever a new value is added to it. More specifically, I need to have the TableView(in fxml A controller) refresh on certain button event in fxml B controller. So far, when the button is clicked, the object is successfully created and stored in an array list. But the table does not display this new value right after. Only after I restart the app I can see that the new value has been added to the table. Been looking for a way to somehow work this out, but with no luck. It's probably worth to mention that I've created the GUI panels in SceneBuilder and then added the fxml files to the java project.

Any help is much appreciated! Thanks

Here is the main controller(fxml A) code:

And here is the secondary controller (fxml B) code:

Member constructor:

Main program:

I may be getting old, but I don't see where you are adding a new member to tableViewB.

Regardless, try this right after you add the member: This requires at least Java 8u60.

Java Docs wrote:Calling refresh() forces the TableView control to recreate and repopulate the cells necessary to populate the visual bounds of the control. In other words, this forces the TableView to update what it is showing to the user. This is useful in cases where the underlying data source has changed in a way that is not observed by the TableView itself.Since:JavaFX 8u60

Hang a left on main. Then read this tiny ad:
Thread Boost - a very different sort of advertising

This thread has been viewed 398 times.

All times above are in ranch (not your local) time.
The current ranch time is
Apr 22, 2018 01:05:55.