java - Bind ToggleGroup bidirectionally in javafx -


Imagine having a mouse-mode an enum to define

itemprop = "text">

after

I need to field field MouseMode currentMode to be bidirectionally linked to toggle group. Whenever a toggle is set, the currentMode is switched accordingly, but it also converts some external process to CurrentMode (maybe press a key) then the togglegroup optimizes accordingly.

Can do this with 2 listeners, but I wonder if there is a way to make custom bidirectional maps.

I do not think there is a way to do this directly. While a general purpose

  Bindings.bindBidirectional (asset  property1, property & lt; t & gt; property2, the function & lt; s, t & gt; ; Mapping;   

can make a good addition to the API, even in this case, because the inverseMapping of the function ToggleGroup 's selectedProperty is read only (since each toggle ' s set select (...) The law applies, as well as ToggleGroup selectedP Roperty ).

The use of some listeners in this case is the way to go.

The closest thing to "custom bidirectional map" is that

  Bindings.bindBiDirectional (StringProperty stringProperty, ObjectProperty & lt; t & gt; otherProperty, StringConverter & lt; t & Gt; converter)   

method. S & gt; Where a (writeable) objectProperty is and (writable) ObjectProperty & LT; T & gt; You can use two bidirectional bindings and an intermediate string in order to string them together. In practice, using only two listeners almost always leads to more code, and it is also less efficient.

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -