How to add CheckBox's to a TableView in JavaFX

前端 未结 13 515
日久生厌
日久生厌 2020-11-30 00:32

In my Java Desktop Application I have a TableView in which I want to have a column with CheckBoxes.

I did find where this has been done http://www.jonathangiles.net/

13条回答
  •  迷失自我
    2020-11-30 01:11

    Inspired from the previous answers, this is the shortest possible version, I think.

    checkBoxColumn.setCellValueFactory(c -> {
        c.getValue().booleanProperty().addListener((ch, o, n) -> {
        // do something
        });
        return c.getValue().booleanProperty();
    });
    checkBoxColumn.setCellFactory(CheckBoxTableCell.forTableColumn(checkBoxColumn));
    

提交回复
热议问题