public class

RadioButton

extends CheckBox
java.lang.Object
   ↳ com.google.gwt.user.client.ui.UIObject
     ↳ com.google.gwt.user.client.ui.Widget
       ↳ com.google.gwt.user.client.ui.FocusWidget
         ↳ com.google.gwt.user.client.ui.ButtonBase
           ↳ com.google.gwt.user.client.ui.CheckBox
             ↳ com.google.gwt.user.client.ui.RadioButton

Class Overview

A mutually-exclusive selection radio button widget. Fires ClickEvents when the radio button is clicked, and ValueChangeEvents when the button becomes checked. Note, however, that browser limitations prevent ValueChangeEvents from being sent when the radio button is cleared as a side effect of another in the group being clicked.

CSS Style Rules

.gwt-RadioButton
the outer element

Example

{@example com.google.gwt.examples.RadioButtonExample}

Summary

[Expand]
Inherited Constants
From class com.google.gwt.user.client.ui.UIObject
Public Constructors
RadioButton(String name)
Creates a new radio associated with a particular group name.
RadioButton(String name, SafeHtml label)
Creates a new radio associated with a particular group, and initialized with the given HTML label.
RadioButton(String name, String label)
Creates a new radio associated with a particular group, and initialized with the given HTML label.
RadioButton(String name, String label, boolean asHTML)
Creates a new radio button associated with a particular group, and initialized with the given label (optionally treated as HTML).
Public Methods
void onBrowserEvent(Event event)
Overridden to send ValueChangeEvents only when appropriate.
void setName(String name)
Change the group name of this radio button.
void sinkEvents(int eventBitsToAdd)
Overridden to defer the call to super.sinkEvents until the first time this widget is attached to the dom, as a performance enhancement.
Protected Methods
void ensureDomEventHandlers()
No-op.
[Expand]
Inherited Methods
From class com.google.gwt.user.client.ui.CheckBox
From class com.google.gwt.user.client.ui.ButtonBase
From class com.google.gwt.user.client.ui.FocusWidget
From class com.google.gwt.user.client.ui.Widget
From class com.google.gwt.user.client.ui.UIObject
From class java.lang.Object
From interface com.google.gwt.editor.client.IsEditor
From interface com.google.gwt.event.dom.client.HasBlurHandlers
From interface com.google.gwt.event.dom.client.HasClickHandlers
From interface com.google.gwt.event.dom.client.HasDoubleClickHandlers
From interface com.google.gwt.event.dom.client.HasFocusHandlers
From interface com.google.gwt.event.dom.client.HasGestureChangeHandlers
From interface com.google.gwt.event.dom.client.HasGestureEndHandlers
From interface com.google.gwt.event.dom.client.HasGestureStartHandlers
From interface com.google.gwt.event.dom.client.HasKeyDownHandlers
From interface com.google.gwt.event.dom.client.HasKeyPressHandlers
From interface com.google.gwt.event.dom.client.HasKeyUpHandlers
From interface com.google.gwt.event.dom.client.HasMouseDownHandlers
From interface com.google.gwt.event.dom.client.HasMouseMoveHandlers
From interface com.google.gwt.event.dom.client.HasMouseOutHandlers
From interface com.google.gwt.event.dom.client.HasMouseOverHandlers
From interface com.google.gwt.event.dom.client.HasMouseUpHandlers
From interface com.google.gwt.event.dom.client.HasMouseWheelHandlers
From interface com.google.gwt.event.dom.client.HasTouchCancelHandlers
From interface com.google.gwt.event.dom.client.HasTouchEndHandlers
From interface com.google.gwt.event.dom.client.HasTouchMoveHandlers
From interface com.google.gwt.event.dom.client.HasTouchStartHandlers
From interface com.google.gwt.event.logical.shared.HasAttachHandlers
From interface com.google.gwt.event.logical.shared.HasValueChangeHandlers
From interface com.google.gwt.event.shared.HasHandlers
From interface com.google.gwt.safehtml.client.HasSafeHtml
From interface com.google.gwt.user.client.EventListener
From interface com.google.gwt.user.client.TakesValue
From interface com.google.gwt.user.client.ui.Focusable
From interface com.google.gwt.user.client.ui.HasEnabled
From interface com.google.gwt.user.client.ui.HasHTML
From interface com.google.gwt.user.client.ui.HasName
From interface com.google.gwt.user.client.ui.HasText
From interface com.google.gwt.user.client.ui.HasValue
From interface com.google.gwt.user.client.ui.HasWordWrap
From interface com.google.gwt.user.client.ui.IsWidget
From interface com.google.gwt.user.client.ui.SourcesClickEvents
From interface com.google.gwt.user.client.ui.SourcesFocusEvents
From interface com.google.gwt.user.client.ui.SourcesKeyboardEvents
From interface com.google.gwt.user.client.ui.SourcesMouseEvents

Public Constructors

public RadioButton (String name)

Creates a new radio associated with a particular group name. All radio buttons associated with the same group name belong to a mutually-exclusive set. Radio buttons are grouped by their name attribute, so changing their name using the setName() method will also change their associated group.

Parameters
name the group name with which to associate the radio button

public RadioButton (String name, SafeHtml label)

Creates a new radio associated with a particular group, and initialized with the given HTML label. All radio buttons associated with the same group name belong to a mutually-exclusive set. Radio buttons are grouped by their name attribute, so changing their name using the setName() method will also change their associated group.

Parameters
name the group name with which to associate the radio button
label this radio button's html label

public RadioButton (String name, String label)

Creates a new radio associated with a particular group, and initialized with the given HTML label. All radio buttons associated with the same group name belong to a mutually-exclusive set. Radio buttons are grouped by their name attribute, so changing their name using the setName() method will also change their associated group.

Parameters
name the group name with which to associate the radio button
label this radio button's label

public RadioButton (String name, String label, boolean asHTML)

Creates a new radio button associated with a particular group, and initialized with the given label (optionally treated as HTML). All radio buttons associated with the same group name belong to a mutually-exclusive set. Radio buttons are grouped by their name attribute, so changing their name using the setName() method will also change their associated group.

Parameters
name name the group with which to associate the radio button
label this radio button's label
asHTML true to treat the specified label as HTML

Public Methods

public void onBrowserEvent (Event event)

Overridden to send ValueChangeEvents only when appropriate.

Parameters
event the event received

public void setName (String name)

Change the group name of this radio button. Radio buttons are grouped by their name attribute, so changing their name using the setName() method will also change their associated group. If changing this group name results in a new radio group with multiple radio buttons selected, this radio button will remain selected and the other radio buttons will be unselected.

Parameters
name name the group with which to associate the radio button

public void sinkEvents (int eventBitsToAdd)

Overridden to defer the call to super.sinkEvents until the first time this widget is attached to the dom, as a performance enhancement. Subclasses wishing to customize sinkEvents can preserve this deferred sink behavior by putting their implementation behind a check of isOrWasAttached():

 @Override
 public void sinkEvents(int eventBitsToAdd) {
   if (isOrWasAttached()) {
     /* customized sink code goes here */
   } else {
     super.sinkEvents(eventBitsToAdd);
  }
} 

Parameters
eventBitsToAdd a bitfield representing the set of events to be added to this element's event set

Protected Methods

protected void ensureDomEventHandlers ()

No-op. CheckBox's click handler is no good for radio button, so don't use it. Our event handling is all done in onBrowserEvent(Event)