JavaFX ScrollPane styling

2020-07-10 05:57发布

I'm trying to create a black and white ScrollPane in JavaFX. I already created a CSS file, wich works pretty fine. Except for this little square:

enter image description here

Whatever I try, I'm not able to turn it black. Here is my CSS file:

.scroll-pane {
    -fx-background-color: black;
}

.scroll-bar:horizontal, .scroll-bar:vertical{
    -fx-background-color:transparent;
}

.increment-button, .decrement-button {
    -fx-background-color: transparent;
    -fx-border-color: transparent;
}

.scroll-bar:horizontal .track,
.scroll-bar:vertical .track{
    -fx-background-color: transparent;
    -fx-border-color: transparent;
    -fx-background-radius: 0em;
}

.scroll-bar:horizontal .thumb,
.scroll-bar:vertical .thumb {
    -fx-background-color: white;
    -fx-background-radius: 5em;
}

Is there a way to change the colour of this square? Thank you in advance!

标签: java css javafx
2条回答
够拽才男人
2楼-- · 2020-07-10 06:24

Simply add the following selector using the needed color:

.scroll-pane > .corner {
    -fx-background-color: black;
}
查看更多
▲ chillily
3楼-- · 2020-07-10 06:40

Use "corner" class.

.scroll-pane > .corner {
      -fx-background-color: black;
}
查看更多
登录 后发表回答