PropertyValueFactory can be used as cellValueFactory in a TableColumn. It uses reflection to access methods that match a certain pattern to retrieve the data from a TableView item:
Example
TableColumn<Person, String> nameColumn = ...
PropertyValueFactory<Person, String> valueFactory = new PropertyValueFactory<>("name");
nameColumn.setCellValueFactory(valueFactory);
The name of the method that is used to get the data depends on the constructor paramerter for PropertyValueFactory.
ObservableValue containing the data. Changes can be observed. They need to match the pattern <constructor parameter>Property and take no parameters.String in the above example). The method name needs to match the pattern get<Constructor parameter>. Note that here <Constructor parameter> begins with a uppercase letter. This method shouldn't take parameters.Sample names of methods
| constructor parameter (without quotes) | name of property method | name of getter method |
|---|---|---|
| foo | fooProperty | getFoo |
| fooBar | fooBarProperty | getFooBar |
| XYZ | XYZProperty | getXYZ |
| listIndex | listIndexProperty | getListIndex |
| aValue | aValueProperty | getAValue |