Added loading FXML view

This commit is contained in:
Gregory Ballantine 2023-01-12 18:01:33 -05:00
parent 19dc3088fa
commit 9c52a48425
2 changed files with 15 additions and 4 deletions

View File

@ -15,6 +15,11 @@
<artifactId>javafx-controls</artifactId>
<version>17</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>17</version>
</dependency>
</dependencies>
<build>
<plugins>

View File

@ -1,9 +1,12 @@
package net.metaunix;
import java.io.IOException;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
@ -13,12 +16,15 @@ import javafx.stage.Stage;
public class App extends Application {
@Override
public void start(Stage stage) {
public void start(Stage stage) throws IOException {
var javaVersion = SystemInfo.javaVersion();
var javafxVersion = SystemInfo.javafxVersion();
var label = new Label("Hello, JavaFX " + javafxVersion + ", running on Java " + javaVersion + ".");
var scene = new Scene(new StackPane(label), 640, 480);
Parent root = FXMLLoader.load(getClass().getClassLoader().getResource("views/main.fxml"));
var scene = new Scene(root, 640, 480);
stage.setTitle("Acorn Music Player");
stage.setScene(scene);
stage.show();
}
@ -27,4 +33,4 @@ public class App extends Application {
launch();
}
}
}