Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaFX 2 - Write Parent Object to FXML File

Tags:

fxml

javafx-2

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?

like image 792
CBK Avatar asked Nov 03 '22 11:11

CBK


1 Answers

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

like image 129
zhujik Avatar answered Nov 17 '22 08:11

zhujik