【问题标题】:Bind custom object property to BooleanBinding将自定义对象属性绑定到 BooleanBinding
【发布时间】:2016-04-02 04:17:15
【问题描述】:

给定一个BooleanBinding 类型的Java 表达式(比如x.lessThan(y)),使用来自boolean 的自定义映射将ObjectProperty p 绑定到它的最简单方法是什么?

具体来说,有没有比以下更简单的方法?

BooleanBinding b = x.lessThan(y);
p.bind(new ObjectBinding<Paint>(){
    {
        super.bind(b);
    }

    @Override
    protected Paint computeValue() {
        if(b.get()){
            return Color.BLUE;
        } else {
            return Color.RED;
        }
    }
});

我很想做类似p.bind(x.lessThan(y).ifElse(Color.BLUE,Color.RED))的事情

【问题讨论】:

标签: java data-binding javafx javafx-8


【解决方案1】:
猜你喜欢
  • 2020-06-16
  • 1970-01-01
  • 2011-04-17
  • 2013-10-09
  • 1970-01-01
  • 2018-09-03
  • 2011-10-03
  • 2011-05-26
  • 2017-08-08
相关资源
最近更新 更多