javafx.beans.property.Property类的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(194)

本文整理了Java中javafx.beans.property.Property类的一些代码示例,展示了Property类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Property类的具体详情如下:
包路径:javafx.beans.property.Property
类名称:Property

Property介绍

暂无

代码示例

代码示例来源:origin: pmd/pmd

/** Unbinds this dialog from its backing properties. */
public void free() {
  backingDescriptor.ifPresent(PropertyDescriptorSpec::unbind);
  backingDescriptor.setValue(null);
  backingDescriptorList.setValue(null);
  this.nameProperty().setValue(""); // necessary to get the validator to reevaluate each time
}

代码示例来源:origin: pmd/pmd

/**
 * Binds the underlying property to a source of values (UI property). The UI
 * property is also initialised using a setter.
 *
 * @param underlying The underlying property
 * @param ui         The property exposed to the user (the one in this wizard)
 * @param setter     Setter to initialise the UI value
 * @param <T>        Type of values
 */
public static <T> void rewireInit(Property<T> underlying, ObservableValue<? extends T> ui, Consumer<? super T> setter) {
  setter.accept(underlying.getValue());
  rewire(underlying, ui);
}

代码示例来源:origin: pmd/pmd

/** Like rewireInit, with no initialisation. */
public static <T> void rewire(Property<T> underlying, ObservableValue<? extends T> source) {
  underlying.unbind();
  underlying.bind(source); // Bindings are garbage collected after the popup dies
}

代码示例来源:origin: speedment/speedment

@Override
  protected Node createUndecoratedEditor() {
    final ChoiceBox<T> box = new ChoiceBox<>(alternatives);
    final T val = currentValue.getValue();

    if (alternatives.contains(val)) {
      box.setValue(val);
    } else {
      box.setValue(alternatives.get(0));
    }

    currentValue.bindBidirectional(box.valueProperty());
    return box;
  }
}

代码示例来源:origin: at.bestsolution.eclipse/org.eclipse.fx.code.editor.fx

@PreDestroy
  void destroy() {
    if( activeInput != null && activeInput.getValue() == input ) {
      activeInput.setValue(null);
    }
    this.input = null;
  }
}

代码示例来源:origin: at.bestsolution.efxclipse.rt/org.eclipse.fx.code.editor.fx

private <T> void installListener(Property<T> property, ChangeListener<? super T> listener) {
  property.addListener(listener);
  toDispose.add(() -> property.removeListener(listener));
}

代码示例来源:origin: org.graniteds/granite-client-javafx

public void afterChange(T newSource, P oldValue) {
  targetProperty = newSource != null ? targetPropertyGetter.getProperty(newSource) : null;
  
  P newValue = targetProperty != null ? targetProperty.getValue() : null;
  
  if (targetProperty != null) {
    targetProperty.addListener(targetChangeListener);
    targetProperty.addListener(targetInvalidationListener);
    
    if (newValue != oldValue) {
      targetInvalidationListener.invalidated(ChainedProperty.this);
      targetChangeListener.changed(ChainedProperty.this, oldValue, newValue);
    }
  }
}

代码示例来源:origin: Tristan971/Lyrebird

@Autowired
public ImageScreenController(final CachedMedia cachedMedia) {
  this.cachedMedia = cachedMedia;
  imageProp.addListener((observable, oldValue, newValue) -> bindViewSizeToParent());
}

代码示例来源:origin: com.speedment.tool/tool-config

final P property = propertyGetter.apply(casted);
if (!Objects.equals(casted, property.getValue())) {
  if (property.isBound()) {
    throw new SpeedmentConfigException(
      "Attempting to set bound " + 
    );
  } else {
    property.setValue(casted);

代码示例来源:origin: org.jcrom/jcrom

/**
 * Set the value of a JavaFX property in the current thread and then in the JavaFX thread.
 * Actually, if a visible node of the JavaFX scene graph is bound to the property, it
 * will be only possible to update its value in the JavaFX thread.
 * <p/>
 * If the property is bound, this method does nothing.
 */
private static void updateProperty(final Object value, final Property finalProperty) {
  if (finalProperty.isBound()) {
    System.out.println("Impossible to set the value " + value + " to " + finalProperty.getName() + ". Property is bound.");
    return;
  }
  try {
    finalProperty.setValue(value);
  } catch (RuntimeException e) {
    Platform.runLater(new Runnable() {
      @Override
      public void run() {
        finalProperty.setValue(value);
      }
    });
  }
}

代码示例来源:origin: org.fxmisc.easybind/easybind

@Override
protected Subscription observeTargetObservable(Property<U> mapped) {
  if(boundTo != null) {
    mapped.bind(boundTo);
  }
  Subscription s1 = super.observeTargetObservable(mapped);
  Subscription s2 = () -> {
    if(boundTo != null) {
      mapped.unbind();
      if(resetOnUnbind) {
        mapped.setValue(resetTo);
      }
    }
  };
  return s1.and(s2);
}

代码示例来源:origin: at.bestsolution.eclipse/org.eclipse.fx.core

@Override
  public void dispose() {
    property.removeListener(l);
  }
};

代码示例来源:origin: org.graniteds/granite-client-javafx

public P beforeChange(T oldSource) {
  P oldValue = targetProperty != null ? targetProperty.getValue() : null;
  
  if (targetProperty != null) {
    targetProperty.removeListener(targetChangeListener);
    targetProperty.removeListener(targetInvalidationListener);
  }
  
  return oldValue;
}

代码示例来源:origin: org.fxmisc.easybind/easybind

public ConditionalBinding(
    Property<T> target,
    ObservableValue<? extends T> source,
    ObservableValue<Boolean> condition) {
  this.target = new WeakReference<>(target);
  this.source = source;
  this.condition = condition;
  // add an empty listener to target just to maintain a strong reference
  // to this object for the lifetime of target
  target.addListener(this);
  condition.addListener((ChangeListener<Boolean>) this);
  if(condition.getValue()) {
    target.bind(source);
  }
}

代码示例来源:origin: org.codehaus.griffon.plugins/griffon-glazedlists-javafx

@Override
@SuppressWarnings("unchecked")
public EventListener installListener(T element) {
  ElementChangeHandler ecl = new ElementChangeHandler<>(element);
  for (Property<?> property : element.properties()) {
    if (matches(property.getName())) {
      property.addListener(ecl);
    }
  }
  return ecl;
}

代码示例来源:origin: com.speedment.tool/tool-config

@Override
public void bind(ObservableValue<? extends Number> observable) {
  wrapped.bind(observable);
}

代码示例来源:origin: org.codehaus.griffon.plugins/griffon-glazedlists-javafx

@Override
@SuppressWarnings("unchecked")
public void uninstallListener(T element, EventListener listener) {
  if (listener instanceof ChangeListener) {
    ChangeListener cl = (ChangeListener) listener;
    for (Property<?> property : element.properties()) {
      if (matches(property.getName())) {
        property.removeListener(cl);
      }
    }
  }
}

代码示例来源:origin: com.speedment.tool/tool-config

@Override
public boolean isBound() {
  return wrapped.isBound();
}

代码示例来源:origin: org.fxmisc.easybind/easybind

@Override
  public void unsubscribe() {
    if(!unsubscribed) {
      condition.removeListener((ChangeListener<Boolean>) this);

      Property<T> tgt = this.target.get();
      if(tgt != null) {
        tgt.removeListener(this);
        tgt.unbind();
      }

      unsubscribed = true;
    }
  }
}

代码示例来源:origin: com.dlsc.formsfx/formsfx-core

/**
 * Unbinds the given property with the field.
 *
 * @param binding
 *          The property to be unbound with.
 *
 * @return Returns the current field to allow for chaining.
 */
public F unbind(P binding) {
  persistentValue.unbindBidirectional(binding);
  binding.removeListener(externalBindingListener);
  return (F) this;
}

相关文章