打字猴:1.700482826e+09
1700482826 }
1700482827
1700482828 }
1700482829
1700482830 这里定义了4个事件类型,分别是新建、修改、删除以及克隆,比较简单。我们再来看产品的事件,如代码清单36-4所示。
1700482831
1700482832 代码清单36-4 产品事件
1700482833
1700482834 public class ProductEvent extends Observable{
1700482835
1700482836 //事件起源
1700482837
1700482838 private Product source;
1700482839
1700482840 //事件的类型
1700482841
1700482842 private ProductEventType type;
1700482843
1700482844 //传入事件的源头,默认为新建类型
1700482845
1700482846 public ProductEvent(Product p){
1700482847
1700482848 this(p,ProductEventType.NEW_PRODUCT);
1700482849
1700482850 }
1700482851
1700482852 //事件源头以及事件类型
1700482853
1700482854 public ProductEvent(Product p,ProductEventType_type){
1700482855
1700482856 this.source=p;
1700482857
1700482858 this.type=_type;
1700482859
1700482860 //事件触发
1700482861
1700482862 notifyEventDispatch();
1700482863
1700482864 }
1700482865
1700482866 //获得事件的始作俑者
1700482867
1700482868 public Product getSource(){
1700482869
1700482870 return source;
1700482871
1700482872 }
1700482873
1700482874 //获得事件的类型
1700482875
[ 上一页 ]  [ :1.700482826e+09 ]  [ 下一页 ]