- java.lang.Object
-
- javafx.beans.binding.StringExpression
-
- javafx.beans.property.ReadOnlyStringProperty
-
- javafx.beans.property.StringProperty
-
- All Implemented Interfaces:
-
Observable,Property<String>,ReadOnlyProperty<String>,ObservableObjectValue<String>,ObservableStringValue,ObservableValue<String>,WritableObjectValue<String>,WritableStringValue,WritableValue<String>
- 已知直接子类:
-
JavaBeanStringProperty,StringPropertyBase
public abstract class StringProperty extends ReadOnlyStringProperty implements Property<String>, WritableStringValue
该类提供了一个包含String值的Property的完整实现。 a的值StringProperty可以获取和设置ObservableObjectValue.get(),StringExpression.getValue(),WritableObjectValue.set(Object),并setValue(String)。 可以使用Property.bind(ObservableValue)和Property.unbind()绑定和绑定一个属性。 可以使用bindBidirectional(Property)和unbindBidirectional(Property)创建和删除双向绑定。StringProperty的上下文可以用ReadOnlyProperty.getBean()和ReadOnlyProperty.getName()读取。- 从以下版本开始:
- JavaFX 2.0
- 另请参见:
-
ObservableStringValue,WritableStringValue,ReadOnlyStringProperty,Property
-
-
构造方法摘要
构造方法 Constructor 描述 StringProperty()
-
方法摘要
所有方法 接口方法 具体的方法 Modifier and Type 方法 描述 voidbindBidirectional(Property<?> other, Format format)在这个StringProperty和另一个任意属性之间创建双向绑定。voidbindBidirectional(Property<String> other)在这个Property之间创建一个双向绑定。<T> voidbindBidirectional(Property<T> other, StringConverter<T> converter)在这个StringProperty和另一个任意属性之间创建双向绑定。voidsetValue(String v)设置包装的值。StringtoString()返回此StringProperty对象的字符串表示形式。voidunbindBidirectional(Object other)删除此Property和另一个之间的双向绑定。voidunbindBidirectional(Property<String> other)删除此Property和另一个之间的双向绑定。-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface javafx.beans.Observable
addListener, removeListener
-
Methods inherited from interface javafx.beans.value.ObservableObjectValue
get
-
Methods inherited from interface javafx.beans.value.ObservableValue
addListener, getValue, removeListener
-
Methods inherited from interface javafx.beans.property.ReadOnlyProperty
getBean, getName
-
Methods inherited from class javafx.beans.binding.StringExpression
concat, getValue, getValueSafe, greaterThan, greaterThan, greaterThanOrEqualTo, greaterThanOrEqualTo, isEmpty, isEqualTo, isEqualTo, isEqualToIgnoreCase, isEqualToIgnoreCase, isNotEmpty, isNotEqualTo, isNotEqualTo, isNotEqualToIgnoreCase, isNotEqualToIgnoreCase, isNotNull, isNull, length, lessThan, lessThan, lessThanOrEqualTo, lessThanOrEqualTo, stringExpression
-
Methods inherited from interface javafx.beans.value.WritableObjectValue
get, set
-
Methods inherited from interface javafx.beans.value.WritableValue
getValue
-
-
-
-
方法详细信息
-
setValue
public void setValue(String v)
设置包装的值。- Specified by:
-
setValue在接口WritableValue<String> - 参数
-
v- 新值
-
bindBidirectional
public void bindBidirectional(Property<String> other)
在这个Property和另一个之间创建双向绑定。 双向绑定与单向绑定无关。 因此,可以向具有双向绑定的属性添加单向绑定,反之亦然。 但是,这种做法是不鼓励的。可以有一个属性的多个双向绑定。
JavaFX双向绑定实现使用弱侦听器。 这意味着双向绑定不会阻止属性被垃圾回收。
- Specified by:
-
bindBidirectional在接口Property<String> - 参数
-
other- 其他Property
-
bindBidirectional
public void bindBidirectional(Property<?> other, Format format)
在这个StringProperty和另一个任意属性之间创建双向绑定。 依赖于实现Format进行转换。- 参数
-
other- 其他Property -
format-Format用于转换此StringProperty和其他Property - 异常
-
NullPointerException- 如果other或format是null -
IllegalArgumentException- 如果other是this - 从以下版本开始:
- JavaFX 2.1
-
bindBidirectional
public <T> void bindBidirectional(Property<T> other, StringConverter<T> converter)
在这个StringProperty和另一个任意属性之间创建双向绑定。 依赖于实现StringConverter进行转换。- 参数类型
-
T- 包装的类型Object - 参数
-
other- 其他Property -
converter-StringConverter用于转换此StringProperty和其他Property - 异常
-
NullPointerException- 如果other或converter是null -
IllegalArgumentException- 如果other是this - 从以下版本开始:
- JavaFX 2.1
-
unbindBidirectional
public void unbindBidirectional(Property<String> other)
删除此Property和另一个之间的双向绑定。 如果不存在属性之间的双向绑定,则调用此方法不起作用。 可以通过第二个属性的调用解除绑定。 此代码将工作:property1.bindBirectional(property2); property2.unbindBidirectional(property1);- Specified by:
-
unbindBidirectional在接口Property<String> - 参数
-
other- 其他Property
-
unbindBidirectional
public void unbindBidirectional(Object other)
删除此Property和另一个之间的双向绑定。 如果不存在属性之间的双向绑定,则调用此方法不起作用。- 参数
-
other- 其他Property - 异常
-
NullPointerException- 如果other是null -
IllegalArgumentException- 如果other是this - 从以下版本开始:
- JavaFX 2.1
-
toString
public String toString()
返回此StringProperty对象的字符串表示形式。- 重写:
-
toString中的ReadOnlyStringProperty - 结果
-
这个
StringProperty对象的字符串表示形式。
-
-