All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.athi.athifx.gui.application.WaitingScreen Maven / Gradle / Ivy

The newest version!
package com.github.athi.athifx.gui.application;

import javafx.concurrent.Task;
import javafx.scene.control.Label;
import javafx.scene.control.ProgressBar;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;

import static com.github.athi.athifx.gui.configuration.ApplicationConfiguration.WAITING_FOR_COMPLETION_MESSAGE;

/**
 * Created by Athi
 */
public class WaitingScreen extends AbstractScreen {

    private Stage waitingScreen;

    public void show(Task task) {
        waitingScreen = new Stage();

        waitingScreen.initStyle(StageStyle.UNDECORATED);
        waitingScreen.setResizable(false);
        waitingScreen.initModality(Modality.APPLICATION_MODAL);

        AnchorPane root = prepareRoot(waitingScreen);
        root.setPrefWidth(400);
        root.setPrefHeight(40);

        ProgressBar progressBar = new ProgressBar();
        progressBar.progressProperty().bind(task.progressProperty());

        Label infoLabel = new Label(WAITING_FOR_COMPLETION_MESSAGE);

        root.getChildren().addAll(progressBar, infoLabel);

        setAnchors(progressBar, 2.0, 2.0, 2.0, 2.0);
        setAnchors(infoLabel, 8.0, 2.0, 2.0, 2.0);

        waitingScreen.show();
    }

    public void close() {
        if (waitingScreen.isShowing()) {
            waitingScreen.close();
        }
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy