📜  字符串属性和整数属性之间的双向绑定 - 汇编代码示例

📅  最后修改于: 2022-03-11 14:48:10.388000             🧑  作者: Mango

代码示例1
Map m = ...;
StringProperty sp = ...;
IntegerProperty ip = ...;

Bindings.bindBidirectional(sp, ip, new StringConverter() {

    @Override
    public Integer fromString(String s) {
        for(Integer key: m.keySet()) {
            if(m.get(key).equals(s)) {
                return key;
            }
        }
        return -1; // or whatever makes sense for you
    }

    @Override
    public String toString(Integer i) {
        return m.get(i);
    }
});