Last active
July 10, 2023 17:23
-
-
Save MainasuK/e5f18fac78ee8cdf552f25c757b483e7 to your computer and use it in GitHub Desktop.
Add checkbox cell to tableView - JavaFX 8 with lambda
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TableView<T> tableView; | |
TableColumn<T, Boolean> booleanColumn; | |
private void setupTableView() { | |
tableView.setEditable(true); | |
} | |
private void setupTableViewColumn() { | |
booleanColumn.setCellFactory(column -> new CheckBoxTableCell<>()); | |
booleanColumn.setCellValueFactory(cellData -> { | |
T cellValue = cellData.getValue(); | |
BooleanProperty property = cellValue.choosedProperty(); | |
// Add listener to handler change | |
property.addListener((observable, oldValue, newValue) -> cellValue.setChoosed(newValue)); | |
return property; | |
}); | |
} |
I already figured this out.
Thanks for this gist!
Thank you so much!!! Especially for the details on the setCellValueFactory!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to convert Boolean to BooleanProperty ?