eventhandler functions 事件处理函数
Listing 3 duplicates the earlier button selection example shown in Figure 1, using an EventHandler.
清单3重复了前面图1中的按钮选择例子,使用了一个EventHandler。
It would be even more object oriented if you replaced the last bits of the if statement with a Map connecting EventTypes to EventHandler factory objects.
要想进一步增强面向对象特性,可以将if语句的最后一小部分替换为Map,后者将EventType连接到EventHandler工厂对象。
Instead of creating a class that implements an interface and registering that implementation with the component whose event you are interested in, you create an EventHandler instance and register it.
它不是创建一个实现了接口的类、并将这个实现注册到需要监听的事件所在的组件上,而是创建一个EventHandler实例并注册它。
应用推荐