当前位置: 首页>>代码示例>>Java>>正文


Java ObservableBooleanValue.addListener方法代码示例

本文整理汇总了Java中javafx.beans.value.ObservableBooleanValue.addListener方法的典型用法代码示例。如果您正苦于以下问题:Java ObservableBooleanValue.addListener方法的具体用法?Java ObservableBooleanValue.addListener怎么用?Java ObservableBooleanValue.addListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.beans.value.ObservableBooleanValue的用法示例。


在下文中一共展示了ObservableBooleanValue.addListener方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addSceneLifecycleHooks

import javafx.beans.value.ObservableBooleanValue; //导入方法依赖的package包/类
/**
 * This method adds listeners for the {@link SceneLifecycle}.
 */
static void addSceneLifecycleHooks(ViewModel viewModel, ObservableBooleanValue viewInSceneProperty) {
    if(viewModel != null) {

        if(viewModel instanceof SceneLifecycle) {
            SceneLifecycle lifecycleViewModel = (SceneLifecycle) viewModel;

            PreventGarbageCollectionStore.getInstance().put(viewInSceneProperty);

            viewInSceneProperty.addListener((observable, oldValue, newValue) -> {
	if(newValue) {
		lifecycleViewModel.onViewAdded();
	} else {
		lifecycleViewModel.onViewRemoved();
                    PreventGarbageCollectionStore.getInstance().remove(viewInSceneProperty);
	}
});
        }
    }
}
 
开发者ID:cmlanche,项目名称:easyMvvmFx,代码行数:23,代码来源:ViewLoaderReflectionUtils.java

示例2: decision

import javafx.beans.value.ObservableBooleanValue; //导入方法依赖的package包/类
/**
 * Returns a new observable string which contains either the contents of ifTrue, or ifFalse, depending on the condition
 * @param condition
 * @param ifTrue
 * @param ifFalse
 * @return
 */
public static ObservableStringValue decision(ObservableBooleanValue condition,
                                             ObservableStringValue ifTrue,
                                             ObservableStringValue ifFalse) {
    StringProperty ret = new SimpleStringProperty();
    condition.addListener((obs, ov, nv) -> {
        ret.set(nv ? ifTrue.get() : ifFalse.get());
    });
    ifTrue.addListener((obs, ov, nv) -> {
        if (condition.get()) {
            ret.set(nv);
        }
    });
    ifFalse.addListener((obs, ov, nv) -> {
        if (!condition.get()) {
            ret.set(nv);
        }
    });
    ret.set(condition.get() ? ifTrue.get() : ifFalse.get());

    return ret;
}
 
开发者ID:narrowtux,项目名称:SmartModInserter,代码行数:29,代码来源:Bindings.java

示例3: handle

import javafx.beans.value.ObservableBooleanValue; //导入方法依赖的package包/类
@Override
public void handle(MouseEvent e) {
    adjustingTooltip.set(true);

    Node chartNode = (Node) e.getSource();

    tooltip.show(chartNode, e.getScreenX(), e.getScreenY());
    setLabelPosition(e);

    ObservableBooleanValue stillHovering = chartNode.hoverProperty().or(adjustingTooltip);
    stillHovering.addListener(new ChangeListener<Boolean>() {
        @Override
        public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean nowHovering) {
            if (!nowHovering) {
                stillHovering.removeListener(this);
                tooltip.hide();
            }
        }
    });

    T chartData = (T) chartNode.getUserData();
    String txt = textProvider.apply(chartData);
    tooltip.setText(txt);

    adjustingTooltip.set(false);
}
 
开发者ID:githublemming,项目名称:CloudTrailViewer,代码行数:27,代码来源:ChartHoverUtil.java

示例4: apply

import javafx.beans.value.ObservableBooleanValue; //导入方法依赖的package包/类
public void apply(ObservableBooleanValue expanded, ObservableBooleanValue animate, Region region) {
    Rectangle clip = new Rectangle();
    clip.widthProperty().bind(region.widthProperty());
    clip.heightProperty().bind(region.heightProperty());
    region.setClip(clip);
    region.setMinHeight(0);
    region.setMaxHeight(expanded.get() ? Region.USE_PREF_SIZE : 0);
    region.visibleProperty().bind(region.heightProperty().greaterThan(0));

    expanded.addListener((v, o, n) -> onExpandedChanged(n, animate.get(), region));
}
 
开发者ID:rmfisher,项目名称:fx-animation-editor,代码行数:12,代码来源:CollapseAnimator.java

示例5: apply

import javafx.beans.value.ObservableBooleanValue; //导入方法依赖的package包/类
public void apply(ObservableBooleanValue trigger, Node node) {
    this.trigger = trigger;
    this.node = node;
    configureTransition(node);
    node.getProperties().put(ANIMATION_TRIGGER_KEY, trigger); // Prevents trigger from being garbage collected.
    trigger.addListener(triggerChangeListener);
    node.setOpacity(trigger.get() ? to : from);
}
 
开发者ID:rmfisher,项目名称:fx-animation-editor,代码行数:9,代码来源:FadeInAnimator.java

示例6: addClickableAndDisableableListElement

import javafx.beans.value.ObservableBooleanValue; //导入方法依赖的package包/类
public void addClickableAndDisableableListElement(final String s, final ObservableBooleanValue isDisabled, final Consumer<MouseEvent> mouseEventConsumer) {
    final Label label = new Label(s);

    label.setStyle("-fx-padding: 8 16 8 16;");
    label.getStyleClass().add("body2");
    label.setMinWidth(width);

    final JFXRippler rippler = new JFXRippler(label);

    rippler.setOnMouseEntered(event -> {
        if (isDisabled.get()) return;

        // Set the background to a light grey
        label.setBackground(new Background(new BackgroundFill(
                Color.GREY.getColor(Color.Intensity.I200),
                CornerRadii.EMPTY,
                Insets.EMPTY
        )));

        canIShowSubMenu.set(false);
    });

    rippler.setOnMouseExited(event -> {
        if (isDisabled.get()) return;

        // Set the background to be transparent
        label.setBackground(new Background(new BackgroundFill(
                TRANSPARENT,
                CornerRadii.EMPTY,
                Insets.EMPTY
        )));
    });

    // When the rippler is pressed, run the provided consumer.
    rippler.setOnMousePressed(event -> {
        if (isDisabled.get()) {
            event.consume();
            return;
        }

        // If we do not do this, the method below will be called twice
        if (!(event.getTarget() instanceof StackPane)) return;

        mouseEventConsumer.accept(event);
    });

    final Consumer<Boolean> updateTransparency = (disabled) -> {
        if (disabled) {
            rippler.setRipplerFill(WHITE);
            label.setOpacity(0.5);
        } else {
            rippler.setOpacity(1);
            rippler.setRipplerFill(Color.GREY_BLUE.getColor(Color.Intensity.I300));
            label.setOpacity(1);
        }
    };

    isDisabled.addListener((obs, oldDisabled, newDisabled) -> updateTransparency.accept(newDisabled));
    updateTransparency.accept(isDisabled.get());

    list.getChildren().add(rippler);
}
 
开发者ID:ulriknyman,项目名称:H-Uppaal,代码行数:63,代码来源:DropDownMenu.java


注:本文中的javafx.beans.value.ObservableBooleanValue.addListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。