Refresh TableView (in fxml A controller) on button event in fxml B controller
Post by:Giedrius Stasiulis
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:
Post by:Knute Snortum
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
It will give me the powers of the gods. Not bad for a tiny ad: