JavaFX Progress Indicator Tutorial

The JavaFX Progress Indicator is a UI control which is used to visualize the progress of an operation in the form of a dynamically changing pie chart.

Constructors :

  • ProgressIndicator()Creates a new indeterminate ProgressIndicator.
  • ProgressIndicator(double progress)Creates a new ProgressIndicator with the given progress value.

Creating Progress Indicator :

ProgressIndicator spi = new ProgressIndicator();

And to set a progress value we use method setProgress().

Example using Progress Indicator:

package javafxtuts;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.control.Separator;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class Javafxtuts extends Application {

  public static void main(String[] args) {

  public void start(Stage stage) {
	// creating label
      Label lb=new Label(" Simple Progress Indicator ");
      ProgressIndicator spi = new ProgressIndicator();
	//creating label
      Label lb1=new Label(" another Progress Indicator ");
      ProgressIndicator pi = new ProgressIndicator();
	 Separator separator =new Separator();
      VBox root =new VBox();
      root.setPadding(new Insets(20, 10, 10, 10));
        Scene scene = new Scene(root, 250, 200);

Output :

Explanation of progress indicator example:

  • Creating simple Progress Indicator ASProgressIndicator spi = new ProgressIndicator();
  • ProgressIndicator pi = new ProgressIndicator();pi.setProgress(0.40F);

    It crate a new Progress Indicator and set its value 40/100.

  • Separator separator =new Separator();It create a separator to separate both Progress Indicator.

Leave A Reply