I want to be as short as possible without omitting useful information. I have the following class:
public class Address{
StringProperty city = new SimpleStringProperty();
StringProperty street = new SimpleStringProperty();
...
}
I have another class client that has an address member
public class Client {
StringProperty name = new SimpleStringProperty();
StringProperty id = new SimpleStringProperty();
ObjectProperty<Address> address = new SimpleObjectProperty<>();
...
}
and a JavaFX interface with a controller that contains the TableView object, which should display in 3 columns the members of the Client class and the city member of the Address class for this object. My definition of TableView and TableColumn is the following code
public class SettingsController {
TableColumn<Client, String> clientNameCol;
TableColumn<Client, String> clientEmailCol;
TableColumn<Client, String> clientCityCol;
private TableView<Client> clientSettingsTableView;
...
...
clientNameCol = new TableColumn<>("Name");
clientNameCol.setCellValueFactory(new PropertyValueFactory<Client, String>("name"));
clientEmailCol = new TableColumn<>("email");
clientEmailCol.setCellValueFactory(new PropertyValueFactory<Client, String>("email"));
clientCityCol = new TableColumn<>("City");
clientCityCol.setCellValueFactory(new PropertyValueFactory<Client, String>("city"));
clientSettingsTableView.setItems(clientData);
clientSettingsTableView.getColumns().clear();
clientSettingsTableView.getColumns().addAll(clientNameCol, clientEmailCol, clientCityCol);
and, of course, there is a CustomerData ObservableList that contains an array of the Client object. Everything works fine, except for the column, which should display the city for each client. How to determine the city column (contained in the Address element) of the Client object?
source
share