diff --git a/.gitpod.Dockerfile b/.gitpod.Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..22ece18e9463c0835a475631069e77cc4ee2d93b --- /dev/null +++ b/.gitpod.Dockerfile @@ -0,0 +1,7 @@ +FROM gitpod/workspace-full-vnc + +USER gitpod + +RUN bash -c ". /home/gitpod/.sdkman/bin/sdkman-init.sh \ + && sdk install java 16.0.1.hs-adpt \ + && sdk default java 16.0.1.hs-adpt" diff --git a/.gitpod.yml b/.gitpod.yml new file mode 100644 index 0000000000000000000000000000000000000000..d22e09670d747777e29c518d412087e640cb665b --- /dev/null +++ b/.gitpod.yml @@ -0,0 +1,10 @@ +image: + file: .gitpod.Dockerfile + +tasks: + - init: sdk use java 16.0.1.hs-adpt + command: cd javafx-template; mvn compile + +ports: + # used by virtual desktop and vnc, supports JavaFX + - port: 6080 diff --git a/javafx-template/.gitignore b/javafx-template/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..213163975bb915006004bbbf5a9c7d75f6598f95 --- /dev/null +++ b/javafx-template/.gitignore @@ -0,0 +1,2 @@ +# ignore maven build folder +target/ diff --git a/javafx-template/pom.xml b/javafx-template/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..c3e9984b644bdfdf57145b04fcec59634e87356f --- /dev/null +++ b/javafx-template/pom.xml @@ -0,0 +1,97 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>it1901</groupId> + <artifactId>javafx-template</artifactId> + <version>0.0.1-SNAPSHOT</version> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <maven.compiler.source>16</maven.compiler.source> + <maven.compiler.target>16</maven.compiler.target> + </properties> + + <dependencies> + + <!-- javafx --> + <dependency> + <groupId>org.openjfx</groupId> + <artifactId>javafx-controls</artifactId> + <version>16</version> + </dependency> + <dependency> + <groupId>org.openjfx</groupId> + <artifactId>javafx-fxml</artifactId> + <version>16</version> + </dependency> + + <!-- junit testing with jupiter --> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-api</artifactId> + <version>5.7.2</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-engine</artifactId> + <version>5.7.2</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-params</artifactId> + <version>5.7.2</version> + <scope>test</scope> + </dependency> + + <!-- test javafx with TextFX --> + <dependency> + <groupId>org.testfx</groupId> + <artifactId>testfx-core</artifactId> + <version>4.0.16-alpha</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.testfx</groupId> + <artifactId>testfx-junit5</artifactId> + <version>4.0.16-alpha</version> + <scope>test</scope> + </dependency> + + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.8.1</version> + <configuration> + <release>16</release> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>3.0.0-M5</version> + </plugin> + + <plugin> + <groupId>org.openjfx</groupId> + <artifactId>javafx-maven-plugin</artifactId> + <version>0.0.6</version> + <executions> + <execution> + <!-- Default configuration for running --> + <!-- Usage: mvn clean javafx:run --> + <id>default-cli</id> + <configuration> + <mainClass>app.App</mainClass> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> diff --git a/javafx-template/src/main/java/app/App.java b/javafx-template/src/main/java/app/App.java new file mode 100644 index 0000000000000000000000000000000000000000..17d788e2986cb64a4124abf3d2b1dbc3ac99e12e --- /dev/null +++ b/javafx-template/src/main/java/app/App.java @@ -0,0 +1,29 @@ +package groupid; + +import javafx.application.Application; +import javafx.fxml.FXMLLoader; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.stage.Stage; + +import java.io.IOException; + +/** + * JavaFX App + */ +public class App extends Application { + + private static Scene scene; + + @Override + public void start(Stage stage) throws IOException { + FXMLLoader fxmlLoader = new FXMLLoader(this.getClass().getResource("App.fxml")); + Parent parent = fxmlLoader.load(); + stage.setScene(new Scene(parent)); + stage.show(); + } + + public static void main(String[] args) { + launch(); + } +} \ No newline at end of file diff --git a/javafx-template/src/main/java/app/AppController.java b/javafx-template/src/main/java/app/AppController.java new file mode 100644 index 0000000000000000000000000000000000000000..348e0f6f891f02862d3050042de3634e98e0f57d --- /dev/null +++ b/javafx-template/src/main/java/app/AppController.java @@ -0,0 +1,11 @@ +package groupid; + +import java.io.IOException; +import javafx.fxml.FXML; + +public class AppController { + + @FXML + private void switchToSecondary() throws IOException { + } +} diff --git a/javafx-template/src/main/resources/app/App.fxml b/javafx-template/src/main/resources/app/App.fxml new file mode 100644 index 0000000000000000000000000000000000000000..b0e6c58039c7bf19bd2df94954ffaf81b3d0a8ca --- /dev/null +++ b/javafx-template/src/main/resources/app/App.fxml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.scene.layout.VBox?> +<?import javafx.scene.control.Label?> +<?import javafx.scene.control.Button?> +<?import javafx.geometry.Insets?> + +<VBox alignment="CENTER" spacing="20.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="app.AppController"> + <children> + <Label text="Primary View" /> + <Button fx:id="primaryButton" text="Switch to Secondary View" onAction="#switchToSecondary"/> + </children> + <padding> + <Insets bottom="20.0" left="20.0" right="20.0" top="20.0" /> + </padding> +</VBox>