The Lib-FXML
library simplifies the loading of JavaFX relevant files (model,
view, controller, .fxml, .css, .properties) and enables a standardized handling
of the data flow to (in, from) the gui.
Inspired by Adam Bien's library afterburner.fx, which unfortunately hasn't been
developed since 2015, the library Lib-FXML
simplifies the daily developer tasks
in context from the aboved mentioned two main points:
- Simplifying the loading of
JavaFX
relevant files and - offering a standardized data flow to (in, from) the gui.
- Demo 'All in Ones'
- Intention
General features
Extended features
Additional features - Demo files
DemoAllInOnes.java
DemoAllInOnesController.java
DemoAllInOnesEntity.java
DemoAllInOnesSqlEntityProvider.java
demoallinones.css
demoallinones.fxml
demoallinones.properties
DemoInfoWriter.java
DemoAllInOnesInfoWriter.java
DemoAllInOnesPreferencesWriter.java - How it works
Usage from the singleton class 'FXMLAction'
Usage from the abstract class 'FXMLController'
Usage from the class 'FXMLModel'
Usage from the class 'FXMLView'
Usage from the interface 'FXMLModelable'
Usage from the interface 'FXMLRegisterable'
- Intention
- JavaDoc
- Download
- Requirements
- Installation
- Contribution
- License
- Autor
- Contact
This demo wants to show, explain how to integrate the various features from the library Lib-FXML
into a demo application:
- How to use the abstract class FXMLController as a convention to managed the presentation from the FXMLModel data in a concrete implementation from
FXMLController
. - How to use the class
FXMLModel
as a lightweight version from an entity to manage the dataflow to (in, from) the controller. - How to use the class FXMLView to load the gui declaration (.fxml file) and map it (initialization from the gui) to a controller.
- How to use the singleton FXMLAction to register (handle) lambda methods such like Consumer, Function and Supplier.
- (TODO) How to use the class FXMLModel to add additional methods which extend the original entity behavior. For example
#isUpdatedProperty()
. - How to use the interface FXMLRegisterable as a convention which allowes developers to register for example action methods.
- How to use the interface FXMLModelable as a convention to create a lightweight version from an entity.
- How to implement a
singleton
instance with Optional<T> in FXMLAction and access the class behaviours with the static method#getDefault()
. - How to use the JavaFX default binding features to automatically update the FXMLModel (entity) data to (in, from) the controller.
- How to use the
JavaFX
standard class FXMLLoader in FXMLView to load.fxml
,.css
,.properties
files and assoziate them with a controller. - How to style with
CSS
differentJavaFX
components such like AnchorPane, Button, TextField, ScrollPane. - How to use the library 'Lib-Logger' (https://github.com/Naoghuman/lib-logger) to log messages easily to a log-file.
In this section all files are listed which are involved into this demo. Also their main purpose are explained:
- Shows how to start a JavaFX application :) .
- Shows how to create an instance from the class FXMLView to show then the gui with 'view.getRoot().orElse(new AnchorPane)' in the demo application.
- Shows how the interface FXMLRegisterable can be used as a convention to register the action method from this class.
- Shows how the developer can access the URL from the
.fxml
file. - Shows how the developer can access the optional ResourceBundle if defined.
- Shows how to use the classes 'DemoInfoWriter', 'DemoAllInOnesInfoWriter' and 'DemoAllInOnesPreferencesWriter' to write the demo infos.
- Shows how to use the overriden method FXMLController#configure(FXMLModel) to bind the data from the
FXMLModel
to the gui components. - Shows how the interface FXMLRegisterable can be used as a convention to register the various action methods from this controller.
- Shows how to use the different
FXMLAction#handle(...)
methods to fit the necessities from this controller.
- Shows how to create a simple
POJO
with JavaFX properties (LongProperty and StringProperty). - Shows the usage from
JavaFX
properties to bind data which means we don't need to be aware that the data is up-to-date :). - Shows how to use the interface FXMLModelable which allowed to configure a FXMLModel with selected data properties from the entity.
- Shows how to define a simple
sql
entity provider which simulates thecrud
operations for an entity to (from) a database. - Shows how to use the interface FXMLRegisterable as a convention to register the action methods from this class.
- Shows how to use the class FXMLAction to register the (crud) action methods via lambda injection.
- Shows how to create a
CSS
(Cascading Style Sheets) file which styles will be then shown in the demo application. - Shows how to style with
CSS
different JavaFX components such like AnchorPane, Button, TextField, ScrollPane.
- Shows how to define a declaration from the demo gui in form from a special JavaFX
XML
file so calledFXML
. - Shows how then the initialization will be done during the loading and mapping from the
.fxml
file with the correspondingcontroller
.
See FXMLView#initializeFXMLLoader(FXMLModel) for more informations.
- Shows how to create a
.properties
file which can contains differentkey/value
String pairs. Over thekey
thevalue
can retrieved then in the application. - An alternative is the useage from my Library
Lib-I18N
(https://github.com/Naoghuman/lib-i18n), which allowed multilingualism depending from an actualLocale
.
The next files are used to create the demo informations:
- The abstract class 'DemoInfoWriter' offers various functions for writing different styled informations into a VBox.
- For example: Styled text (size, FontPosture), Buttons, Separators and TextFields.
- A concrete implementation from the abstract class 'DemoInfoWriter' for this demo.
- All informations about the features from the library
Lib-FXML
and the demo :) in the left side from the demo are written with this class.
- Another concrete implementation from the abstract class 'DemoInfoWriter'.
- With this class the interactive area on the right side in the demo application is written.
This section shows how to use the different classes and interfaces from the Lib-FXML
api:
- Used in 'DemoAllInOnes', 'DemoAllInOnesController', 'DemoAllInOnesInfoWriter' and 'DemoAllInOnesSqlEntityProvider'.
- Answers the question how to implement a
singleton
instance with Optional<T> in FXMLAction and access the class behaviours with the static method#getDefault()
. - Answers the question how to register (handle) action methods from type Consumer<FXMLModel>, EventHandler<ActionEvent> and Function<Long, FXMLModel>.
- Answers also the question how to register (handle) action methods from type EventHandler<ActionEvent>.
- Used in 'DemoAllInOnesController'.
- Used in FXMLView.
- Answers the question how to use the abstract class as a convention to managed the presentation from the FXMLModel data in a concrete controller.
- Answers the question how the controller (it's attributs) is the initialization from the declaration in the
.fxml
file.
- Used in 'DemoAllInOnes', 'DemoAllInOnesController', 'DemoAllInOnesEntity' and 'DemoAllInOnesSqlEntityProvider'.
- Used in FXMLAction, FXMLController, FXMLModelable and FXMLView.
- Answers the question how to use the model to managed the dataflow to (in, from) the gui.
- Answers the question how the FXMLModel will be initialized in the entity 'DemoAllInOnesEntity' with the convention methods from the interface
FXMLModelable
. - Answers the question how to add some additional data methods to extend the behavior from the original entity.
- Used in 'DemoAllInOnes'.
- Answers the question how to use the class FXMLView to load the gui declaration (.fxml file) and map it (initialization from the gui) to a controller.
- Answers the question how to use the JavaFX standard class FXMLLoader in
FXMLView
to load.fxml
,.css
,.properties
files and assoziate them with a controller.
- Used in 'DemoAllInOnesEntity'.
- Answers the question how to use the interface as a convention to initialize a FXMLModel with different entity properties.
- Used in 'DemoAllInOnes', 'DemoAllInOnesController' and 'DemoAllInOnesSqlEntityProvider'.
- Answers the question how to use the interface as a convention to register different action methods via
lambda
injection.
The JavaDoc from the library Lib-FXML
can be explored here: JavaDoc Lib-FXML (in work)
Image: JavaDoc Lib-FXML v0.3.0-PRERELEASE
Current version
is 0.3.0-PRERELEASE
. Main points in this release are:
- Extend the api with exciting features like FXMLAction, FXMLModel.
- Create an extended demo application with all features from the library.
Download:
- Release v0.3.0-PRERELEASE (04.23.2019 / MM.dd.yyyy)
An overview
about all existings releases can be found here:
- Overview from all releases in Lib-FXML.
- On your system you need JRE 8 or JDK 8 installed.
- The library lib-fxml-0.3.0-PRERELEASE.
In the library following dependencies are registered:
- The library lib-logger-0.6.0.jar.
- Included in
Lib-Logger
is the library log4j-api-2.10.0.jar. - Included is
Lib-Logger
is the library log4j-core-2.10.0.jar.
- Included in
- If not installed download the JRE 8 or the JDK 8.
- Optional: To work better with FXML files in a JavaFX application download the JavaFX Scene Builder under 'Additional Resources'.
- Choose your preferred IDE (e.g. NetBeans, Eclipse or IntelliJ IDEA) for development.
- Download or clone Lib-FXML.
- Download or clone Lib-Logger.
- Open the projects in your IDE and run them.
- If you find a
Bug
I will be glad if you could report an Issue. - If you want to contribute to the project plz fork the project and do a Pull Request.
The project Lib-FXML
is licensed under General Public License 3.0.
The project Lib-FXML
is maintained by me, Naoghuman (Peter Rogge). See Contact.
You can reach me under [email protected].