本文整理汇总了Java中javafx.collections.WeakSetChangeListener类的典型用法代码示例。如果您正苦于以下问题:Java WeakSetChangeListener类的具体用法?Java WeakSetChangeListener怎么用?Java WeakSetChangeListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WeakSetChangeListener类属于javafx.collections包,在下文中一共展示了WeakSetChangeListener类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ObservableSetBuffering
import javafx.collections.WeakSetChangeListener; //导入依赖的package包/类
/**
* @param newBeanType
* bean type
* @param newPropertyName
* bean property name
* @param newSubject
* property value
*/
public ObservableSetBuffering(final Class<?> newBeanType, final String newPropertyName,
final ObservableSet<E> newSubject)
{
super(FXCollections.observableSet(new HashSet<>(newSubject != null ? newSubject.size() : 0)));
if (newBeanType != null || !(newSubject instanceof ReadOnlyProperty<?>))
{
beanType = newBeanType;
}
else
{
final Object bean = ((ReadOnlyProperty<?>) newSubject).getBean();
beanType = (bean != null ? bean.getClass() : null);
}
if (newPropertyName != null || !(newSubject instanceof ReadOnlyProperty<?>))
{
propertyName = newPropertyName;
}
else
{
propertyName = ((ReadOnlyProperty<?>) newSubject).getName();
}
subject = Objects.requireNonNull(newSubject);
addAll(subject);
thisListener = c -> {
if (equalsBuffering)
{
buffering.setValue(!equalsSubject());
}
else
{
buffering.setValue(true);
}
validate();
};
subjectListener = c -> {
if (!buffering.getValue())
{
revert();
}
};
addListener(thisListener);
weakSubjectListener = new WeakSetChangeListener<E>(subjectListener);
subject.addListener(weakSubjectListener);
validate();
}