Reputation:
I have an javafx application which let's the user to add as much as buttons he/she wants.
I load my main scene root from an fxml
file which contains the default user-interface.
As the user changes the interface, I change the scene using @FXML
annotation.
This changes are temporary and the user interface will be same as what it was, in the next time application run. So here's my question:
How can I save the changes made to interface of the application during runtime to a new fxml
file?
Upvotes: 2
Views: 857
Reputation: 1768
A FXML File is a xml File so you can Write with Any XML Libary.
But i would recommend to save the Buttons in a json or properties file, and add them back over Code.
So if the Applications stops save the Buttons to the File and if the Applications starts again add them to the Scene, this is much easier as saving them into an FXML File.
But if you realy want to do this with FXML take a look at https://bitbucket.org/gluon-oss/scenebuilder maybe you can use some of the Code from the SceneBuilder to save your scene as an FXML.
Upvotes: 2