Browse Source

add JavaFX

main
fdai7736 11 months ago
parent
commit
5fa39297a7
  1. 65
      pom.xml
  2. 5
      src/main/java/de/hsfulda/onses/Main.java
  3. 22
      src/main/java/de/hsfulda/onses/controllers/MainController.java
  4. 14
      src/main/resources/de/hsfulda/onses/views/main.fxml

65
pom.xml

@ -12,6 +12,71 @@
<maven.compiler.source>21</maven.compiler.source> <maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target> <maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.version>5.10.1</junit.version>
</properties> </properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>21</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>21</version>
</dependency>
<dependency>
<groupId>org.kordamp.bootstrapfx</groupId>
<artifactId>bootstrapfx-core</artifactId>
<version>0.4.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>21</source>
<target>21</target>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.8</version>
<executions>
<execution>
<!-- Default configuration for running with: mvn clean javafx:run -->
<id>default-cli</id>
<configuration>
<mainClass>de.hsfulda.uno/de.hsfulda.onses.HelloApplication</mainClass>
<launcher>app</launcher>
<jlinkZipName>app</jlinkZipName>
<jlinkImageName>app</jlinkImageName>
<noManPages>true</noManPages>
<stripDebug>true</stripDebug>
<noHeaderFiles>true</noHeaderFiles>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project> </project>

5
src/main/java/de/hsfulda/onses/Main.java

@ -1,7 +1,10 @@
package de.hsfulda.onses; package de.hsfulda.onses;
import de.hsfulda.onses.controllers.MainController;
import javafx.application.Application;
public class Main { public class Main {
public static void main(String[] args) { public static void main(String[] args) {
System.out.println("Hello world!");
Application.launch(MainController.class);
} }
} }

22
src/main/java/de/hsfulda/onses/controllers/MainController.java

@ -0,0 +1,22 @@
package de.hsfulda.onses.controllers;
import de.hsfulda.onses.Main;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import java.io.IOException;
import java.util.Objects;
public class MainController extends Application {
@Override
public void start(Stage stage) throws IOException {
final Parent parent = FXMLLoader.load(Objects.requireNonNull(Main.class.getResource("views/main.fxml")));
stage.setTitle("Onses");
stage.setScene(new Scene(parent));
stage.show();
}
}

14
src/main/resources/de/hsfulda/onses/views/main.fxml

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<AnchorPane xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
fx:controller="de.hsfulda.onses.controllers.MainController"
prefHeight="400.0" prefWidth="600.0">
</AnchorPane>
Loading…
Cancel
Save