项目作者: Naoghuman
项目描述 :
`Lib-FXML`库简化了[JavaFX]相关文件(模型,视图,控制器,.fxml,.css,.properties)的加载,并实现了对gui(in,from)的数据流的标准化处理。
高级语言: Java
项目地址: git://github.com/Naoghuman/lib-fxml.git
Lib-FXML



Intention
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.
Image: Overview Lib-FXML

Content
" class="reference-link">Demo ‘All in Ones’
Image: Demo ‘All in Ones’

" class="reference-link">Intention
This demo wants to show, explain how to integrate the various features from the library Lib-FXML
into a demo application:
" class="reference-link">General features
- 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.
" class="reference-link">Extended features
- 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.
" class="reference-link">Additional features
" class="reference-link">Demo files
In this section all files are listed which are involved into this demo. Also their main purpose are explained:
" class="reference-link">DemoAllInOnes.java
- 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.
" class="reference-link">DemoAllInOnesController.java
- 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.
" class="reference-link">DemoAllInOnesEntity.java
- 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.
" class="reference-link">DemoAllInOnesSqlEntityProvider.java
- Shows how to define a simple
sql
entity provider which simulates the crud
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.
" class="reference-link">demoallinones.css
- 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.
" class="reference-link">demoallinones.fxml
- Shows how to define a declaration from the demo gui in form from a special JavaFX
XML
file so called FXML
. - Shows how then the initialization will be done during the loading and mapping from the
.fxml
file with the corresponding controller
.
See FXMLView#initializeFXMLLoader(FXMLModel) for more informations.
" class="reference-link">demoallinones.properties
- Shows how to create a
.properties
file which can contains different key/value
String pairs. Over the key
the value
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 actual Locale
.
The next files are used to create the demo informations:
" class="reference-link">DemoInfoWriter.java
- 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.
" class="reference-link">DemoAllInOnesInfoWriter.java
- 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.
" class="reference-link">DemoAllInOnesPreferencesWriter.java
- Another concrete implementation from the abstract class ‘DemoInfoWriter’.
- With this class the interactive area on the right side in the demo application is written.
" class="reference-link">How it works
This section shows how to use the different classes and interfaces from the Lib-FXML
api:
" class="reference-link">Usage from the singleton class ‘FXMLAction’
- Used in ‘DemoAllInOnes’, ‘DemoAllInOnesController’, ‘DemoAllInOnesInfoWriter’ and ‘DemoAllInOnesSqlEntityProvider’.
- Answers the question how to implement a
singleton
instance with Optional 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.
- Answers also the question how to register (handle) action methods from type EventHandler.
" class="reference-link">Usage from the abstract class ‘FXMLController’
- 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.
" class="reference-link">Usage from the class ‘FXMLModel’
- 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.
" class="reference-link">Usage from the class ‘FXMLView’
- 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.
" class="reference-link">Usage from the interface ‘FXMLModelable’
- Used in ‘DemoAllInOnesEntity’.
- Answers the question how to use the interface as a convention to initialize a FXMLModel with different entity properties.
" class="reference-link">Usage from the interface ‘FXMLRegisterable’
- 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.
" class="reference-link">JavaDoc
The JavaDoc from the library Lib-FXML
can be explored here: JavaDoc Lib-FXML (in work)
Image: JavaDoc Lib-FXML v0.3.0-PRERELEASE

" class="reference-link">Download
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:
An overview
about all existings releases can be found here:
" class="reference-link">Requirements
In the library following dependencies are registered:
" class="reference-link">Installation
" class="reference-link">Contribution
- 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.
" class="reference-link">License
The project Lib-FXML
is licensed under General Public License 3.0.
" class="reference-link">Autor
The project Lib-FXML
is maintained by me, Naoghuman (Peter Rogge). See Contact.
You can reach me under peter.rogge@yahoo.de.