I am trying to add custom css styling to the JavaFX ProgressBar component but I couldn't find any information on the topic. I am looking for the css class names and the css commands that are required to:
- set the color of the progress bar itself
- set the background color of the progress bar (not the same as setting the background color)
- add a custom text node on top of the progress bar (to show the different states)
I have marked this answer as community wiki.
If you have ideas for JavaFX ProgressBar styling outside of the original initial styling queries, please edit this post to add your styling ideas (or to link to them).
Answered in:
The answer demonstrates
JavaFX 7 (caspian) on a Windows PC:
JavaFX 8 (modena) on a Mac:
Sometimes people like barbershop pole style gradients, like the bootstrap striped style:
Define an appropriate css style for the progress bar's "track":
Answered in:
Answered in:
Sample CSS:
José Pereda gives a nice comprehensive solution for narrow progress bars in his answer to:
The place to look is in the default JavaFX style sheet.
The ProgressBar style definitions for caspian (Java 7) are:
The progress bar style definitions for modena (Java 8) are:
The JavaFX CSS reference guide contains general information on the use of CSS in JavaFX (which differs somewhat from the use of CSS in HTML).
css file:
assign this class to the progressbar