JavaFX Controls: ProgressIndicator and ProgressBar
In JavaFX, both the ProgressIndicator and ProgressBar controls are designed to let your users know that some process which takes a long time (such as updating a database or downloading a file) hasn’t stalled, but is indeed chugging along toward completion.
The difference between the two is the way progress is visualized: The ProgressIndicator is a circular control in which more of the circle fills in as progress is made, whereas the ProgressBar is a horizontal bar that fills in from left to right as progress is made.
To create a progress indicator or progress bar, just call the default constructor:
ProgressIndicator pi = new ProgressIndicator(); ProgressBar pb = new ProgressBar();
To set the amount of progress indicated by the progress indicator, you call the setProgress method, passing it a double value between 0.0 and 1.0. For example, to set the progress to 45 percent:
Until you call the setProgress method, the progress indicator is considered to be indeterminate, which means that the user can’t tell how much progress has been made. An indeterminate ProgressIndicator is indicated by a circular pattern of spinning dots; an indeterminate ProgressBar is a bar that sweeps back and forth. After you call the setProgress method, the indicator will change to show the amount of progress that has been made.
This figure shows both indeterminate and determinate examples of a progress indicator and a progress bar.