简体   繁体   English

在Java中传播事件

[英]Propagate events in java

If we have a class in Java responsilbe for building interfaces (builder), it builds an interface which the user interacts with (interface 1 )and the user clicks a button which does some processing using a calculation class. 如果我们在Java responsilbe中有一个用于构建接口的类(构建器),它将构建一个与用户进行交互的接口(接口1),并且用户单击一个按钮,该按钮将使用计算类进行一些处理。

Is there anyway of knowing when this processing is complete from the builder class so it can proceed to build the second interfce and hide/close the original? 无论如何,是否要从builder类中知道此处理何时完成,以便它可以继续构建第二个接口并隐藏/关闭原始接口?

I was thinking the interface could throw an event which can be listended for in the interface builder class. 我以为接口可能会引发一个事件,该事件可以在接口构建器类中列出。

Is there a more appropriate way of doing this? 有更合适的方法吗?

A builder class should just build. 一个构建器类应该构建。

If you need something to listen for events and react by hiding or closing something and building something else, that sounds much more like a controller in Model-View-Controller or a related pattern. 如果您需要某些东西来监听事件并通过隐藏或关闭某些东西并构建其他东西来做出反应,这听起来更像是Model-View-Controller中的控制器或相关模式。 This controller would likely call the builder whenever it needs to close a view and present a new view, and it would be the recipient of such events. 每当需要关闭视图并显示新视图时,此控制器可能会调用构建器,并且它将是此类事件的接收者。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM