user2630579
user2630579

Reputation: 75

In javafx, how to change scrollbar arrow color?

i'm customizing scrollbar using css and I can't change the increment/decrement arrows color. In fact, it's simpler to change their form - like this:

.increment-arrow {
    -fx-shape: "M 0 0 L 4 8 L 8 0 Z";
}

But nothing I'm trying to add to that style can change the color of the arrows (the arrows themself, not the background around them). How this could be implemented?

Upvotes: 1

Views: 2266

Answers (1)

José Pereda
José Pereda

Reputation: 45456

If you have a look at how modena styles the ScrollBar control you'll find out that the arrows use these rules:

.scroll-bar > .increment-button > .increment-arrow,
.scroll-bar > .decrement-button > .decrement-arrow {
    -fx-background-color: -fx-mark-highlight-color, derive(-fx-base,-45%);
}

so all you need to do is just override that color with your own:

.scroll-bar > .increment-button > .increment-arrow,
.scroll-bar > .decrement-button > .decrement-arrow {
    -fx-background-color: green;
}

You can find the modena.css file included in the jfxrt.jar or listed in the openJFX repository.

Upvotes: 4

Related Questions