简体   繁体   中英

JavaFX change the blue color of the TableView selection row bar

Everything I found searching for an hour does not work in my TableView with javaFX8, the selection row bar still is always blue.

Tried all of this :

Javafx ListView selection bar text color when using CellFactory

How do i change the color of the blue TableView selection row bar?

tableView.setStyle("...");?

As you can see in the screenshot I have different text styles set in the cellFactory of some columns and it's hard to read with this dark-blue.

.table-row-cell:selected {

    -fx-background-color: #EFEFEF;
    -fx-table-cell-border-color: transparent;

}

To change the text color i had to add the following:

.table-row-cell:selected .text {

    -fx-fill: black ;

}

You can overwrite the .table-row-cell CSS style class:

.table-row-cell:selected {
    -fx-background-color: #005797;
    -fx-background-insets: 0;
    -fx-background-radius: 1;
}

Put this code into a CSS file and then add the file to the list of CSS stylesheets of the TableView .

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