反正有没有向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;
});
和handleCellDisplaying:
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.);
}
}