• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

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

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 7126
185
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic