Answers for "bidirectional binding between string Property and Objectproperty"

0

bidirectional binding between string Property and integerproperty

Map<Integer, String> m = ...;
StringProperty sp = ...;
IntegerProperty ip = ...;

Bindings.bindBidirectional(sp, ip, new StringConverter<Number>() {

    @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);
    }
});
Posted by: Guest on July-19-2021

Code answers related to "bidirectional binding between string Property and Objectproperty"

Code answers related to "Assembly"

Browse Popular Code Answers by Language