Tell JavaFX Scene Builder where to look for controller classes

邮差的信 提交于 2019-12-20 14:42:01

问题


In Oracle's JavaFX Scene Builder it is possible to specify which Java class will be used as the controller for a scene. It's member variables will be populated by the FXMLLoader with instances of the controls. If the FXML file is in the same directory as the Java files, the Scene Builder can automatically suggest the class to use as controller, and from there, suggest the names of member variables in which a reference to the instance of a specific control should be placed.

When using Maven as a build tool, resource files (like the FXML files) are placed in a different directory than source files (like the Java files). Because of this, the Scene Builder is unable to find the Java file and inspect if for suitable properties.

Is there a ways to the the Scene Builder, where it should look for Java files to inspect?


回答1:


As of right now, this is not possible. There's a feature request to add the functionality in the future:

https://javafx-jira.kenai.com/browse/DTL-5124

As a workaround, you might be able to configure the maven-resources-plugin to include your source directory as a resource directory:

http://maven.apache.org/plugins/maven-resources-plugin/

If you're using Gradle and Intellij IDEA 13, be aware of this issue:

http://youtrack.jetbrains.com/issue/IDEA-118280#comment=27-654638




回答2:


I've shared an example for usage of maven-resources-plugin in maven-java-fx projects at below link.

https://stackoverflow.com/a/33057082/2017822 [JavaFx scenebuilder and Maven Integration]



来源:https://stackoverflow.com/questions/20523567/tell-javafx-scene-builder-where-to-look-for-controller-classes

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