本文整理匯總了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);
}