Launcher now finds and correctly sets main Scene

This commit is contained in:
François Autin 2021-05-28 01:15:50 +02:00
parent 4e99b1e115
commit cd7627d36d
No known key found for this signature in database
GPG Key ID: 24025429AC559B7C
3 changed files with 13 additions and 7 deletions

View File

@ -7,6 +7,11 @@
<description>Projet de fin d'année de L3</description> <description>Projet de fin d'année de L3</description>
<build> <build>
<sourceDirectory>src</sourceDirectory> <sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src/launcher/ui</directory>
</resource>
</resources>
<plugins> <plugins>
<plugin> <plugin>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>

View File

@ -9,8 +9,6 @@
package launcher; package launcher;
import java.io.FileInputStream;
import javafx.application.Application; import javafx.application.Application;
import javafx.scene.Parent; import javafx.scene.Parent;
import javafx.scene.Scene; import javafx.scene.Scene;
@ -19,16 +17,19 @@ import javafx.fxml.*;
public class Launcher extends Application { public class Launcher extends Application {
/*
* Start method is used by Launcher as an implementation of the Application class to create a JavaFX thread to display the GUI window
*/
public void start(Stage primaryStage) throws Exception { public void start(Stage primaryStage) throws Exception {
FileInputStream r_launcher = new FileInputStream("ui/launcher.fxml");
FXMLLoader floader = new FXMLLoader(); Parent root = FXMLLoader.load(getClass().getResource("ui/launcher.fxml"));
Parent root = floader.load(r_launcher);
Scene main = root.getScene(); Scene main = new Scene(root);
primaryStage.setTitle("Boulevard Combattant"); primaryStage.setTitle("Boulevard Combattant");
primaryStage.setScene(main); primaryStage.setScene(main);
primaryStage.show(); primaryStage.show();
} }
} }