Class VaadinRadioButton

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.AbstractField<VaadinRadioButton, Boolean>
com.vaadin.flow.component.AbstractSinglePropertyField<VaadinRadioButton, Boolean>
com.vaadin.swingbridge.surrogates.VaadinRadioButton
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.BlurNotifier<VaadinRadioButton>, com.vaadin.flow.component.ClickNotifier<VaadinRadioButton>, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.Focusable<VaadinRadioButton>, com.vaadin.flow.component.FocusNotifier<VaadinRadioButton>, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasEnabled, com.vaadin.flow.component.HasLabel, com.vaadin.flow.component.HasStyle, com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<VaadinRadioButton, Boolean>, Boolean>, com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<VaadinRadioButton, Boolean>, Boolean>, Serializable
Direct Known Subclasses:
SJRadioButton

@Tag("vaadin-radio-button") @NpmPackage(value="@vaadin/radio-group", version="25.3.0") @JsModule("@vaadin/radio-group/src/vaadin-radio-button.js") public class VaadinRadioButton extends com.vaadin.flow.component.AbstractSinglePropertyField<VaadinRadioButton, Boolean> implements com.vaadin.flow.component.ClickNotifier<VaadinRadioButton>, com.vaadin.flow.component.Focusable<VaadinRadioButton>, com.vaadin.flow.component.HasLabel
Re-host of Vaadin's vaadin-radio-button web component as a public Java Component. Vaadin ships the web component as part of @vaadin/radio-group and exposes a Java wrapper com.vaadin.flow.component.radiobutton.RadioButton — but that wrapper is package-private (intended as RadioButtonGroup's internal item class only), so it cannot be extended or used standalone. SJRadioButton needs a real radio button it can subclass, so we re-host the public web component here.

Lives in :surrogates as a plain Vaadin component — no Swing surface, no mixin. General-purpose: any Vaadin code needing a standalone radio button (outside a RadioButtonGroup) can use it directly. Same precedent LongField follows for Vaadin's missing long-typed numeric field.

HasValue<Boolean> via checked property

Extends AbstractSinglePropertyField bound to the checked boolean — the same web-component property Vaadin's own (package-private) RadioButton synchronises via @Synchronize("checked-changed"). AbstractSinglePropertyField's automatic <property>-changed subscription wires the same synchronisation without the annotation. Produces a Vaadin HasValue.ValueChangeEvent on browser-side toggle — SJRadioButton's R_swing_is_truth model sync hooks here.

Label slot (not a property)

Unlike Vaadin Checkbox (which exposes a label string property via HasLabel's default), vaadin-radio-button renders its label through a slotted child element. We override HasLabel.setLabel(String) / HasLabel.getLabel() to manage a single NativeLabel in the label slot. Same mechanism Vaadin's internal RadioButton uses via setLabelComponent — we surface a string-based setter to match the HasLabel contract.

Standalone use vs. RadioButtonGroup

Vaadin's design hosts radios exclusively inside a RadioButtonGroup, which manages selection mutex on the server side and pushes per-element checked state. A standalone VaadinRadioButton carries no mutex behaviour — clicking toggles checked on/off like a checkbox. Group mutex is SJRadioButton's job (via ButtonModel + emulator-layer vaadinx.swing.ButtonGroup per D_buttongroup), not the peer's.
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from class com.vaadin.flow.component.AbstractField

    com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<C,V>

    Nested classes/interfaces inherited from interface com.vaadin.flow.component.BlurNotifier

    com.vaadin.flow.component.BlurNotifier.BlurEvent<C>

    Nested classes/interfaces inherited from interface com.vaadin.flow.component.FocusNotifier

    com.vaadin.flow.component.FocusNotifier.FocusEvent<C>

    Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasValue

    com.vaadin.flow.component.HasValue.ValueChangeEvent<V>, com.vaadin.flow.component.HasValue.ValueChangeListener<E>
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Read back the label set via setLabel(String).
    void
    Set the radio button's label.

    Methods inherited from class com.vaadin.flow.component.AbstractSinglePropertyField

    getSynchronizationRegistration, hasValidValue, setPresentationValue, setSynchronizedEvent

    Methods inherited from class com.vaadin.flow.component.AbstractField

    addValueChangeListener, bindValue, getEmptyValue, getValue, isEmpty, setModelValue, setValue, valueEquals

    Methods inherited from class com.vaadin.flow.component.Component

    addListener, bindVisible, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTestId, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setTestId, setVisible, whenAttached

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.vaadin.flow.component.AttachNotifier

    addAttachListener

    Methods inherited from interface com.vaadin.flow.component.BlurNotifier

    addBlurListener

    Methods inherited from interface com.vaadin.flow.component.ClickNotifier

    addClickListener, addClickShortcut, addDoubleClickListener, addSingleClickListener

    Methods inherited from interface com.vaadin.flow.component.DetachNotifier

    addDetachListener

    Methods inherited from interface com.vaadin.flow.component.Focusable

    addFocusShortcut, blur, focus, focus, getTabIndex, setTabIndex

    Methods inherited from interface com.vaadin.flow.component.FocusNotifier

    addFocusListener

    Methods inherited from interface com.vaadin.flow.component.HasElement

    getElement

    Methods inherited from interface com.vaadin.flow.component.HasEnabled

    bindEnabled, isEnabled, setEnabled

    Methods inherited from interface com.vaadin.flow.component.HasStyle

    addClassName, addClassNames, bindClassName, bindClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName

    Methods inherited from interface com.vaadin.flow.component.HasValue

    clear, getOptionalValue

    Methods inherited from interface com.vaadin.flow.component.HasValueAndElement

    bindReadOnly, bindRequiredIndicatorVisible, isReadOnly, isRequiredIndicatorVisible, setReadOnly, setRequiredIndicatorVisible
  • Constructor Details

    • VaadinRadioButton

      public VaadinRadioButton()
  • Method Details

    • setLabel

      public void setLabel(String label)
      Set the radio button's label. Null and the empty string both clear the label slot; any other value lazily creates a NativeLabel in the label slot and writes the text into it. Matches the HasLabel contract while routing through the slot mechanism the web component actually uses (no top-level label property exists on vaadin-radio-button).
      Specified by:
      setLabel in interface com.vaadin.flow.component.HasLabel
    • getLabel

      public String getLabel()
      Read back the label set via setLabel(String). Returns null when no label slot child exists (matches Vaadin Checkbox.getLabel()'s null-when-unset shape).
      Specified by:
      getLabel in interface com.vaadin.flow.component.HasLabel