Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR ASSEMBLY

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);
    }
});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #bidirectional #binding #string #Property #integerproperty
ADD COMMENT
Topic
Name
5+8 =