📅  最后修改于: 2022-03-11 14:48:10.388000             🧑  作者: Mango
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);
}
});