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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s