本文整理匯總了Java中javafx.beans.value.ObservableValue.addListener方法的典型用法代碼示例。如果您正苦於以下問題:Java ObservableValue.addListener方法的具體用法?Java ObservableValue.addListener怎麽用?Java ObservableValue.addListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.beans.value.ObservableValue
的用法示例。
在下文中一共展示了ObservableValue.addListener方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: nestValue
import javafx.beans.value.ObservableValue; //導入方法依賴的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: nestListProp
import javafx.beans.value.ObservableValue; //導入方法依賴的package包/類
public static <F, T> ListProperty<T> nestListProp(ObservableValue<F> pf, Function<F, ListProperty<T>> func) {
ListProperty<T> current = func.apply(pf.getValue());
ListProperty<T> nestProp = new SimpleListProperty<>();
CacheUtil.set(BeanUtil.class, nestProp, current);
nestProp.bindBidirectional(current);
pf.addListener((ob, o, n) -> {
CacheUtil.<ListProperty<T>> remove(BeanUtil.class, nestProp).ifPresent(p -> nestProp.unbindContentBidirectional(p));
ListProperty<T> pt = func.apply(n);
CacheUtil.set(BeanUtil.class, nestProp, pt);
nestProp.bindContentBidirectional(pt);
});
return nestProp;
}
示例3: nestListValue
import javafx.beans.value.ObservableValue; //導入方法依賴的package包/類
public static <F, T> ObservableList<T> nestListValue(ObservableValue<F> pf, Function<F, ObservableList<T>> func) {
ObservableList<T> current = func.apply(pf.getValue());
ListProperty<T> nestProp = new SimpleListProperty<>();
CacheUtil.set(BeanUtil.class, nestProp, current);
nestProp.bindContent(current);
pf.addListener((ob, o, n) -> {
CacheUtil.<ListProperty<T>> remove(BeanUtil.class, nestProp).ifPresent(p -> nestProp.unbindContent(p));
ObservableList<T> pt = func.apply(n);
CacheUtil.set(BeanUtil.class, nestProp, pt);
nestProp.bindContent(pt);
});
return nestProp;
}
示例4: setObservableVariable
import javafx.beans.value.ObservableValue; //導入方法依賴的package包/類
/**
* The variable will be automatically updated when the value changes
* @see Formatter#setVariable(String, String)
* @param var Variable
* @param observable Observable property
*/
public void setObservableVariable(String var, ObservableValue<?> observable) {
setVariable(var, observable.getValue().toString());
observable.addListener(o -> {
if(additionalVariables.containsKey(var)) {
setVariable(var, observable.getValue().toString());
}
});
}
示例5: FunctionBasedValidator
import javafx.beans.value.ObservableValue; //導入方法依賴的package包/類
private FunctionBasedValidator(ObservableValue<T> source) {
source.addListener((observable, oldValue, newValue) -> {
validate(newValue);
});
}
示例6: bindModified
import javafx.beans.value.ObservableValue; //導入方法依賴的package包/類
public void bindModified(ObservableValue<?>... ovs) {
for (ObservableValue<?> ov : ovs) {
ov.addListener((observable, o, n) -> modified());
}
}
示例7: bind
import javafx.beans.value.ObservableValue; //導入方法依賴的package包/類
/**
* Binds the atomic property to an observable value.
*
* @see Property#bind(ObservableValue)
*/
public void bind(ObservableValue<? extends T> observableValue) {
Objects.requireNonNull(observableValue, "Cannot bind to a null observable");
bound = new WeakReference<>(observableValue);
observableValue.addListener(bindingListener);
}
示例8: register
import javafx.beans.value.ObservableValue; //導入方法依賴的package包/類
public static void register(Subroutine function, ObservableValue<State> target)
{
OnLoadListener listener = new OnLoadListener(function);
listener.observable = target;
target.addListener(listener);
}
示例9: addRule
import javafx.beans.value.ObservableValue; //導入方法依賴的package包/類
/**
* Add a rule for this validator.
* <p>
* The rule defines a condition that has to be fulfilled.
* <p>
* A rule is defined by an observable boolean value. If the rule has a value of <code>true</code> the rule is
* "fulfilled". If the rule has a value of <code>false</code> the rule is violated. In this case the given message
* object will be added to the status of this validator.
* <p>
* There are some predefined rules for common use cases in the {@link ObservableRules} class that can be used.
*
* @param rule
* @param message
*/
public void addRule(ObservableValue<Boolean> rule, ValidationMessage message) {
rules.add(rule);
rule.addListener((observable, oldValue, newValue) -> {
validateRule(newValue, message);
});
validateRule(rule.getValue(), message);
}
示例10: bind
import javafx.beans.value.ObservableValue; //導入方法依賴的package包/類
/**
* Binds an observable list to a list property.
*
* @param list the observable list to bind
* @param observable the property to bind to
* @param <T> the type of elements in the list
*/
public static <T> void bind(ObservableList<? super T> list,
ObservableValue<? extends List<? extends T>> observable) {
list.setAll(observable.getValue());
observable.addListener((__, oldList, newList) -> list.setAll(newList));
}