Multiple controller for one FXML file

人走茶凉 提交于 2019-12-01 06:27:12

I recommend to create custom controls - use several smaller FXML files rather than one big FXML file.

Here is the tutorial:

http://docs.oracle.com/javafx/2/fxml_get_started/custom_control.htm

During the loading of your FXML markup, there is only the provision to have one controller specified for your scene graph. You are able to load other FXML markup files and nest controllers, but I don't think that's what you're asking.

To my mind, it doesn't matter anyway.

You can write any number of classes in any number of files and have them interact with your controller class just like any Java class can interact with any other Java class.

I really can't think of any particularly good reason why it would be useful to specify multiple controllers for a scene graph at load time.

You can add an fxml file as a node into another fxml , both with diferent controllers with include option in scene builder

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