JavaFX 场景构建器 2:控制器类

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21060568/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 06:17:06  来源:igfitidea点击:

JavaFX scene builder 2: controller class

javajavafx-2scenebuilder

提问by jan behang

Hi im building a JavaFX project and am using JavaFX Scene Builder 2. I wanted to link my controller to my fxml file but i can't see the possibility to add a controller to my fxml file in Scene Builder 2. I was wondering if someone could help me out. Thank you.

嗨,我正在构建一个 JavaFX 项目并且正在使用 JavaFX Scene Builder 2。我想将我的控制器链接到我的 fxml 文件,但我看不到在 Scene Builder 2 中将控制器添加到我的 fxml 文件的可能性。我想知道是否有人可以帮助我。谢谢你。

采纳答案by jan behang

I found the controller attributes by accident in SceneBuilder 2. When closing the hierarchy menu on the left side the Controller menu will be visible where I can declare my controller

我在 SceneBuilder 2 中偶然发现了控制器属性。关闭左侧的层次结构菜单时,控制器菜单将可见,我可以在其中声明我的控制器

回答by jewelsea

Update

更新

This answer is obsolete. The solution is to use Gluon SceneBuilderand set the controller as specified in the screenshot provided in the most upvoted answer to this question.

这个答案已经过时了。解决方案是使用Gluon SceneBuilder按照此问题最受好评的答案中提供的屏幕截图中的指定设置控制器。



I HIGHLY recommend using Scene Builder 1.1 until Scene Builder 2 becomes more complete and reliable a few months from now.

我强烈建议使用 Scene Builder 1.1,直到几个月后 Scene Builder 2 变得更加完整和可靠。

When I recently used Scene Builder 2, it was still an unreliable, early access release.

当我最近使用 Scene Builder 2 时,它仍然是一个不可靠的早期访问版本。

Scene Builder 1.1 has a feature in the right hand code panel where you can set the controller class. Scene Builder 2 does not seem to have this feature. Therefore, if you use SceneBuilder 2, you will need to set the controller class manually as xxlali says. If, as you indicate, Scene Builder 2 early access sometimes removes your manually set controller class from the FXML file, then that would be one more reason to use a stable certified version rather than the immature early access version.

Scene Builder 1.1 在右侧代码面板中有一项功能,您可以在其中设置控制器类。Scene Builder 2 似乎没有这个功能。因此,如果您使用 SceneBuilder 2,您将需要像 xxlali 所说的那样手动设置控制器类。如果正如您所指出的,Scene Builder 2 早期访问有时会从 FXML 文件中删除您手动设置的控制器类,那么这将是使用稳定认证版本而不是不成熟的早期访问版本的另一个原因。

回答by Muhamet Aljobairi

As you see on the image the controller menu moved on the left , below the Library List. enter image description here

正如您在图像上看到的,控制器菜单移动到左侧,库列表下方。 在此处输入图片说明