From 6d01be0d13239c22b76a34378bb08a4c579c502a Mon Sep 17 00:00:00 2001 From: Vladimir ELazar Tokarev Date: Fri, 20 May 2016 12:54:33 +0300 Subject: [PATCH] Loading gif removed Loading gif removed after all fxmls loaded --- .../src/splash_screen_on_boot/Main.java | 28 +++++++++++++------ .../fxmls/spalsh_screen_on_boot.fxml | 2 +- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/voting-station-gui/src/splash_screen_on_boot/Main.java b/voting-station-gui/src/splash_screen_on_boot/Main.java index 313567c..08c7ba4 100644 --- a/voting-station-gui/src/splash_screen_on_boot/Main.java +++ b/voting-station-gui/src/splash_screen_on_boot/Main.java @@ -2,6 +2,7 @@ package splash_screen_on_boot; import javafx.application.Application; import javafx.fxml.FXMLLoader; +import javafx.scene.Node; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.stage.Stage; @@ -10,9 +11,12 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.ThreadFactory; public class Main extends Application { + private static final String SPALSH_SCREEN_ON_BOOT_FXML_PATH = "fxmls/spalsh_screen_on_boot.fxml"; + private List listFilesForFolder(File folder) { List filesNames = new ArrayList<>(); for (final File fileEntry : folder.listFiles()) @@ -31,26 +35,34 @@ public class Main extends Application { private List Boards; - private void loadAllFxmls() throws IOException { + private void loadAllFxmls() throws IOException, InterruptedException { Boards = new ArrayList<>(); for (String filename : getNamesOfAllFxmls()) { Boards.add(FXMLLoader.load(getClass().getResource("fxmls/" + filename))); } } - @Override - public void start(Stage primaryStage) throws Exception{ - - Parent root = FXMLLoader.load(getClass().getResource("fxmls/spalsh_screen_on_boot.fxml")); + private Parent loadStartingPanel(Stage primaryStage) throws IOException { + Parent root = FXMLLoader.load(getClass().getResource(SPALSH_SCREEN_ON_BOOT_FXML_PATH)); primaryStage.setTitle("Voting Station"); primaryStage.setScene(new Scene(root, 560, 360)); primaryStage.show(); - - loadAllFxmls(); + return root; } + private void removeLoadingGif(Parent root) throws InterruptedException { + Node loadingGif = root.lookup("#LoadingGif"); + loadingGif.setVisible(false); + } - public static void main(String[] args) { + @Override + public void start(Stage primaryStage) throws Exception{ + Parent root = loadStartingPanel(primaryStage); + loadAllFxmls(); + removeLoadingGif(root); + } + + public static void main(String[] args) throws InterruptedException { launch(args); } } diff --git a/voting-station-gui/src/splash_screen_on_boot/fxmls/spalsh_screen_on_boot.fxml b/voting-station-gui/src/splash_screen_on_boot/fxmls/spalsh_screen_on_boot.fxml index 6d15a1d..a0a5e58 100644 --- a/voting-station-gui/src/splash_screen_on_boot/fxmls/spalsh_screen_on_boot.fxml +++ b/voting-station-gui/src/splash_screen_on_boot/fxmls/spalsh_screen_on_boot.fxml @@ -59,7 +59,7 @@ - +