Issue
I want to create a table view in Javafx.
UploaderColumn.setCellValueFactory(new PropertyValueFactory<User, String>("Uploader Name"));
For what should be the String parameter where I added "Uploader Name"
used for? In my case I added the text of the column from my fxml file. It seems to be wrong since I get the following error:
WARNING: Can not retrieve property 'Uploader Name' in PropertyValueFactory:
Solution
You need to specify a JavaFX property name in the quotes, instead of "Uploader Name"
.
So say you change your line to read:
UploaderColumn.setCellValueFactory(new PropertyValueFactory<User, String>("uploaderName"));
Then, in your User
class, you'd need a property method called uploaderNameProperty()
.
If no such method is defined, the factory will try to use the bean methods getUploaderName()
and setUploaderName()
.
This is described in length here: https://docs.oracle.com/javafx/2/ui_controls/table-view.htm#CJAGAAEE
Answered By - bertilmuth
Answer Checked By - David Marino (JavaFixing Volunteer)