RadioButton

@Composable
fun RadioButton(text: @Nls String, selected: Boolean, onSelectedChange: (Boolean) -> Unit, modifier: SwingModifier = SwingModifier)

A JRadioButton, a labeled button showing whether it is chosen. The button shows whatever selected holds, and every activation the user makes is reported through onSelectedChange. Standing alone it clears itself on a second click; making several buttons one choice takes a ButtonGroup. buttonGroup enrolls a button in one, and RadioGroup declares a whole choice.

An activation the caller does not answer with a matching selected does not stand: the button is back on the declared state before the click is painted.

Parameters

text

the text to display next to the radio button

selected

whether the radio button is selected

onSelectedChange

callback invoked with the selected state when the button is activated

modifier

the SwingModifier applied to the underlying component

See also


@Composable
fun RadioButton(text: @Nls String, selected: Boolean, actionListener: ActionListener, modifier: SwingModifier = SwingModifier)

A RadioButton driven by a raw ActionListener instead of an onSelectedChange lambda. The actionListener is attached as-is and removed on the same instance; pass a stable instance (e.g. remember {}) to avoid churn.

Parameters

text

the text to display next to the radio button

selected

whether the radio button is selected

actionListener

the listener notified when the radio button is activated

modifier

the SwingModifier applied to the underlying component

See also