本文整理汇总了Java中javafx.beans.property.Property.bind方法的典型用法代码示例。如果您正苦于以下问题:Java Property.bind方法的具体用法?Java Property.bind怎么用?Java Property.bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.beans.property.Property
的用法示例。
在下文中一共展示了Property.bind方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: nestValue
import javafx.beans.property.Property; //导入方法依赖的package包/类
public static <F, T> ObservableValue<T> nestValue(ObservableValue<F> pf, Function<F, ObservableValue<T>> func) {
ObservableValue<T> current = func.apply(pf.getValue());
Property<T> nestProp = new SimpleObjectProperty<>();
nestProp.bind(current);
pf.addListener((ob, o, n) -> {
ObservableValue<T> pt = func.apply(n);
nestProp.unbind();
nestProp.bind(pt);
});
return nestProp;
}
示例2: bindWithConverter
import javafx.beans.property.Property; //导入方法依赖的package包/类
/**
* Binds {@code firstProperty} to {@code secondProperty}, using a conversion function to map
* values of type {@code U} to {@code T} so the first property can be bound.
*
* @param firstProperty the property to bind
* @param secondProperty the property to bind to
* @param u2tConverter the conversion function
*/
public static <T, U> void bindWithConverter(
Property<T> firstProperty,
Property<U> secondProperty,
Function<U, T> u2tConverter) {
Binding<T> binding = EasyBind.monadic(secondProperty).map(u2tConverter);
bindings.put(firstProperty, binding);
firstProperty.bind(binding);
}
示例3: bind
import javafx.beans.property.Property; //导入方法依赖的package包/类
/**
* bind the value to the valueTo
*
* @param value
* @param valueTo
* @param biDirectional
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
protected void bind(Property value, Property valueTo, boolean biDirectional) {
if (valueTo != null) {
if (debug && value.isBound())
LOGGER.log(Level.WARNING, "value is already bound");
if (biDirectional)
value.bindBidirectional(valueTo);
else
value.bind(valueTo);
}
}
示例4: bind
import javafx.beans.property.Property; //导入方法依赖的package包/类
/**
* Binds a property to the value of an entry in a map.
*
* @param property the property to bind
* @param map the map to bind to
* @param key the key of the entry to bind to
* @param converter a function for converting map values to a type the property can accept
* @param <K> the type of keys in the map
* @param <V> the type of values in the map
* @param <T> the type of data in the property
*/
public static <K, V, T> void bind(Property<T> property,
ObservableMap<K, V> map,
K key,
Function<V, T> converter) {
property.bind(Bindings.createObjectBinding(() -> converter.apply(map.get(key)), map));
}