Reputation: 1093
I was searching for a solution how to change first and last cell differently then the other cells. I know css for odd/even cells etc but didn't find a solution for change first/last cell. Target: having the first and the last cell background radius while the rest does not. Thanks.
Upvotes: 1
Views: 840
Reputation: 1093
Solution, extend cell-factory while checking index of row:
list.setCellFactory(new Callback<ListView<Object>, ListCell<Object>>() {
...
super.updateItem(object, empty);
if(!empty) {
super.setGraphic(new Label(paramT));
// Styling the first and last cells.
if(getIndex() == 0 || getIndex() == (getListView().getItems().size()-1)) {
this.getStyleClass().add("your-style");
}
...
Upvotes: 4