本文整理汇总了Java中javafx.beans.Observable.addListener方法的典型用法代码示例。如果您正苦于以下问题:Java Observable.addListener方法的具体用法?Java Observable.addListener怎么用?Java Observable.addListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.beans.Observable
的用法示例。
在下文中一共展示了Observable.addListener方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onChange
import javafx.beans.Observable; //导入方法依赖的package包/类
/** fires handler if any of the observables change */
public static void onChange(Runnable handler, boolean immediately, Observable ... props)
{
// Helper li = new Helper(handler);
for(Observable p: props)
{
// p.addListener(li);
// weak listener gets collected... but why??
p.addListener((src) -> handler.run());
}
if(immediately)
{
handler.run();
}
}
示例2: addBinding
import javafx.beans.Observable; //导入方法依赖的package包/类
public final void addBinding(Observable... dependencies)
{
if ((dependencies != null) && (dependencies.length > 0))
{
if (observer == null)
{
observer = new BindingHelperObserver(this);
}
for (final Observable dep : dependencies)
{
dep.addListener(observer);
listeningTo.add(dep);
}
invalidate();
}
}
示例3: listen
import javafx.beans.Observable; //导入方法依赖的package包/类
/** adds an invalidation listener to an observable */
public static void listen(Runnable handler, boolean fireImmediately, Observable prop)
{
prop.addListener((src) -> handler.run());
if(fireImmediately)
{
handler.run();
}
}
示例4: WeakListener
import javafx.beans.Observable; //导入方法依赖的package包/类
public WeakListener(Observable[] props, Runnable r)
{
this.props = props;
this.ref = new WeakReference<>(r);
for(Observable p: props)
{
p.addListener(this);
}
}
示例5: bind
import javafx.beans.Observable; //导入方法依赖的package包/类
public void bind(Observable... dependencies) {
if ((dependencies != null) && (dependencies.length > 0)) {
for (Observable dep : dependencies) {
dep.addListener(observer);
}
}
}
示例6: weakBind
import javafx.beans.Observable; //导入方法依赖的package包/类
private void weakBind(Runnable doBind, Node bindedNode, String propertyName, Observable... dependencies) {
InvalidationListener listener = new DependenciesInvalidationListener(doBind, dependencies);
WeakInvalidationListener weakListener = new WeakInvalidationListener(listener);
Object prev = bindedNode.getProperties().put(propertyName, listener);
Object prevWeak = bindedNode.getProperties().put(propertyName + ".weak", weakListener);
if (prev instanceof DependenciesInvalidationListener) {
for (Observable observable : ((DependenciesInvalidationListener) prev).dependencies) {
observable.removeListener((InvalidationListener) prevWeak);
}
}
for (Observable dep : dependencies) {
dep.addListener(weakListener);
}
doBind.run();
}
示例7: FxInvalidationListener
import javafx.beans.Observable; //导入方法依赖的package包/类
public FxInvalidationListener(Observable prop, boolean immediate, Runnable handler)
{
this.handler = handler;
prop.addListener(this);
if(immediate)
{
handler.run();
}
}
示例8: invalidationsOf
import javafx.beans.Observable; //导入方法依赖的package包/类
/**
* Creates an event stream that emits an impulse on every invalidation
* of the given observable.
*/
public static EventStream<Void> invalidationsOf(Observable observable) {
return new EventStreamBase<Void>() {
@Override
protected Subscription observeInputs() {
InvalidationListener listener = obs -> emit(null);
observable.addListener(listener);
return () -> observable.removeListener(listener);
}
};
}
示例9: subscribeToCell
import javafx.beans.Observable; //导入方法依赖的package包/类
/**
* Add an InvalidationListener to a certain cell.
*
* @param c The cell to add a listener to
*/
private void subscribeToCell(C c) {
for (Observable observable : extractor.call(c)) {
observable.addListener(this::listenRowInvalidation);
}
}
示例10: addListener
import javafx.beans.Observable; //导入方法依赖的package包/类
@Override
protected void addListener(Observable observable, InvalidationListener listener)
{
observable.addListener(listener);
}