This week's giveaway is in the Spring forum.
We're giving away four copies of Microservices Testing (Live Project) and have Chris Love & Andres Sacco on-line!
See this thread for details.
Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • 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:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

How to add data to tableview

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've tried generalizing a few examples I've found online with my own code, but I can't seem to get any data to add to the table. The columns add just fine. Some insight on how this works would be helpful. I've already picked my may through the API that relates to tables and I still can't seem to get it to work.

What I want to happen is for the user to click the add button, to select the file(s) and for the data to be added to the table. The only things that get added are the column names.



Part definition



Library Generator

 
Rancher
Posts: 387
30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I didn't look through all of your code, there is a lot of it, next time it is probably best to post an mcve: https://stackoverflow.com/help/mcve

One thing you don't have in your code (unless I missed it) is any code which sets the data into the table view (which is why no data shows).

When you create the table view you can pass it an observable list of items, which is the data it will display:
 https://docs.oracle.com/javase/8/javafx/api/javafx/scene/control/TableView.html#TableView-javafx.collections.ObservableList-

You can also set the items at a later stage rather than in the constructor if you prefer:

Once the parts list is associated with the table as above, adding a new item to the parts list will also add it to the TableView, as the parts list is an ObservableList and the TableView knows this and observes the list for changes:

For more info, read the javadoc in TableView.
 
Menachem Henry
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Alright, Thanks for your clear description, help and patience. I was having trouble understanding the flow of events for adding things to a table, but this finalizes it.
 
reply
    Bookmark Topic Watch Topic
  • New Topic