PropertyChangeEvent

JavaBean PropertyChangeEvent 事件使用

妖精的绣舞 提交于 2019-12-10 15:06:28
In this example we'll listen to bean's property change event. We create a small bean named MyBean , adds attributes and getter/setter. We want to know or to get notified when the bean property name is changed. First we need the add a PropertyChangeSupport field to the bean, with this object we will fire the property change event. When we need to listen for the change we have to create an implementation of a PropertyChangeListener . In this example we'll just use the MyBean class as the listener. The PropertyChangeListener has a method called propertyChange and inside this method we'll