Search code examples
listviewjavafxstrikethrough

Java- Striking through item in ListView javafx?


I want to strikethrough text in my listview. I tried the following codes but it's not working. Any help is appreciated. Thank you.

.list-cell {
   -fx-text-fill: red;
   -fx-strikethrough: true;
}

Solution

  • ListCell does not have the strikethrough property. You probably want to apply the CSS to the text element inside the cell, roughly:

    .list-cell .text {
        -fx-strikethrough: true;
    }
    

    See also the JavaFX CSS Reference Guide