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文件的可能性。我想知道是否有人可以帮助我。谢谢。
3 个解决方案
#1
75
As you see on the image the controller menu moved on the left , below the Library List.
正如您在图像上看到的那样,控制器菜单在“库列表”下方的左侧移动。
#2
22
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中偶然发现了控制器属性。当关闭左侧的层次结构菜单时,Controller菜单将显示在我可以声明控制器的位置
#3
1
Update
This answer is obsolete. The solution is to use Gluon SceneBuilder and 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文件中删除您手动设置的控制器类,那么这将是使用稳定的认证版本而不是不成熟的早期访问版本的另一个原因。
#1
75
As you see on the image the controller menu moved on the left , below the Library List.
正如您在图像上看到的那样,控制器菜单在“库列表”下方的左侧移动。
#2
22
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中偶然发现了控制器属性。当关闭左侧的层次结构菜单时,Controller菜单将显示在我可以声明控制器的位置
#3
1
Update
This answer is obsolete. The solution is to use Gluon SceneBuilder and 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文件中删除您手动设置的控制器类,那么这将是使用稳定的认证版本而不是不成熟的早期访问版本的另一个原因。