Java AWT CheckboxGroup
Java AWT CheckboxGroup
At a time only one check box button is allowed to be in "on" state and remaining check box button in "off"
state. It inherits the object class.
Note: CheckboxGroup enables you to create radio buttons in AWT. There is no special control for
creating radio buttons in AWT.
1. import java.awt.*;
2. public class CheckboxGroupExample
3. {
4. CheckboxGroupExample(){
5. Frame f= new Frame("CheckboxGroup Example");
6. CheckboxGroup cbg = new CheckboxGroup();
7. Checkbox checkBox1 = new Checkbox("C++", cbg, false);
8. checkBox1.setBounds(100,100, 50,50);
9. Checkbox checkBox2 = new Checkbox("Java", cbg, true);
Dr Bharti Sharma
Output:
Dr Bharti Sharma
1. import java.awt.*;
2. import java.awt.event.*;
3. public class CheckboxGroupExample
4. {
5. CheckboxGroupExample(){
6. Frame f= new Frame("CheckboxGroup Example");
7. final Label label = new Label();
8. label.setAlignment(Label.CENTER);
9. label.setSize(400,100);
Dr Bharti Sharma
34. }
Output: