Link between Toggle and e.g. the RadioButton behind it?

蹲街弑〆低调 提交于 2019-12-13 03:54:55

问题


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:


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.



来源:https://stackoverflow.com/questions/14885608/link-between-toggle-and-e-g-the-radiobutton-behind-it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!