diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..c89cfdc0d75484ed1323393cd37dfb582f49bc37 --- /dev/null +++ b/pom.xml @@ -0,0 +1,20 @@ +<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>cz.vsb.fei.java2</groupId> + <artifactId>javafx-quickstart</artifactId> + <version>1.0.0</version> + <packaging>maven-archetype</packaging> + + <build> + <extensions> + <extension> + <groupId>org.apache.maven.archetype</groupId> + <artifactId>archetype-packaging</artifactId> + <version>3.1.1</version> + </extension> + </extensions> + </build> + +</project> diff --git a/src/main/resources/META-INF/maven/archetype-metadata.xml b/src/main/resources/META-INF/maven/archetype-metadata.xml new file mode 100644 index 0000000000000000000000000000000000000000..855b191f242ee4dedbea93f6ee9edd8bfda6468a --- /dev/null +++ b/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -0,0 +1,27 @@ +<archetype-descriptor + xmlns="https://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.1.0" + xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="https://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.1.0 https://maven.apache.org/xsd/archetype-descriptor-1.1.0.xsd" + name="javafx-quickstart"> + <fileSets> + <fileSet filtered="true" packaged="true"> + <excludes> + <exclude>module-info.java</exclude> + </excludes> + <directory>src/main/java</directory> + </fileSet> + <fileSet filtered="true"> + <includes> + <include>module-info.java</include> + </includes> + <directory>src/main/java</directory> + </fileSet> + + <fileSet filtered="true" packaged="true"> + <directory>src/main/resources</directory> + </fileSet> + <fileSet filtered="true" packaged="true"> + <directory>src/test/java</directory> + </fileSet> + </fileSets> +</archetype-descriptor> \ No newline at end of file diff --git a/src/main/resources/archetype-resources/pom.xml b/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..20b1fc3469562cf7731dd48186d1ac7ac93f971c --- /dev/null +++ b/src/main/resources/archetype-resources/pom.xml @@ -0,0 +1,58 @@ +<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>${groupId}</groupId> + <artifactId>${artifactId}</artifactId> + <version>${version}</version> + + <name>${artifactId}</name> + + <packaging>jar</packaging> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <maven.compiler.release>21</maven.compiler.release> + <JavaFX.version>22-ea+16</JavaFX.version> + <JUnit.version>5.10.1</JUnit.version> + </properties> + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.junit</groupId> + <artifactId>junit-bom</artifactId> + <version>${JUnit.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + + <dependencies> + <dependency> + <groupId>org.openjfx</groupId> + <artifactId>javafx-controls</artifactId> + <version>${JavaFX.version}</version> + </dependency> + <dependency> + <groupId>org.openjfx</groupId> + <artifactId>javafx-fxml</artifactId> + <version>${JavaFX.version}</version> + </dependency> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <artifactId>maven-surefire-plugin</artifactId> + <version>3.2.1</version> + </plugin> + </plugins> + </build> + +</project> diff --git a/src/main/resources/archetype-resources/src/main/java/App.java b/src/main/resources/archetype-resources/src/main/java/App.java new file mode 100644 index 0000000000000000000000000000000000000000..b2d3741f4a219aedd906208ac96a890bd2f13353 --- /dev/null +++ b/src/main/resources/archetype-resources/src/main/java/App.java @@ -0,0 +1,49 @@ +package $package; + +import javafx.application.Application; +import javafx.fxml.FXMLLoader; +import javafx.scene.Scene; +import javafx.scene.layout.BorderPane; +import javafx.stage.Stage; +import javafx.stage.WindowEvent; + +/** + * Class <b>App</b> - extends class Application and it is an entry point of the program + * @author Java I + */ +public class App extends Application { + + public static void main(String[] args) { + launch(args); + } + + private AppController controller; + + @Override + public void start(Stage primaryStage) { + try { + //Construct a main window with a canvas. + + FXMLLoader loader = new FXMLLoader(this.getClass().getResource("AppWindow.fxml")); + + BorderPane root = loader.load(); + + Scene scene = new Scene(root); + + + primaryStage.setScene(scene); + primaryStage.setTitle("Hello word app"); + primaryStage.show(); + controller = loader.getController(); + + //Exit program when main window is closed + primaryStage.setOnCloseRequest(this::exitProgram); + } catch (Exception e) { + e.printStackTrace(); + } + } + + private void exitProgram(WindowEvent evt) { + System.exit(0); + } +} \ No newline at end of file diff --git a/src/main/resources/archetype-resources/src/main/java/AppController.java b/src/main/resources/archetype-resources/src/main/java/AppController.java new file mode 100644 index 0000000000000000000000000000000000000000..829307194becbd19eb82f222c21d6823168258a6 --- /dev/null +++ b/src/main/resources/archetype-resources/src/main/java/AppController.java @@ -0,0 +1,20 @@ +package $package; + +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.scene.control.Label; +import javafx.scene.control.MenuItem; + +public class AppController { + + @FXML + private Label infoLabel; + + @FXML + private void menuPressed(ActionEvent event) { + if(event.getSource() instanceof MenuItem menuItem) { + infoLabel.setText("Selected menu: " + menuItem.getText()); + } + } + +} diff --git a/src/main/resources/archetype-resources/src/main/java/module-info.java b/src/main/resources/archetype-resources/src/main/java/module-info.java new file mode 100644 index 0000000000000000000000000000000000000000..d80c132db1466cec48fcb4de0b032a6e061a99ff --- /dev/null +++ b/src/main/resources/archetype-resources/src/main/java/module-info.java @@ -0,0 +1,6 @@ +module $package { + requires transitive javafx.controls; + requires javafx.fxml; + opens $package to javafx.fxml; + exports $package; +} \ No newline at end of file diff --git a/src/main/resources/archetype-resources/src/main/resources/AppWindow.fxml b/src/main/resources/archetype-resources/src/main/resources/AppWindow.fxml new file mode 100644 index 0000000000000000000000000000000000000000..a6095ee7d698dd44ed0315af9a6f17bc6f74d1c7 --- /dev/null +++ b/src/main/resources/archetype-resources/src/main/resources/AppWindow.fxml @@ -0,0 +1,93 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + Copyright (c) 2015, 2019, Gluon and/or its affiliates. + All rights reserved. Use is subject to license terms. + + This file is available and licensed under the following license: + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the distribution. + - Neither the name of Oracle Corporation nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +--> + +<?import javafx.scene.control.Label?> +<?import javafx.scene.control.Menu?> +<?import javafx.scene.control.MenuBar?> +<?import javafx.scene.control.MenuItem?> +<?import javafx.scene.control.SeparatorMenuItem?> +<?import javafx.scene.layout.BorderPane?> +<?import javafx.scene.text.Font?> + + +<BorderPane minHeight="400.0" minWidth="640.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="${package}.AppController"> + <top> + <MenuBar BorderPane.alignment="CENTER"> + <menus> + <Menu mnemonicParsing="false" text="File"> + <items> + <MenuItem mnemonicParsing="false" onAction="#menuPressed" text="New" /> + <MenuItem mnemonicParsing="false" onAction="#menuPressed" text="Open…" /> + <Menu mnemonicParsing="false" text="Open Recent" /> + <SeparatorMenuItem mnemonicParsing="false" /> + <MenuItem mnemonicParsing="false" onAction="#menuPressed" text="Close" /> + <MenuItem mnemonicParsing="false" onAction="#menuPressed" text="Save" /> + <MenuItem mnemonicParsing="false" onAction="#menuPressed" text="Save As…" /> + <MenuItem mnemonicParsing="false" onAction="#menuPressed" text="Revert" /> + <SeparatorMenuItem mnemonicParsing="false" onAction="#menuPressed" /> + <MenuItem mnemonicParsing="false" onAction="#menuPressed" text="Preferences…" /> + <SeparatorMenuItem mnemonicParsing="false" /> + <MenuItem mnemonicParsing="false" onAction="#menuPressed" text="Quit" /> + </items> + </Menu> + <Menu mnemonicParsing="false" text="Edit"> + <items> + <MenuItem mnemonicParsing="false" onAction="#menuPressed" text="Undo" /> + <MenuItem mnemonicParsing="false" onAction="#menuPressed" text="Redo" /> + <SeparatorMenuItem mnemonicParsing="false" /> + <MenuItem mnemonicParsing="false" onAction="#menuPressed" text="Cut" /> + <MenuItem mnemonicParsing="false" onAction="#menuPressed" text="Copy" /> + <MenuItem mnemonicParsing="false" onAction="#menuPressed" text="Paste" /> + <MenuItem mnemonicParsing="false" onAction="#menuPressed" text="Delete" /> + <SeparatorMenuItem mnemonicParsing="false" /> + <MenuItem mnemonicParsing="false" onAction="#menuPressed" text="Select All" /> + <MenuItem mnemonicParsing="false" onAction="#menuPressed" text="Unselect All" /> + </items> + </Menu> + <Menu mnemonicParsing="false" text="Help"> + <items> + <MenuItem mnemonicParsing="false" onAction="#menuPressed" text="About MyHelloApp" /> + </items> + </Menu> + </menus> + </MenuBar> + </top> + <center> + <Label fx:id="infoLabel" alignment="CENTER" style=" " text="Drag components from Library here…" textAlignment="CENTER" textFill="#9f9f9f" wrapText="false" BorderPane.alignment="CENTER"> + <font> + <Font size="18.0" /> + </font> + </Label> + </center> +</BorderPane> diff --git a/src/main/resources/archetype-resources/src/main/resources/application.css b/src/main/resources/archetype-resources/src/main/resources/application.css new file mode 100644 index 0000000000000000000000000000000000000000..83d6f3343843c65d5dfaf3fedb97b6494c19113d --- /dev/null +++ b/src/main/resources/archetype-resources/src/main/resources/application.css @@ -0,0 +1 @@ +/* JavaFX CSS - Leave this comment until you have at least create one rule which uses -fx-Property */ \ No newline at end of file diff --git a/src/main/resources/archetype-resources/src/test/java/AppTest.java b/src/main/resources/archetype-resources/src/test/java/AppTest.java new file mode 100644 index 0000000000000000000000000000000000000000..f5b64156a136b6fbe9f1a194d2f233b1c981d3c2 --- /dev/null +++ b/src/main/resources/archetype-resources/src/test/java/AppTest.java @@ -0,0 +1,19 @@ +package $package; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Test; + +/** + * Unit test for simple App. + */ +class AppTest { + + /** + * Rigorous Test :-) + */ + @Test + void shouldAnswerWithTrue() { + assertTrue(true); + } +}