My question is related to TableView from JavaFx. JavaFx recommends using Properties for storing values which are going to be shown in the table ( SimpleSttringProperty, etc. ) like in the example below.
Isn't this an memory overhead for Java ( creating another object for each cell ) ? I am going to use the TableView to show more then 10.000 rows from the database. Isn't there a way to avoid this, and simply work as Swing did earlier ? Can't TableView get only the value to represent ? For all solutions I found an ObservableValue is required for each cell, which may require a lot of memory.
TableColumn<Person,String> firstNameCol = new TableColumn<Person,String>("First Name");
firstNameCol.setCellValueFactory( element -> element.getValue().firstName );
or
firstNameCol.setCellValueFactory( new PropertyValueFactory<Person, String>("firstName"));
public static class Person {
public final SimpleStringProperty firstName;
private final SimpleStringProperty lastName;
private final SimpleStringProperty email;
private Person(String fName, String lName, String email) {
this.firstName = new SimpleStringProperty(fName);
this.lastName = new SimpleStringProperty(lName);
this.email = new SimpleStringProperty(email);
}
Propertyis pretty minimal, isn't it? It's just a simple object wrapping the value, so should only consume a few more bytes than the value itself. Do you have an actual example where you can show this causes a problem? - James_D