Saturday 23 June 2018

JavaFX: Working with ProgressIndicator widget

JavaFX provides ProgressBar and ProgressIndicator widgets to visualize the progress of operations (Ex: How much copy is done, how much installation finished etc.,).

In this post, I am going to explain about ProgressIndicator widget.

ProgressIndicator class provides below constructors to create ProgressIndicator widget.

public ProgressIndicator()
public ProgressIndicator(double progress)

Example 1
ProgressIndicator progressIndicator1 = new ProgressIndicator();
progressIndicator1.setProgress(0.3);

Example 2          
ProgressIndicator progressIndicator2 = new ProgressIndicator(0.6);

Find the below working application.

ProgressIndicatorApp.java
package com.sample.demos;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class ProgressIndicatorApp extends Application {

 @Override
 public void start(Stage primaryStage) throws Exception {
  ProgressIndicator progressIndicator1 = new ProgressIndicator();
  progressIndicator1.setProgress(0.3);
  
  ProgressIndicator progressIndicator2 = new ProgressIndicator(0.6);

  VBox vBox = new VBox(20, progressIndicator1, progressIndicator2);

  Scene scene = new Scene(vBox);

  primaryStage.setScene(scene);

  primaryStage.setTitle("Progress Indicator widget Example");
  primaryStage.setWidth(500);
  primaryStage.setHeight(400);
  primaryStage.show();
 }

}

TestFX.java
package com.sample.demos;

import javafx.application.Application;

public class TestFX {
 public static void main(String args[]) {
  Application.launch(ProgressIndicatorApp.class, args);
 }
}





Previous                                                 Next                                                 Home

No comments:

Post a Comment