告诉JavaFX Scene Builder在哪里寻找控制器类 [英] Tell JavaFX Scene Builder where to look for controller classes

查看:647
本文介绍了告诉JavaFX Scene Builder在哪里寻找控制器类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Oracle的 JavaFX Scene Builder 中,可以指定将哪个Java类用作场景的控制器.它的成员变量将由FXMLLoader以及控件的实例填充.如果FXML文件与Java文件位于同一目录中,则Scene Builder可以自动建议用作控制器的类,然后从那里建议应在其中引用特定控件实例的成员变量的名称.放置.

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.

使用 Maven 作为构建工具时,资源文件(例如FXML文件)与源文件(例如Java文件)放置在不同的目录中.因此,Scene Builder无法找到Java文件并检查是否具有合适的属性.

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.

是否有通往Scene Builder的途径,它应该在其中寻找Java文件进行检查?

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

推荐答案

到目前为止,这是不可能的.将来有功能要求添加功能:

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

作为一种解决方法,您可以配置maven-resources-plugin以将您的源目录包含为资源目录:

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 /

如果您使用的是Gradle和Intellij IDEA 13,请注意以下问题:

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

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

这篇关于告诉JavaFX Scene Builder在哪里寻找控制器类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆