Most visited

Recently visited

Added in API level 3

PropertyChangeEvent

public class PropertyChangeEvent
extends EventObject

java.lang.Object
   ↳ java.util.EventObject
     ↳ java.beans.PropertyChangeEvent
Known Direct Subclasses


每当bean更改“绑定”或“约束”属性时,都会传递“PropertyChange”事件。 PropertyChangeEvent对象作为参数发送到PropertyChangeListener和VetoableChangeListener方法。

通常,PropertyChangeEvent伴随着名称以及已更改属性的旧值和新值。 如果新值是原始类型(如int或boolean),则必须将其封装为相应的java.lang。* Object类型(如Integer或Boolean)。

如果它们的真实值未知,则可以为旧值和新值提供空值。

事件源可能会发送一个空对象作为名称,以指示任意一组属性是否已更改。 在这种情况下,旧值和新值也应该为空。

Summary

Inherited fields

From class java.util.EventObject

Public constructors

PropertyChangeEvent(Object source, String propertyName, Object oldValue, Object newValue)

构造一个新的 PropertyChangeEvent

Public methods

Object getNewValue()

获取属性的新值,以对象表示。

Object getOldValue()

获取属性的旧值,以对象表示。

Object getPropagationId()

“propagationId”字段保留供将来使用。

String getPropertyName()

获取已更改的属性的编程名称。

void setPropagationId(Object propagationId)

设置事件的propagationId对象。

String toString()

返回对象的字符串表示形式。

Inherited methods

From class java.util.EventObject
From class java.lang.Object

Public constructors

PropertyChangeEvent

Added in API level 3
PropertyChangeEvent (Object source, 
                String propertyName, 
                Object oldValue, 
                Object newValue)

构造一个新的 PropertyChangeEvent

Parameters
source Object: The bean that fired the event.
propertyName String: The programmatic name of the property that was changed.
oldValue Object: The old value of the property.
newValue Object: The new value of the property.

Public methods

getNewValue

Added in API level 3
Object getNewValue ()

获取属性的新值,以对象表示。

Returns
Object The new value for the property, expressed as an Object. May be null if multiple properties have changed.

getOldValue

Added in API level 3
Object getOldValue ()

获取属性的旧值,以对象表示。

Returns
Object The old value for the property, expressed as an Object. May be null if multiple properties have changed.

getPropagationId

Added in API level 3
Object getPropagationId ()

“propagationId”字段保留供将来使用。 在Beans 1.0中,唯一的要求是如果一个监听器捕获一个PropertyChangeEvent,然后触发它自己的PropertyChangeEvent,那么它应该确保它将propagationId字段从它的传入事件传播到它的传出事件。

Returns
Object the propagationId object associated with a bound/constrained property update.

getPropertyName

Added in API level 3
String getPropertyName ()

获取已更改的属性的编程名称。

Returns
String The programmatic name of the property that was changed. May be null if multiple properties have changed.

setPropagationId

Added in API level 3
void setPropagationId (Object propagationId)

设置事件的propagationId对象。

Parameters
propagationId Object: The propagationId object for the event.

toString

Added in API level 3
String toString ()

返回对象的字符串表示形式。

Returns
String a string representation of the object

Hooray!