當前位置: 首頁>>代碼示例>>Java>>正文


Java Observable.addListener方法代碼示例

本文整理匯總了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();
		}
	}
 
開發者ID:andy-goryachev,項目名稱:FxEditor,代碼行數:19,代碼來源:Binder.java

示例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();
	}
}
 
開發者ID:Apelon-VA,項目名稱:ISAAC,代碼行數:17,代碼來源:UpdateableBooleanBinding.java

示例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();
	}
}
 
開發者ID:andy-goryachev,項目名稱:FxEditor,代碼行數:11,代碼來源:FX.java

示例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);
	}
}
 
開發者ID:andy-goryachev,項目名稱:ReqTraq,代碼行數:11,代碼來源:Binder.java

示例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);
		}
	}
}
 
開發者ID:to2mbn,項目名稱:LoliXL,代碼行數:8,代碼來源:ObservableContext.java

示例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();
}
 
開發者ID:to2mbn,項目名稱:LoliXL,代碼行數:16,代碼來源:BlurBackgroundPane.java

示例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();
	}
}
 
開發者ID:andy-goryachev,項目名稱:FxDock,代碼行數:11,代碼來源:FxInvalidationListener.java

示例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);
        }
    };
}
 
開發者ID:TomasMikula,項目名稱:ReactFX,代碼行數:15,代碼來源:EventStreams.java

示例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);
  }
}
 
開發者ID:VerifAPS,項目名稱:stvs,代碼行數:11,代碼來源:SpecificationRow.java

示例10: addListener

import javafx.beans.Observable; //導入方法依賴的package包/類
@Override
protected void addListener(Observable observable, InvalidationListener listener)
{
    observable.addListener(listener);
}
 
開發者ID:jvm-profiling-tools,項目名稱:honest-profiler,代碼行數:6,代碼來源:InvalidationListenerHandle.java


注:本文中的javafx.beans.Observable.addListener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。