First try to build some component based solution.
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
<link.name>${project.artifactId}</link.name>
|
||||
<launcher>${project.artifactId}</launcher>
|
||||
<appName>${project.artifactId}</appName>
|
||||
<main.class>de.neitzel.injectfx.example.Main</main.class>
|
||||
<main.class>de.neitzel.neitzelfx.injectfx.example.Main</main.class>
|
||||
<jar.filename>${project.artifactId}-${project.version}</jar.filename>
|
||||
</properties>
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package de.neitzel.neitzelfx.component.example;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class Address {
|
||||
private String street;
|
||||
private String city;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package de.neitzel.neitzelfx.component.example;
|
||||
|
||||
import de.neitzel.neitzelfx.component.ComponentLoader;
|
||||
import javafx.application.Application;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
public class ExampleApp extends Application {
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
// Beispielmodel initialisieren
|
||||
Address address = new Address();
|
||||
address.setStreet("Sample Street 1");
|
||||
address.setCity("Sample City");
|
||||
|
||||
Person person = new Person();
|
||||
person.setName("Max Mustermann");
|
||||
person.setAddress(address);
|
||||
|
||||
// ComponentLoader verwenden
|
||||
ComponentLoader loader = new ComponentLoader();
|
||||
Parent root = loader.load(person, "/person.fxml");
|
||||
|
||||
// Scene erstellen und anzeigen
|
||||
Scene scene = new Scene(root);
|
||||
primaryStage.setTitle("ComponentLoader Example");
|
||||
primaryStage.setScene(scene);
|
||||
primaryStage.show();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
launch();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package de.neitzel.neitzelfx.component.example;
|
||||
|
||||
import de.neitzel.neitzelfx.injectfx.example.JavaFXApp;
|
||||
|
||||
/**
|
||||
* Another Main class as workaround when the JavaFX Application ist started without
|
||||
* taking care os Classloader Requirements of JavaFX. (Important when starting from inside NetBeans!)
|
||||
*/
|
||||
public class Main {
|
||||
/**
|
||||
* Additional main methode to start Application.
|
||||
* @param args Commandline Arguments.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
ExampleApp.main(args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package de.neitzel.neitzelfx.component.example;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class Person {
|
||||
private String name;
|
||||
private Address address;
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package de.neitzel.injectfx.example;
|
||||
package de.neitzel.neitzelfx.injectfx.example;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package de.neitzel.injectfx.example;
|
||||
package de.neitzel.neitzelfx.injectfx.example;
|
||||
|
||||
/**
|
||||
* Another Main class as workaround when the JavaFX Application ist started without
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package de.neitzel.injectfx.example;
|
||||
package de.neitzel.neitzelfx.injectfx.example;
|
||||
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
|
||||
<AnchorPane xmlns="http://javafx.com/javafx"
|
||||
xmlns:fx="http://javafx.com/fxml"
|
||||
xmlns:nfx="http://example.com/nfx"
|
||||
fx:controller="de.neitzel.neitzelfx.component.ComponentController"
|
||||
prefWidth="300" prefHeight="100">
|
||||
<children>
|
||||
<TextField layoutX="10" layoutY="10" prefWidth="280"
|
||||
nfx:target="street" nfx:direction="bidirectional"/>
|
||||
<TextField layoutX="10" layoutY="50" prefWidth="280"
|
||||
nfx:target="city" nfx:direction="bidirectional"/>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
|
||||
<AnchorPane prefHeight="127.0" prefWidth="209.0" xmlns="http://javafx.com/javafx/17.0.2-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.neitzel.injectfx.example.MainWindow">
|
||||
<AnchorPane prefHeight="127.0" prefWidth="209.0" xmlns="http://javafx.com/javafx/17.0.2-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.neitzel.neitzelfx.injectfx.example.MainWindow">
|
||||
<children>
|
||||
<Button fx:id="button" layoutX="44.0" layoutY="70.0" mnemonicParsing="false" onAction="#onButtonClick" text="Click Me" />
|
||||
<TextField fx:id="textField" layoutX="14.0" layoutY="24.0" />
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
|
||||
<AnchorPane xmlns="http://javafx.com/javafx"
|
||||
xmlns:fx="http://javafx.com/fxml"
|
||||
xmlns:nfx="http://example.com/nfx"
|
||||
fx:controller="de.neitzel.neitzelfx.component.ComponentController"
|
||||
prefWidth="300" prefHeight="180">
|
||||
<children>
|
||||
<TextField layoutX="10" layoutY="10" prefWidth="280"
|
||||
nfx:target="name" nfx:direction="bidirectional"/>
|
||||
<Pane layoutX="10" layoutY="50" prefWidth="280" prefHeight="110"
|
||||
nfx:target="address" nfx:direction="bidirectional"
|
||||
nfx:source="/address.fxml"/>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
Reference in New Issue
Block a user