CheckboxGroup in Advance Java Programming with Source Code


  * CheckboxGroup*

1) CheckboxGroup is a java.awt class which is used to create mutually 
     exclusive Checkbox.(RadioButton)
 
2) For Example:-
  Select Your Gender:-   O Male
                                      O Female
                                      O other  

3) To create this,we use Checkbox class in which CheckboxGroup is a
     specified as a parameter.

*Methods:-

(1)getSelectedCheckbox() 
      Syntax:-[Checkbox getSelectedCheckbox()]
-Return the object of currently selected Checkbox. 

(2)setSelectedCheckbox() 
      Syntax:-[void setSelectedCheckbox(Checkbox which)]
-It select Checkbox through program control whose object is specified 
  as a parameter.


*Program:-


import java.awt.*;
class CheckDemo extends Frame
{
Label l1;
Checkbox c1,c2,c3;
CheckboxGroup cbGroup;
CheckDemo()
{
setVisible(true);
setSize(400,300);
setTitle("Radio Button");
setLayout(new FlowLayout());
l1=new Label("Select Your Gender :-");
cbGroup=new CheckboxGroup();
c1=new Checkbox("Male",false,cbGroup);
c2=new Checkbox("Female",false,cbGroup);
c3=new Checkbox("Other",false,cbGroup);
add(l1);
add(c1);
add(c2);
add(c3);
}
public static void main(String args[])
{
new CheckDemo();
}
}    


                                                                    
 








 Tejas  Nalawade                                                             

Comments

Post a Comment

Popular posts from this blog

Checkbox with source code