KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > google > gwt > user > client > ui > RadioButton


1 /*
2  * Copyright 2006 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations under
14  * the License.
15  */

16 package com.google.gwt.user.client.ui;
17
18 import com.google.gwt.user.client.DOM;
19
20 /**
21  * A mutually-exclusive selection radio button widget.
22  *
23  * <p>
24  * <img class='gallery' SRC='RadioButton.png'/>
25  * </p>
26  *
27  * <h3>CSS Style Rules</h3>
28  * <ul class='css'>
29  * <li>.gwt-RadioButton { }</li>
30  * </ul>
31  *
32  * <p>
33  * <h3>Example</h3> {@example com.google.gwt.examples.RadioButtonExample}
34  * </p>
35  */

36 public class RadioButton extends CheckBox {
37
38   /**
39    * Creates a new radio associated with a particular group. All radio buttons
40    * associated with the same group name belong to a mutually-exclusive set.
41    *
42    * @param group the group with which to associate the radio button
43    */

44   public RadioButton(String JavaDoc group) {
45     super(DOM.createInputRadio(group));
46     setStyleName("gwt-RadioButton");
47   }
48
49   /**
50    * Creates a new radio associated with a particular group, and initialized
51    * with the given HTML label. All radio buttons associated with the same group
52    * name belong to a mutually-exclusive set.
53    *
54    * @param group the group with which to associate the radio button
55    * @param label this radio button's label
56    */

57   public RadioButton(String JavaDoc group, String JavaDoc label) {
58     this(group);
59     setText(label);
60   }
61
62   /**
63    * Creates a new radio button associated with a particular group, and
64    * initialized with the given label (optionally treated as HTML). All radio
65    * buttons associated with the same group name belong to a mutually-exclusive
66    * set.
67    *
68    * @param group the group with which to associate the radio button
69    * @param label this radio button's label
70    * @param asHTML <code>true</code> to treat the specified label as HTML
71    */

72   public RadioButton(String JavaDoc group, String JavaDoc label, boolean asHTML) {
73     this(group);
74     if (asHTML) {
75       setHTML(label);
76     } else {
77       setText(label);
78     }
79   }
80 }
81
Popular Tags