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 HasValue<Boolean> via
Extends
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 VaadinCheckbox (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 aRadioButtonGroup, 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 -
Method Summary
Modifier and TypeMethodDescriptiongetLabel()Read back the label set viasetLabel(String).voidSet the radio button's label.Methods inherited from class com.vaadin.flow.component.AbstractSinglePropertyField
getSynchronizationRegistration, hasValidValue, setPresentationValue, setSynchronizedEventMethods inherited from class com.vaadin.flow.component.AbstractField
addValueChangeListener, bindValue, getEmptyValue, getValue, isEmpty, setModelValue, setValue, valueEqualsMethods 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, whenAttachedMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.BlurNotifier
addBlurListenerMethods inherited from interface com.vaadin.flow.component.ClickNotifier
addClickListener, addClickShortcut, addDoubleClickListener, addSingleClickListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.Focusable
addFocusShortcut, blur, focus, focus, getTabIndex, setTabIndexMethods inherited from interface com.vaadin.flow.component.FocusNotifier
addFocusListenerMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
bindEnabled, isEnabled, setEnabledMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, bindClassName, bindClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.HasValue
clear, getOptionalValueMethods inherited from interface com.vaadin.flow.component.HasValueAndElement
bindReadOnly, bindRequiredIndicatorVisible, isReadOnly, isRequiredIndicatorVisible, setReadOnly, setRequiredIndicatorVisible
-
Constructor Details
-
VaadinRadioButton
public VaadinRadioButton()
-
-
Method Details
-
setLabel
Set the radio button's label. Null and the empty string both clear the label slot; any other value lazily creates aNativeLabelin thelabelslot and writes the text into it. Matches theHasLabelcontract while routing through the slot mechanism the web component actually uses (no top-levellabelproperty exists onvaadin-radio-button).- Specified by:
setLabelin interfacecom.vaadin.flow.component.HasLabel
-
getLabel
Read back the label set viasetLabel(String). Returnsnullwhen no label slot child exists (matches VaadinCheckbox.getLabel()'s null-when-unset shape).- Specified by:
getLabelin interfacecom.vaadin.flow.component.HasLabel
-