[英]JavaFx Communicating between controllers
I am trying to send data from one controller to another and I decide to inherit the scene class with one of my controller so when I create the second scene I can pass it through an overloaded constructor that was extended. 我试图将数据从一个控制器发送到另一个控制器,并决定用一个控制器继承场景类,因此当我创建第二个场景时,可以将其传递给扩展的重载构造函数。
Is it correct for a controller class to inherit Scene class? 控制器类继承Scene类是否正确?
Otherwise please suggest a more efficient way to communicate between controllers. 否则,请提出一种更有效的控制器之间通信方式。
Controller class should be separated from gui class. 控制器类应与gui类分开。 In mvc pattern there are three layers: model, controller and view.
在mvc模式中,分为三层:模型,控制器和视图。
View - gui class that extends Scene or other ui component. View-扩展Scene或其他ui组件的gui类。
Controller - listener class that catches events made by user 控制器-捕获用户产生的事件的侦听器类
Model - holds data of program. 模型-保存程序数据。 Like username,password
像用户名,密码
You can also create separate classes to perform operations(add,subtract) of data in model 您还可以创建单独的类来执行模型中数据的操作(加,减)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.