×

JavaFX ProgressBar

In the JavaFX application, in order to show the progress of work ProgressBar is used. It shows how much work is done. In order to use ProgressBar in JavaFX, javafx.scene.control.ProgressBar class is used.

JavaFX ProgressBar:

Example:

import javafx.application.Application;


import javafx.scene.Scene;
import javafx.scene.control.ProgressBar;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;  


  
public class ProgressBarUI extends Application {  


    @Override  
    public void start(Stage primaryStage) throws Exception 
    {  
      StackPane pane = new StackPane();  
      ProgressBar newprogress = new ProgressBar();  
      pane.getChildren().add(newprogress);  
        Scene scn = new Scene(pane, 400, 200);
        primaryStage.setScene(scn);  
        primaryStage.setTitle("JavaFx Progress bar Example");  
        primaryStage.show();  
        }
    public static void main(String[] args) {
        Application.launch(args);
    }
}

Output:

In order to create the ProgressBar in JavaFX, we have to import all the required libraries such as javafx.application.Application, javafx.scene.Scene, javafx.stage.Stage, javafx.scene.control.ProgressBar, javafx.scene.layout.StackPane.

Then we have created one class named ProgressBarUI extending the Application class. Also, we have to override the start method to provide implementation details. This method creates an object of Stage as primaryStage. For the container to hold ProgressBar, a StackPane object is created which is then passed to the Scene class object.

The ProgressBar is created with its constructor.

The stage is prepared, the title is set and the show() method is called to display output. In order to run the application, the launch(args) method is called in the main() method. In output Frame like container is displayed with the title, “ JavaFX Progress bar Example ”. Also, it displays Simple ProgressBar.

JavaFX ProgressBar

JavaFX ProgressBar with setProgress() method:

Example:

import javafx.application.Application;


import javafx.scene.Scene;
import javafx.scene.control.ProgressBar;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;  


  
public class ProgressBarUI extends Application {  


    @Override  
    public void start(Stage primaryStage) throws Exception 
    {  
    StackPane pane = new StackPane();  
        ProgressBar newprogress = new ProgressBar();  
        newprogress.setProgress(0.5f);  


        pane.getChildren().add(newprogress);  
        Scene scn = new Scene(pane, 400, 200);
        primaryStage.setScene(scn);  
        primaryStage.setTitle("JavaFx Progress bar Example");  
        primaryStage.show();  
        }
    public static void main(String[] args) {
        Application.launch(args);
    }
}

Output:

In order to create the ProgressBar with progress level set in JavaFX, we have to import all the required libraries such as javafx.application.Application, javafx.scene.Scene, javafx.stage.Stage, javafx.scene.control.ProgressBar, javafx.scene.layout.StackPane.

Then we have created one class named ProgressBarUI extending the Application class. Also, we have to override the start method to provide implementation details. This method creates an object of Stage as primaryStage. For the container to hold ProgressBar with 0.5 level. A StackPane object is created which is later on passed to the Scene class object.

The ProgressBar is created with its constructor. The setProgress() method is used to set the level of progress in ProgressBar.

The stage is prepared, the title is set, and the show() method is called to display output. In order to run the application, the launch(args) method is called in the main() method. In output Frame like container is displayed with the title, “ JavaFX Progress bar Example ”. Also, it displays ProgressBar with a 0.5 level.

JavaFX ProgressBar

JavaFX Progress Bar with Progress Indicator:

Example:

import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.geometry.Insets;
import javafx.scene.Group;
import javafx.scene.control.ProgressBar;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;


  
public class ProgressBarUI extends Application {  


    @Override  
    public void start(Stage primaryStage) throws Exception 
    {  
    ProgressBar newprogress = new ProgressBar();
    newprogress.setProgress(0.4);
        ProgressIndicator newindicator = new ProgressIndicator(0.4);
        newprogress.setPrefSize(300, 30);
        HBox hbox = new HBox(20);
        hbox.setSpacing(15);
        hbox.setPadding(new Insets(75, 150, 50, 60));
        hbox.getChildren().addAll(newprogress, newindicator);
        Group pane = new Group(hbox);
        Scene scn = new Scene(pane, 600, 400);
        primaryStage.setScene(scn);  
        primaryStage.setTitle("JavaFx Progress bar Example");  
        primaryStage.show();  
        }
    public static void main(String[] args) {
        Application.launch(args);
    }
}

Output:

In order to create the ProgressBar with progress indicator and level set in JavaFX, we have to import all the required libraries such as javafx.application.Application, javafx.stage.Stage, javafx.scene.Scene, javafx.geometry.Insets, javafx.scene.Group, javafx.scene.control.ProgressBar, javafx.scene.control.ProgressIndicator, javafx.scene.layout.HBox, and javafx.scene.paint.Color.

Then we have created one class named ProgressBarUI extending the Application class. Also, we have to override the start method to provide implementation details. This method creates an object of Stage as primaryStage. For the container to hold ProgressBar with 0.4 level and progress indicator with 0.4 level. Group is created and later on passed to the Scene class object.

The ProgressBar is created with its constructor. The setProgress() method is used to set the level of progress in ProgressBar. ProgressIndicator is created using its constructor with a level passed in it.

The stage is prepared, the title is set and the show() method is called to display output. The launch(args) method is called. In output Frame like container is displayed with the title, “ JavaFX Progress bar Example ”. Also, it displays ProgressBar with 0.4 level and progress indicator with the same level.

JavaFX ProgressBar

Related Topics

JavaFX Translate Transition

In the JavaFX application, in order to generate the translate transition, we have to apply translate transition on any particular shape. It has the ability to translate the shape along...

3 minutes read.

JavaFX Slider

In the JavaFX application, in order to slide over a range of data having values, Slider is used. It provides a pane with a Slider to move over a range...

4 minutes read.

JavaFX PasswordField

In the JavaFX application, to get the user information and password as input from the user, a form is created using textfields and password fields which allows the user to...

4 minutes read.

JavaFX Drop Shadow

In the JavaFX application, in order to apply various Drop Shadow effect, we use this class. It has the ability to create the drop shadow of the given object. This...

4 minutes read.

JavaFX Area Chart

In the JavaFX application, in order to create Area Chart, the AreaChart class is used. The Area Chart allows us to plot data along the XY plane. All methods needed...

3 minutes read.

JavaFX Installation

In order to run JavaFX applications, we need to have eclipse and java installed on our machine. Prerequisite: Operating systemAny Operating system (Windows, Linux, Mac)Memory requirementNo minimum requirementDisk SpaceNo minimum requirementJDK versionJDK...

3 minutes read.

JavaFX Circle

In the JavaFX application, in order to draw a circle, the Circle class is used. The Circle allows us to join any points in the space. All methods needed for...

4 minutes read.

JavaFX Sequential Transition

In the JavaFX application, in order to generate the sequential transition, we have to apply sequential transition on any particular shape. It has the ability to execute multiple transactions sequentially...

4 minutes read.

JavaFX Line

In the JavaFX application, in order to draw a line, the Line class is used. The line allows us to join any two points with x and y coordinates in...

3 minutes read.

JavaFX Line Chart

In the JavaFX application, in order to create a Line Chart, LineChart class is used. The LineChart allows us to plot markers point according to the entities on number axes....

4 minutes read.

JavaFX Color Input

In the JavaFX application, in order to apply various color input effect, we use the ColorInput class. It has the ability to fill the specified shape with a given color...

4 minutes read.

JavaFX Glow

In the JavaFX application, in order to apply various glow effect, we use Glow class. It has the ability to glow the colors of the shape. All methods needed for...

4 minutes read.

JavaFX Scale Transition

In the JavaFX application, in order to generate the scale transition, we have to apply scale transition on any particular shape. It has the ability to scale the shape along...

4 minutes read.

JavaFX Image Input

In the JavaFX application, in order to apply various image input effect, we use the ImageInput class. It has the ability to fill the specified shape with a given image...

4 minutes read.

JavaFX Light Point

In the JavaFX application, in order to apply various LightPoint effect from a single source, we use this class. It has the ability to apply light from a single source...

4 minutes read.

JavaFX Bar Chart

In the JavaFX application, in order to create Bar Chart, the BarChart class is used. The Bar Chart allows us to plot data along different bars to show the scales...

4 minutes read.

JavaFX Scaling

In the JavaFX application, in order to apply various Scaling effects, we use this class. It has the ability to change the size of the given object. All methods needed...

5 minutes read.

JavaFX Cylinder

In the JavaFX application, in order to draw a Cylinder, the Cylinder class is used. The Cylinder allows us to form a 3D shape having rectangular faces and a straight...

4 minutes read.

JavaFX Rotation

In the JavaFX application, in order to apply various rotation effects, we use this class. It has the ability to rotate the given object. It rotates the given node along...

3 minutes read.

JavaFX Box

In the JavaFX application, in order to draw a Box, the Box class is used. The Box allows us to form 3D shape having rectangular faces. All methods needed for...

4 minutes read.