首页 > 解决方案 > JavaFX ListView Cell 多个图形

问题描述

是否有向 JavaFX ListView 单元格添加多个图形?

lstTest.setCellFactory(param -> {
            ListCell<Test> cell = new ListCell<>();
            cell.selectedProperty().addListener((observable, oldValue, newValue) -> {
                handleCellDisplaying(cell);
            });
            cell.itemProperty().addListener((observable, oldValue, newValue) -> handleCellDisplaying(cell));
            return cell;
        });

和句柄CellDisplaying:

 private void handleCellDisplaying(ListCell<Test> cell) {
        FontIcon lockIcon = new FontIcon(FontAwesome.LOCK);
        cell.setGraphic(lockIcon);
        cell.setGraphic(bellIcon); //Multiple graphics here for the same cell
        cell.setGraphic(etc.etc.);
        }
    }

标签: listviewjavafx

解决方案


推荐阅读