-1

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:

teres
  • 53
  • 6
  • 3
    I don't think property names can have a space in them. – SedJ601 Jul 26 '22 at 20:08
  • 4
    Don’t use `PropertyValueFactory`. See https://stackoverflow.com/q/72437983/2189127 – James_D Jul 26 '22 at 21:13
  • whatever class/api you intend to use: the very first step is to study its __api doc__ - which would have made this question non-existent ;) Unrelated: stick to java naming convention, please. – kleopatra Jul 27 '22 at 13:26

1 Answers1

0

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

bertilmuth
  • 276
  • 1
  • 11