简体   繁体   中英

How to change background color of unselected JavaFX ListCell

So I use a JFX ListView to display all the connected friends. I've changed the background colors of the cells. But on border color i cant find. You can easily see it, if you control+click an already selected row, it deselects it and then you can see the two blue border colors. How do I change this so it fits with the rest of the background???

This is the css that changes the colors.

.list-cell {
    -fx-border-width: 2 0 2 0;
    -fx-border-color:#37474f;
}
.list-cell:even:hover {
    -fx-border-color:linear-gradient(to left, #DF1721, #cd005f) ;
}
.list-cell:odd:hover {
    -fx-border-color:linear-gradient(to left, #DF1721, #cd005f) ;
}
.list-cell:even:pressed {
    -fx-fill: linear-gradient(to left, #9c1017, #8f0042);
}
.list-cell:odd:pressed {
    -fx-fill: linear-gradient(to left, #9c1017, #8f0042);
}
.list-cell:hover:empty {
    -fx-border-color:#37474f;
}

.list-cell:hover:selected {
    -fx-border-color:#ff4d4d;
}
.list-cell:selected {
    -fx-background-color: #4b5960;
    -fx-border-color:#ff4d4d;
}

So here you can see an unselected ListView

Its the -fx-background-insets that causing the blue lines when focused. Include the below code to fix it.

.list-cell:focused {
    -fx-background-insets:0px;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM