7twenty7
7twenty7

Reputation: 568

Scene builder removes imports in fxml file

I use scene builder (Gluon Scene Builder - JavaFX Scene Builder 8.1.1) to create the UI of my application and develop JavaFX with Eclipse.

Now... every time I save something in scene builder it removes the imports of my own classes from the fxml file. Is there a way to tell scene builder that those classes belong to the project to avoid this behavior?

Upvotes: 3

Views: 1656

Answers (1)

José Pereda
José Pereda

Reputation: 45456

In order for SceneBuilder to deal with custom controls, you need to add the jar with your classes, so it can be loaded in its classpath.

If you don't add it, the imports on your FXML file can't be resolved, and SceneBuilder will remove them.

To add the jar, go to the Library panel on the top-left, and to the right of the Search field, click the little engine button. Select Import JAR/FXML Files..., find your jar and click import. You can select what components of that jar can be added.

Import jar

After that, the jar is added to a Custom Library Folder, that you can find clicking on the same engine button, and selecting Custom Library Folder->Reveal in Explorer.

If you make changes to your jar, make sure you update the version at that folder, either by importing it through that menu, or by copying it directly to that folder.

Upvotes: 4

Related Questions