Saving user interface into fxml : javafx

老子叫甜甜 提交于 2019-12-10 19:55:36

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/27874110/saving-user-interface-into-fxml-javafx

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!