Link between Toggle and e.g. the RadioButton behin

2019-08-30 11:41发布

Imaging e.g. 2 RadioButtons which share one ToggleGroup. Using

ToggleGroup.getToggles()

one can access all Toggles of the ToggleGroup. But is there any reference from a Toggle to the RadioButton that is linked to?

1条回答
We Are One
2楼-- · 2019-08-30 11:51

If I understood the question correctly you're looking for:

RadioButton button = (RadioButton) toggleGroup.getSelectedToggle();

Unfortunatly, the ToggleGroup isn't "generified" yet, so you need the cast.

But is there any reference from a Toggle to the RadioButton that is linked to?

Or in other words: RadioButton is a (implements) Toggle, there isn't any reference.

查看更多
登录 后发表回答