Created loader of all next fxmls

Now we display the spalsh screen on boot then load all of the fxmls
voting-station-gui
Dasha-1 2016-05-20 12:10:17 +03:00
parent 7eb5aec1d1
commit b76bd76854
6 changed files with 62 additions and 29 deletions

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -1,4 +0,0 @@
package sample;
public class Controller {
}

View File

@ -1,23 +0,0 @@
package sample;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception{
Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
primaryStage.setTitle("Voting Station");
primaryStage.setScene(new Scene(root, 560, 360));
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}

View File

@ -0,0 +1,4 @@
package splash_screen_on_boot;
public class Controller {
}

View File

@ -0,0 +1,56 @@
package splash_screen_on_boot;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class Main extends Application {
private List<String> listFilesForFolder(File folder) {
List<String> filesNames = new ArrayList<>();
for (final File fileEntry : folder.listFiles())
{
filesNames.add(fileEntry.getName());
}
return filesNames;
}
private List<String> getNamesOfAllFxmls() throws IOException {
String fxmlsFolderPath = getClass().getResource("fxmls/").getPath().replace("%20", " ");
List<String> filesNames = listFilesForFolder(new File(fxmlsFolderPath));
return filesNames;
}
private List<Parent> Boards;
private void loadAllFxmls() throws IOException {
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"));
primaryStage.setTitle("Voting Station");
primaryStage.setScene(new Scene(root, 560, 360));
primaryStage.show();
loadAllFxmls();
}
public static void main(String[] args) {
launch(args);
}
}

View File

@ -11,7 +11,7 @@
<?import javafx.scene.control.Label?>
<GridPane alignment="center" hgap="10" vgap="10" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8" fx:controller="sample.Controller">
<GridPane alignment="center" hgap="10" vgap="10" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8" fx:controller="splash_screen_on_boot.Controller">
<columnConstraints>
<ColumnConstraints />
<ColumnConstraints />
@ -61,7 +61,7 @@
<children>
<ImageView AnchorPane.leftAnchor="65.0" AnchorPane.rightAnchor="65.0" GridPane.columnIndex="1">
<image>
<Image url="@../Gifs/712%20(1).gif" />
<Image url="@../../gifs/loadingGif.gif" />
</image>
<GridPane.margin>
<Insets left="60.0" />