user13419405
user13419405

Reputation:

JavaFX ProgressIndicator to show a new Stage()

I have a method called enpointsList() which stage which contain a TableView. Now I have this ProgressIndicator which will run till this TableView shows up!

StackPane root = new StackPane();
            root.setStyle("-fx-background-color: rgba(0,0,0,0.5)");
                    ProgressIndicator pi = new ProgressIndicator();
                    root.setAlignment(Pos.CENTER);
                    root.getChildren().add(pi);   
                    root.setMinWidth(700);
                    root.setMinHeight(500);
                    Scene c = new Scene(root, Color.TRANSPARENT);
                    Task<Void> task = new Task<Void>()
                    {
                        @Override
                        protected Void call() throws Exception
                        {
                            
                            request = specificVersion(URL);
                            endpointsList(request); //Create New Stage
                            Thread.sleep(150);
                            return null;
                        }
                    };
                    
                    pi.progressProperty().bind(task.progressProperty());
                    task.setOnSucceeded((workerStateEvent) -> {
                        stage.close();
                        
                    });
                    new Thread(task).start();
                    
            stage.initStyle(StageStyle.TRANSPARENT);
            stage.setX(350);
            stage.setY(100);
            stage.setScene(c);
            stage.setMinWidth(700);
            stage.setMinHeight(500);
            stage.show();

but always the progress indicator runs without end!

Upvotes: 0

Views: 71

Answers (0)

Related Questions