Marcel
Marcel

Reputation: 1594

Having problems with changing the style of the JavaFX CustomColorDialog per CSS

This is my CustomColorDialog as it is now:

Picture of a CustomColorDialog

As you can see there is a white field, I have already tried to change the color of that field it doesn't even work with:

.region
{
    -fx-background-color:red;
}

How do I know it is a region? I have used ScenicView to see the dialogs structure, it even tells me the styleclasses, the regions style class is "customcolor-controls-background". I also tried it with the styleclass, but it didn't work, why would it work though if .region didn't even work?

Upvotes: 0

Views: 108

Answers (1)

José Pereda
José Pereda

Reputation: 45456

If you have a look at the modena.css file (bundled within the jfxrt.jar), you'll find out about all the styling applied to the CustomColorDialog control.

As for the white region, you'll find this:

.custom-color-dialog .controls-pane .customcolor-controls-background {
    -fx-background-color: -fx-text-box-border, -fx-control-inner-background;
    -fx-background-insets: 
        0.8333333em 0 0.4166667em 0,
        1em 0.166667em 0.5833333em 0.166667em;
    -fx-background-radius: 0.3333333em, 0.166667em;
}

so all you have to do is override that rule on your css file:

.custom-color-dialog .controls-pane .customcolor-controls-background {
    -fx-background-color: red;
}

custom color

Upvotes: 1

Related Questions