JavaFX Tutorial 26 ProgressBar Java GUI
Source Code : https://bit.ly/34qCpPT
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("JavaFX Tutorial");
Pane pane = new Pane();
// Source Code In Description
ProgressBar prog_bar = new ProgressBar(0);
prog_bar.setPrefWidth(400);
prog_bar.setLayoutY(50);
pane.getChildren().add(prog_bar);
Button start = new Button("Start");
start.setLayoutY(70);
pane.getChildren().add(start);
Button cancel = new Button("Cancel");
cancel.setLayoutX(60);
cancel.setLayoutY(70);
cancel.setDisable(true);
pane.getChildren().add(cancel);
start.setOnAction((event) -? {
prog_bar.setProgress(prog_bar.getProgress()+0.1);
if(prog_bar.getProgress() ?= 0.9){
start.setDisable(true);
cancel.setDisable(false);
}
});
cancel.setOnAction((event) -? {
start.setDisable(false);
prog_bar.setProgress(0);
cancel.setDisable(true);
});
VBox vBox = new VBox(pane);
Scene scene = new Scene(vBox, 800, 600);
primaryStage.setScene(scene);
primaryStage.show();
}
Libraries Importing :
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ProgressBar;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
In order to use a JavaFX ProgressBar you must first create an instance of the ProgressBar class. Here is how you create an instance of a JavaFX ProgressBar:
On this page of the site you can watch the video online JavaFX Tutorial 26 - ProgressBar Java GUI with a duration of hours minute second in good quality, which was uploaded by the user Code Amir 01 January 1970, share the link with friends and acquaintances, this video has already been watched 1,017 times on youtube and it was liked by 11 viewers. Enjoy your viewing!