Loading gif removed

Loading gif removed after all fxmls loaded
voting-station-gui
Vladimir ELazar Tokarev 2016-05-20 12:54:33 +03:00
parent b76bd76854
commit 6d01be0d13
2 changed files with 21 additions and 9 deletions

View File

@ -2,6 +2,7 @@ package splash_screen_on_boot;
import javafx.application.Application; import javafx.application.Application;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.Parent; import javafx.scene.Parent;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.stage.Stage; import javafx.stage.Stage;
@ -10,9 +11,12 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.ThreadFactory;
public class Main extends Application { public class Main extends Application {
private static final String SPALSH_SCREEN_ON_BOOT_FXML_PATH = "fxmls/spalsh_screen_on_boot.fxml";
private List<String> listFilesForFolder(File folder) { private List<String> listFilesForFolder(File folder) {
List<String> filesNames = new ArrayList<>(); List<String> filesNames = new ArrayList<>();
for (final File fileEntry : folder.listFiles()) for (final File fileEntry : folder.listFiles())
@ -31,26 +35,34 @@ public class Main extends Application {
private List<Parent> Boards; private List<Parent> Boards;
private void loadAllFxmls() throws IOException { private void loadAllFxmls() throws IOException, InterruptedException {
Boards = new ArrayList<>(); Boards = new ArrayList<>();
for (String filename : getNamesOfAllFxmls()) { for (String filename : getNamesOfAllFxmls()) {
Boards.add(FXMLLoader.load(getClass().getResource("fxmls/" + filename))); Boards.add(FXMLLoader.load(getClass().getResource("fxmls/" + filename)));
} }
} }
@Override private Parent loadStartingPanel(Stage primaryStage) throws IOException {
public void start(Stage primaryStage) throws Exception{ Parent root = FXMLLoader.load(getClass().getResource(SPALSH_SCREEN_ON_BOOT_FXML_PATH));
Parent root = FXMLLoader.load(getClass().getResource("fxmls/spalsh_screen_on_boot.fxml"));
primaryStage.setTitle("Voting Station"); primaryStage.setTitle("Voting Station");
primaryStage.setScene(new Scene(root, 560, 360)); primaryStage.setScene(new Scene(root, 560, 360));
primaryStage.show(); primaryStage.show();
return root;
loadAllFxmls();
} }
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); launch(args);
} }
} }

View File

@ -59,7 +59,7 @@
<children> <children>
<AnchorPane GridPane.columnIndex="1"> <AnchorPane GridPane.columnIndex="1">
<children> <children>
<ImageView AnchorPane.leftAnchor="65.0" AnchorPane.rightAnchor="65.0" GridPane.columnIndex="1"> <ImageView fx:id="LoadingGif" AnchorPane.leftAnchor="65.0" AnchorPane.rightAnchor="65.0" GridPane.columnIndex="1">
<image> <image>
<Image url="@../../gifs/loadingGif.gif" /> <Image url="@../../gifs/loadingGif.gif" />
</image> </image>