private void construct()
{
// react to when the user clicks on another togglebutton
selectedToggleProperty().addListener( (observable) -> {
// get selected toggle
Toggle lToggle = selectedToggleProperty().get();
if (lToggle == null)
{
valueObjectProperty.set(null);
}
else
{
T lValue = (T)lToggle.getUserData();
valueObjectProperty.set( lValue );
}
});
// react to when the value property get a different value
valueObjectProperty.addListener( (observable) -> {
T value = valueObjectProperty.get();
// if null
if (value == null) {
// deselect
selectToggle(null);
return;
}
// scan all toggles
for (Toggle lToggle : getToggles()) {
// if user data is equal
if (Objects.equals(lToggle.getUserData(), value)) {
// set toggle if required
if (getSelectedToggle() != lToggle) {
selectToggle(lToggle);
return;