当前位置: 首页>>代码示例>>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;未经允许,请勿转载。