JavaFX 2: Get TableCell Row Index

后端 未结 2 759
梦毁少年i
梦毁少年i 2021-02-15 21:20

I have a Table with checkboxes. I want to change the selection of the checkbox in the first column when I click on the checkbox in the third or fourth column. I want to be able

2条回答
  •  自闭症患者
    2021-02-15 22:18

    Almost There

    Before calling commitEdit, it is necessary to call getTableView().edit(getTableRow().getIndex(), param). This puts the cell into "editing mode". Since there is no startEdit method, there is very little involved in entering edit mode, but it is still required.

    After that, as described here: http://download.oracle.com/javafx/2.0/ui_controls/table-view.htm

    It is necessary to call

    firstCol.setOnEditCommit(new EventHandler>() {
        @Override
        public void handle(EditEvent event) {
            String newValue = event.getNewValue();
            ContactOptions data = (ContactOptions) event.getTableView().getItems().get(event.getTablePosition().getRow());
            data.one.set(newValue)
            if(newValue.equals("No")) {
                data.three.set("No");
                data.four.set("No");
            }
        }
    }
    

    Now all I need to know is how to update the table's display once the data is updated.

提交回复
热议问题