vendredi 7 septembre 2018

Javafx validate CheckBoxTableCell when check a checkbox

I follow this example to use CheckBoxTableCell in TableView:

JavaFX: CheckBoxTableCell get ActionEvent when user check a checkBox

I have table in my project like this:

TableView with three TableColums: icon/name, primary and secondary headers I tried this code to validate (in the same row) if primary checkbox or secondary checkbox is selected, the other one unselect. But code doesnt work:

primaryTableColumn.setCellFactory(CheckBoxTableCell.forTableColumn(i -> {
    Diet diet = diets.get(i);
    if (diet.isPrimary()) {
        diet.setSecondary(false);
    }
    return diet.primaryProperty();
}));

secondaryTableColumn.setCellFactory(CheckBoxTableCell.forTableColumn(i -> {
    Diet diet = diets.get(i);
    if (diet.isSecondary()) {
        diet.setPrimary(false);
    }
    return diet.secondaryProperty();
}));

How can i code in order to uncheck one checkbox if other one in same row is checked (preferably using bindings)? thanks and sorry for my english




Aucun commentaire:

Enregistrer un commentaire