I know that I can load an FXML file into a Parent object with the following:
parent = FXMLLoader.load(getClass().getResource(fxmlFile.getAbsolutePath()));
Now I want to do the exact opposite and save a Parent object as the root of an FXML file.
Does anyone know how to accomplish this?
There is currently no public API which allows the serialization of a generic JavaFX object into FXML. It is also far from trivial to implement such a thing, because it is not known at runtime which values should be initialized where and so on.
The JavaFX SceneBuilder uses a mechanism to serialize to FXML to implement drag & drop functionality, but the code for this is quite heavy.
See:
https://forums.oracle.com/forums/thread.jspa?messageID=10377102
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With