-
Book Overview & Buying
-
Table Of Contents
Google Web Toolkit 2 Application Development Cookbook
By :
The radio button is used when there are some predefined options from which only a single option is selected for a field. In this recipe, we are going to create radio buttons to use as options for the gender of a person. A radio group is a group of radio buttons which allows selecting only a single radio in the group.
Import the class com.extjs.gxt.ui.client.widget.form.Radio.
Create an instance for each of the options as shown:
Radio maleRadio = new Radio(); Radio femaleRadio = new Radio();
Set a label for each instance appearing beside the radio. The code for the same is as below:
maleRadio.setBoxLabel("Male");
femaleRadio.setBoxLabel("Female");
Create a RadioGroup instance:
RadioGroup genderGroup = new RadioGroup();
Set a label for RadioGroup as shown:
genderGroup.setFieldLabel("Gender");
Add all the radio instances in the RadioGroup instance:
genderGroup.add(maleRadio); genderGroup.add(femaleRadio);
Add the radio group in the required form, panel, or widget...
Change the font size
Change margin width
Change background colour