Coloring JavaFX progress bar in fxml.

In case if you want to change color of progress bar in JavaFx, but don’t want to do it by css or by java code, there is a possibility to change it by adding ColorAdjust affect to it.

For green progressbar:

<ProgressBar progress="0.0">
    <effect>
        <ColorAdjust hue="-0.50"/>
    </effect>
</ProgressBar>

For red progressbar:

<ProgressBar progress="0.0">
    <effect>
        <ColorAdjust hue="0.80"/>
    </effect>
</ProgressBar>

Any color can be achieved by changing hue attribute.

Advertisements