javajavafxscrollbar

How to change or remove JavaFX ScrollPane scrollbar background color


Problem setting the background of the scrollbar to white, making it seamless to the scrollpane, if better, the background could be transparent so any color would work
enter image description here

Solution I tried:

nothing changed

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

this kinda works and resulted to the image below:

.track-background {
    -fx-background-color: WHITE;
}

enter image description here

In the first image, you can see the light gray surrounding (which I'm trying to set to transparent) the thumb, in the second image, it has been set to white using the track-background class.

to reproduce this: use an anchor pane for the scrollpane and set its background color to white, and also set the thumb to other color instead of the default now you can see the light gray background of the track

What I want to achieve is to make the background seamless.


Solution

  • By setting the scrollpane background color to transparent, it is now seamless like this:

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

    enter image description here