katana
katana

Reputation: 51

JavaFX - How to remove ListView & TableView's bands?

I'm adding JavaFX ListViews & TableViews to my app in their default style.

The odd rows got a white background and even rows got a grey background. I don't like those bands, especially on unpopulated rows.

I tried the following CSS settings on my ListView with fxid:list_PayMethod but doesn't help.

(this page doesn't recognize the fxid as part of the code, so it is not inside the grey box, please note.)

#list_PayMethod {

    .list-cell:odd {
        -fx-padding: 0px;
        -fx-control-background: #F4F4F4;
        -fx-control-inner-background: #F4F4F4;
    }

    .list-cell:even {
        -fx-padding: 0px;
        -fx-control-background: #F4F4F4;
        -fx-control-inner-background: #F4F4F4;
    }

    .list-view:focused .list-cell:focused:odd {
        -fx-padding: 0px;
        -fx-control-background: #F4F4F4;
        -fx-control-inner-background: #F4F4F4;
    }

    .list-view:focused .list-cell:focused:even {
        -fx-padding: 0px;
        -fx-control-background: #F4F4F4;
        -fx-control-inner-background: #F4F4F4;
    }
}

Is there any way to set all to write or all grey?

Thanks!

Upvotes: 1

Views: 503

Answers (1)

Miss Chanandler Bong
Miss Chanandler Bong

Reputation: 4258

Replace -fx-control-background with -fx-background-color and that should be enough.

.list-cell {
    -fx-background-color: #F4F4F4;
}

Upvotes: 1

Related Questions