Reputation: 190
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?
Upvotes: 5
Views: 411
Reputation: 6574
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
Upvotes: 2