1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package Utilities;
21
22 import javafx.concurrent.Task;
23 import javafx.geometry.Pos;
24 import javafx.scene.Scene;
25 import javafx.scene.control.Label;
26 import javafx.scene.control.ProgressBar;
27 import javafx.scene.layout.VBox;
28 import javafx.stage.Modality;
29 import javafx.stage.Stage;
30 import javafx.stage.StageStyle;
31
32
33
34
35 public class ProgressForm {
36 final Label label = new Label();
37 private final Stage dialogStage;
38 private final ProgressBar pb = new ProgressBar();
39
40
41 public ProgressForm() {
42 dialogStage = new Stage();
43 dialogStage.initStyle(StageStyle.UTILITY);
44 dialogStage.setResizable(false);
45 dialogStage.initModality(Modality.APPLICATION_MODAL);
46
47
48 label.setText("alerto");
49
50 pb.setProgress(-1F);
51
52 final VBox vb = new VBox();
53 vb.setSpacing(5);
54 vb.setAlignment(Pos.CENTER);
55 vb.getChildren().addAll(label, pb);
56
57 Scene scene = new Scene(vb);
58 dialogStage.setScene(scene);
59 }
60
61 public void activateProgressBar(final Task<?> task) {
62 pb.progressProperty().bind(task.progressProperty());
63 label.textProperty().bind(task.messageProperty());
64
65 dialogStage.show();
66 }
67
68 public Stage getDialogStage() {
69 return dialogStage;
70 }
71 }