All About Class CheckboxGroup in AWT in Java

0
135
Spread the love
  • 28
  • 34
  • 28
  • 35
  •  
  •  
  •  
  • 12
  •  
  •  
    137
    Shares

CheckboxGroup in AWT in Java
CheckboxGroup in AWT in Java

CheckboxGroup in AWT in Java:

CheckboxGroup groups a set of check buttons or Radio buttons.Exactly one checkbox button in a┬áCheckboxGroup can be in the “ON” state at any given point of time.Pushing any button turns it in and forces any other button that is “ON” to become “OFF”.When a checkbox in a checkbox group is clicked,AWT sends an action event to that checkbox.This event’s target is the checkbox and its object is a value equal to Boolean.TRUE.No action event is sent to the checkbox(if any) that is turned off.An application should override the action method of the checkbox or one of its parent containers in order to cause some action to occur.
CheckboxGroup or Radio buttons have all the methods same as checkboxes but appears as Circles where only one of the group can be selected if the checkbox items are made members of a CheckboxGroup.Java allows us to have several groups of radio buttons on a page as long as we make each set members of a different CheckboxGroup.

The class structure of the CheckboxGroup is given as:


public class java.awt.CheckboxGroup extends java.lang.Object{
//constructors
public CheckboxGroup();// default constructor,creates a new CheckboxGroup.
//methods:
public Checkbox getContext();
public void setContent(Checkbox box);
public String toString();
}
 

One example:


CheckboxGroup maleFemale=new CheckboxGroup();
Checkbox male=new Checkbox("male",maleFemale,true);
Checkbox female=new Checkbox("female",maleFemale,false);
 
Don't miss out!
Subscribe To Newsletter

Receive top technical news, lesson ideas, travel tips and more!

Invalid email address
Give it a try. You can unsubscribe at any time.

Spread the love
  • 28
  • 34
  • 28
  • 35
  •  
  •  
  •  
  • 12
  •  
  •  
    137
    Shares

LEAVE A REPLY

Please enter your comment!
Please enter your name here