Work in progress ...

This commit is contained in:
Konrad Neitzel
2025-11-30 18:58:05 +01:00
parent 9bbddaaae9
commit 5503dd192e
64 changed files with 4855 additions and 4252 deletions
@@ -3,9 +3,27 @@ package de.neitzel.fx.component.example;
import lombok.Getter;
import lombok.Setter;
/**
* Simple address model used in the FX example component.
*/
@Getter
@Setter
public class Address {
/**
* Street name and number.
*/
private String street;
/**
* City name.
*/
private String city;
/**
* Default constructor only
*/
public Address() {
// default constructor only
}
}
@@ -6,8 +6,32 @@ import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
/**
* Example JavaFX application demonstrating the {@link de.neitzel.fx.component.ComponentLoader} usage.
*/
public class ExampleApp extends Application {
/**
* Default constructor only
*/
public ExampleApp() {
// default constructor only
}
/**
* Launches the JavaFX application.
*
* @param args command line arguments
*/
public static void main(String[] args) {
launch(args);
}
/**
* Initializes sample model data, loads the FX component and shows the primary stage.
*
* @param primaryStage the primary stage for this application
*/
@Override
public void start(Stage primaryStage) throws Exception {
// Beispielmodel initialisieren
@@ -29,8 +53,4 @@ public class ExampleApp extends Application {
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch();
}
}
@@ -5,8 +5,17 @@ package de.neitzel.fx.component.example;
* taking care os Classloader Requirements of JavaFX. (Important when starting from inside NetBeans!)
*/
public class Main {
/**
* Default constructor only
*/
public Main() {
// default constructor only
}
/**
* Additional main methode to start Application.
*
* @param args Commandline Arguments.
*/
public static void main(String[] args) {
@@ -3,9 +3,27 @@ package de.neitzel.fx.component.example;
import lombok.Getter;
import lombok.Setter;
/**
* Simple person model used in the FX example component.
*/
@Getter
@Setter
public class Person {
/**
* The person's full name.
*/
private String name;
/**
* The address of the person.
*/
private Address address;
/**
* Default constructor only
*/
public Person() {
// default constructor only
}
}
@@ -6,23 +6,44 @@ import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Minimal JavaFX application launcher used by the examples.
*
* <p>This class initializes the JavaFX runtime, loads {@code MainWindow.fxml} and shows
* the primary stage. It is intended as a small bootstrap used by IDEs or test runs
* to start the JavaFX UI for demonstration purposes.
*/
public class JavaFXApp extends Application {
@Override
public void start(Stage primaryStage) {
try {
primaryStage.setTitle("Hello World!");
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("MainWindow.fxml"));
Parent root = fxmlLoader.load();
primaryStage.setScene(new Scene(root));
primaryStage.show();
} catch (Exception ex) {
System.out.println("Exception: " + ex.getMessage());
ex.printStackTrace();
}
}
private static final Logger LOGGER = Logger.getLogger(JavaFXApp.class.getName());
public static void main(String[] args) {
launch(args);
}
/**
* Default constructor only.
*
* <p>The constructor does not perform UI initialization. UI setup happens in {@link #start(Stage)}
* after JavaFX has set up the application thread.
*/
public JavaFXApp() {
// default constructor only
}
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
try {
primaryStage.setTitle("Hello World!");
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("MainWindow.fxml"));
Parent root = fxmlLoader.load();
primaryStage.setScene(new Scene(root));
primaryStage.show();
} catch (Exception ex) {
LOGGER.log(Level.SEVERE, "Exception while starting JavaFXApp", ex);
}
}
}
@@ -5,8 +5,26 @@ package de.neitzel.fx.injectfx.example;
* taking care os Classloader Requirements of JavaFX. (Important when starting from inside NetBeans!)
*/
public class Main {
/**
* Creates a new helper instance of {@code Main}.
*
* <p>This constructor is intentionally empty. The {@code Main} class serves as an alternative
* entry point to launch the JavaFX application via {@link JavaFXApp#main(String[])} in
* environments (IDEs, build tools) where directly starting a class that extends
* {@code javafx.application.Application} may fail due to classloader or JVM startup constraints.
*
* <p>Do not perform application initialization here; use the static {@code main} method to
* start the JavaFX runtime. This constructor exists to allow tooling and frameworks to
* instantiate the class reflectively if required.
*/
public Main() {
// default constructor only
}
/**
* Additional main methode to start Application.
*
* @param args Commandline Arguments.
*/
public static void main(String[] args) {
@@ -8,13 +8,49 @@ import javafx.scene.control.TextField;
import java.net.URL;
import java.util.ResourceBundle;
/**
* Controller for the MainWindow FXML view.
*
* <p>This class acts as the backing controller for the {@code MainWindow.fxml} UI. It demonstrates a
* minimal example of a JavaFX controller that:
* <ul>
* <li>receives UI element injection via {@link FXML} (the {@link #textField} field),</li>
* <li>initializes the view in {@link #initialize(URL, ResourceBundle)}, and</li>
* <li>handles user actions via {@link #onButtonClick(ActionEvent)}.</li>
* </ul>
*
* <p>Usage notes:
* <ul>
* <li>Fields annotated with {@link FXML} are injected by the {@code FXMLLoader} before
* {@link #initialize(URL, ResourceBundle)} is called — do not expect them to be non-null
* in the constructor.</li>
* <li>All UI updates must run on the JavaFX Application Thread. Methods called by FXML
* (such as {@link #onButtonClick(ActionEvent)}) are executed on that thread by the
* JavaFX runtime.</li>
* <li>The controller keeps a simple click counter and updates {@link #textField} to reflect
* the current count using {@link #displayCounter()}.</li>
* </ul>
*/
public class MainWindow implements Initializable {
/**
* Counter for button clicks shown in the UI.
*/
private int counter = 0;
/**
* Text field UI control showing the click counter.
*/
@FXML
private TextField textField;
/**
* Default constructor only
*/
public MainWindow() {
// default constructor only
}
@Override
public void initialize(URL location, ResourceBundle resources) {
displayCounter();
+2 -2
View File
@@ -2,9 +2,9 @@
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<AnchorPane xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
<AnchorPane xmlns:fx="http://javafx.com/fxml"
xmlns:nfx="http://example.com/nfx"
xmlns="http://javafx.com/javafx"
fx:controller="de.neitzel.fx.component.ComponentController"
prefWidth="300" prefHeight="100">
<children>
@@ -3,9 +3,11 @@
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<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.fx.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" />
</children>
<AnchorPane xmlns:fx="http://javafx.com/fxml/1" prefHeight="127.0" prefWidth="209.0"
xmlns="http://javafx.com/javafx/17.0.2-ea" fx:controller="de.neitzel.fx.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"/>
</children>
</AnchorPane>
+2 -2
View File
@@ -3,9 +3,9 @@
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.Pane?>
<AnchorPane xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
<AnchorPane xmlns:fx="http://javafx.com/fxml"
xmlns:nfx="http://example.com/nfx"
xmlns="http://javafx.com/javafx"
fx:controller="de.neitzel.fx.component.ComponentController"
prefWidth="300" prefHeight="180">
<children>