Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/345.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用JavaFX从选定TableRow中的TableCell中删除所选内容_Java_Javafx_Tableview_Selection_Tablecell - Fatal编程技术网

如何使用JavaFX从选定TableRow中的TableCell中删除所选内容

如何使用JavaFX从选定TableRow中的TableCell中删除所选内容,java,javafx,tableview,selection,tablecell,Java,Javafx,Tableview,Selection,Tablecell,我有一个带有一些列的TableView。一列包含自定义TableCell节点。当选定行时,我想从该列单元格中删除选择突出显示 以下是我想要的示例图像: 如何执行此操作?使用自定义单元工厂向单元添加样式类: firstNameCol.setCellFactory(col -> { TableCell<Person, String> cell = new TableCell<Person, String>() { @Ov

我有一个带有一些列的TableView。一列包含自定义TableCell节点。当选定行时,我想从该列单元格中删除选择突出显示

以下是我想要的示例图像:


如何执行此操作?

使用自定义单元工厂向单元添加样式类:

    firstNameCol.setCellFactory(col -> {
        TableCell<Person, String> cell = new TableCell<Person, String>() {
            @Override
            public void updateItem(String name, boolean empty) {
                super.updateItem(name, empty);
                if (empty) {
                    setText("");
                } else {
                    setText(name);
                }
            }
        };
        cell.getStyleClass().add("no-select-cell");
        return cell ;
    });
.table-row-cell:selected .no-select-cell {

    -fx-background: -fx-control-inner-background;
    -fx-background-color: -fx-background;
    -fx-text-fill: -fx-text-background-color;
}

.table-row-cell:odd:selected .no-select-cell {
    -fx-background: -fx-control-inner-background-alt ;
}