JavaFX Progress Bar


JavaFX Progress tutorials:

The JavaFX Progress Bar is UI control which is used to visualize progress of an operation in JavaFX applications.
It is a horizontal bar to show progress from left to right.

Constructors :

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

Creating progress bar :

ProgressBar pb = new ProgressBar();

setProgress() method is used to set the starting progress of progress bar.

Example using Progress bar:

package javafxtuts;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.ProgressBar;
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) {
      Label lb=new Label(" Progress Bar ");
      ProgressBar pb = new ProgressBar();
      VBox root =new VBox();
      root.setPadding(new Insets(20, 10, 10, 10));
        Scene scene = new Scene(root, 250, 200);

Output :

Explanation of progress bar example :

    • Creating a new progress bar as
      ProgressBar pb = new ProgressBar();
    • pb.setProgress(0.40F);
      It set progress to 40/100

Leave A Reply