This week's book giveaways are in the Scala and Android forums.
We're giving away four copies each of Machine Learning Systems: Designs that scale and Xamarin in Action: Creating native cross-platform mobile apps and have the authors on-line!
See this thread and this one for details.
Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Refresh TableView (in fxml A controller) on button event in fxml B controller  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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:


 
Sheriff
Posts: 4866
136
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
Paper jam tastes about as you would expect. Try some on this tiny ad:
free 1 hour java lesson
https://coderanch.com/t/695988/free-hour-java-lesson
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!