AWT package is used for components and awt. event package is used for the action performed. If we want to select only one option, we use checkboxes.CheckboxGroup is a set of checkboxes in which we can select only one option(checkbox). The checkboxes that are set in CheckboxGroup are called “radio buttons”.
Java Abstract Window ToolKit(AWT Example)
import java.awt.*;
import java.awt.event.*;
public class lcdd extends Frame implements ActionListener
{
CheckboxGroup cbb;
Checkbox oo1,ff;
Label l1;
Button oo;
public lcdd()
{
setBackground(Color.pink);
cbb=new CheckboxGroup();
oo1=new Checkbox(“on”,true,cbb);
ff=new Checkbox(“off”,false,cbb);
oo=new Button(“Ok”);
setLayout(null);
l1=new Label(“XCnotes.com”);
l1.setBounds(225,100,100,10);
oo.setBounds(300,500,50,20);
oo1.setBounds(300,450,50,20);
ff.setBounds(370,450,50,20);
add(oo);
add(l1);
add(oo1);
add(ff);
oo.addActionListener(this);
}
public void actionPerformed(ActionEvent eh)//click event on button
{
if(eh.getSource()==oo)//when we click on this button the repaint() called
{
repaint();
}}
public void paint(Graphics gl)
{
if(oo1.getState())
{
gl.drawRect(100,100,300,200);
gl.fillRect(100,100,300,200);
Image piic=Toolkit.getDefaultToolkit().getImage(“awt.jpg”);//pic displayed in the lcd
gl.drawImage(piic,110,110,280,180,this); //draw the image
gl.fillRect(230,300,30,50);
gl.fillOval(170,330,150,100);
}
else
{
gl.drawRect(100,100,300,200);
gl.fillRect(100,100,300,200);
gl.fillRect(230,300,30,50);
gl.fillOval(170,330,150,100);
}
}
public static void main(String aa[])
{
lcdd lc=new lcdd();//lc is the object of class lcdd
lc.setSize(300,300); //we can set the size of the frame by using setSize()
lc.setVisible(true);
lc.addWindowListener(new WindowAdapter() //for window closing
{
public void windowClosing(WindowEvent ew) /*when we click on close, then this event perform*/
{
System.exit(0); //for closing
}
});
}
}

Explanation…
In the above example, when we select the checkbox and click on the button, the image will be shown, and when we deselect the checkbox and click on the button, the image will not show (like switching on and off)