RadioButtonMenuGroup
A set of mutually exclusive choices in a menu, backed by a shared ButtonGroup, so at most one option is selected at a time.
Declare the choices in content; each option(...) becomes a JRadioButtonMenuItem placed in the surrounding menu in call order, among whatever other items that menu declares. The selected option is controlled via selectedIndex (the zero-based position of the chosen option, or any out-of-range value such as -1 for no selection); selecting an option invokes onSelectionChange with its index, while external selectedIndex changes move the selection to match.
Menu("View") {
RadioButtonMenuGroup(selectedIndex = density, onSelectionChange = { density = it }) {
option("Comfortable")
option("Compact")
}
}A pick the caller does not answer with a matching selectedIndex is settled back onto the declared one, so the option shown selected is the one the composition holds.
Parameters
the index of the selected option (controlled); an out-of-range value, such as -1, leaves every option unselected
callback invoked with the option's index when the user selects it
declares the options; see RadioButtonMenuGroupScope