Modal of absolute loading

Asked

Viewed 39 times

1

Good afternoon, I would like to know how I can make my loading stage absolute on my main stage. Since, as the code below I am setting the X/Y based on my main Stage, however when moving the main Stage with the mouse the loading Stage is shifted Ex:

    private static void createModalLoadingTask() {
    if(MODAL == null){
        try {
            MODAL = new Stage(StageStyle.TRANSPARENT);
            FXMLLoader modalLoader = new FXMLLoader(Esign.class.getResource("/test/LoadingModal.fxml"));
            AnchorPane ap = (AnchorPane) modalLoader.load();
            MODAL.initModality(Modality.NONE);
            MODAL.initStyle(StageStyle.UNDECORATED);
            MODAL.initOwner(primaryStage);
            MODAL.setOpacity(MODAL_OPACITY);
            alignSplash();
            Scene s = new Scene(ap);
            s.setFill(null);
            MODAL.setScene(s);
        } catch (IOException e) {
            LOG.error(e.getMessage());
        }
    }
}

private static void alignSplash() {
    MODAL.setX(primaryStage.getX()+INCREMENT_X);
    MODAL.setY(primaryStage.getY()+INCREMENT_Y);
}
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.