How to delete row from table column javafx

后端 未结 2 1709
醉话见心
醉话见心 2021-02-10 15:37

These are my table columns Course and Description. If one clicks on a row (the row becomes \'active\'/highlighted), and they

2条回答
  •  不思量自难忘°
    2021-02-10 15:49

    Just remove the selected item from the table view's items list. If you have

    TableView table = new TableView<>();
    

    then you do

    deleteButton.setOnAction(e -> {
        MyDataType selectedItem = table.getSelectionModel().getSelectedItem();
        table.getItems().remove(selectedItem);
    });
    

提交回复
热议问题