I try to add CheckBoxTableCell to my TableColumn but the cell just show unchecked box regardless the value is true or false
My Object
public class Room {
private String id,type,category,floor,number;
private Boolean status;
//setter and getter
........
}
How I declare the table
@FXML
private TableView<Room> roomTable;
@FXML
private TableColumn ....
@FXML
private TableColumn<Room,Boolean> statusColumn;
public void initialize(){
....
statusColumn.setCellValueFactory(new PropertyValueFactory<Room, Boolean>("status")); // here
statusColumn.setCellFactory(CheckBoxTableCell.forTableColumn(statusColumn));
....
}
I have solve this problem with making a new variable with BooleanProperty type and change the PropertyValueFactory parameter with the new variable
the problem is I didn't want to use BooleanProperty or Property
because all my model class still use the standard type not the Property
is there a way to do that?
if not maybe i just change all my model class variable to Property variable
To keep the cell in sync with the property, the cell needs to be notified when the property value changes. This is the functionality the JavaFX property classes provide. There are ways to bind to classical Java Bean properties, but they involve a lot more "wiring" and will end up being more complicated than using JavaFX property classes. This question is similar.