| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 
 |  
public class screenLoader extends MASTERCLASS {
 
    private Line loaderBar = new Line();
    private Line loaderBar2 = new Line();
    private ResourceLoadingTask task = new ResourceLoadingTask();
    private int textWidth = 200;
 
    private Parent loadingContent() {
        Pane root = new Pane();
        root.setPrefSize(800, 600);
 
        Text copyright = new Text();
        copyright.setFont(new Font(12));
        copyright.setTextAlignment(TextAlignment.CENTER);
        copyright.setWrappingWidth(textWidth);
        copyright.setX((800 / 2) - (textWidth / 2));
        copyright.setY(600 - 5);
        copyright.setText("Copyright BLA BLA BLA");
 
        LoadingCircle loadingCircle = new LoadingCircle();
        loadingCircle.setTranslateX(800 - 120);
        loadingCircle.setTranslateY(600 - 100);
 
        Rectangle loadingBarBG = new Rectangle(100, 600 - 70, 800 - 200, 5);
        loadingBarBG.setFill(Color.DARKGREY);
        loadingBarBG.setStroke(Color.BLUE);
 
        loaderBar.setStartX(100);
        loaderBar.setStartY(600 - 70);
        loaderBar.setEndX(100);
        loaderBar.setEndY(600 - 70);
        loaderBar.setStroke(Color.AZURE);
 
        loaderBar2.setStartX(100);
        loaderBar2.setStartY(600 - 65);
        loaderBar2.setEndX(100);
        loaderBar2.setEndY(600 - 65);
        loaderBar2.setStroke(Color.AZURE);
 
        task.progressProperty().addListener((observable, oldValue, newValue) -> {
            double progress = newValue.doubleValue();
            loaderBar.setEndX(100 + progress * (800 - 200));
            loaderBar2.setEndX(100 + progress * (800 - 200));
        });
 
        root.getChildren().addAll(copyright, loadingCircle, loadingBarBG, loaderBar, loaderBar2);
        return (root);
    }
 
    private RotateTransition animation;
 
    class LoadingCircle extends Parent {
 
        private LoadingCircle() {
            Circle circle = new Circle(20);
            circle.setFill(null);
            circle.setStroke(Color.WHITE);
            circle.setStrokeWidth(5);
 
            Rectangle rect = new Rectangle(25, 25);
 
            Shape shape = Shape.subtract(circle, rect);
            shape.setFill(Color.DARKGREY);
            shape.setStroke(Color.DARKGREY);
 
            getChildren().add(shape);
 
            animation = new RotateTransition(Duration.seconds(2.5), this);
            animation.setByAngle(360);
            animation.setInterpolator(Interpolator.LINEAR);
            animation.setCycleCount(Animation.INDEFINITE);
            animation.play();
        }
    }
 
    class ResourceLoadingTask extends Task<Void> {
 
        @Override
        protected Void call() throws Exception {
 
            for (int i = 0; i < 100; i++) {
                Thread.sleep((int)(Math.random() * 100));
                updateProgress(i + 1, 100);
            }
            animation.stop();
            // /!\
            // C'EST ICI QUE JE VEUX DE L'AIDE
            getScreenMenu().displayWindow(); // AUCUNE ERREUR REMARQUÉE PAR L'IDE, RIEN NE S'AFFICHE
            // /!\
            return (null);
        }
    }
 
    public void displayWindow() throws InterruptedException {
        System.out.println("YOLO I AM TEST - YOUR FATHER!");
        getWindow().setTitle("JE SUIS : Loader");
 
        getWindow().setScene(createContent(this.loadingContent()));
 
        getWindow().setResizable(false);
        getWindow().sizeToScene();
 
        getWindow().show();
 
        Thread t = new Thread(task);
        t.start();
    }
} | 
Partager