It is possible to use FXML to load non-GUI objects into memory? For example, I am creating a simple "voting" software for my school. All it needs is the list of "elective-posts" and the corresponding candidates along with other things like sets of "properties" of the posts and candidates.
What I want to do is, that I write the data in a FXML file and then load it using a FXMLLoader
.
Yes, FXML can be used to create arbitrary objects. You'd define the objects just like you would any GUI object. You just have to make sure that:
setField
then in the FXML the attribute would befield="value"
NamedArg
Here's a small example.
Animal.java
Main.java
Main.fxml
Running
Main
prints the following: