import java.awt.*;
import java.awt.event.*;
class Radio implements ItemListener
{
Frame fr;
Panel p;
CheckboxGroup cgp;
Checkbox c1,c2,c3;
private String msg;
public Radio()
{
fr=new Frame("RADIO BUTTON");
p=new Panel();
cgp=new CheckboxGroup();
c1=new Checkbox("CASH",cgp,true);
c2=new Checkbox("CHEQUE",cgp,false);
c3=new Checkbox("DEMAND DRAFT",cgp,false);
p.add(c1);
p.add(c2);
p.add(c3);
c1.addItemListener(this);
c2.addItemListener(this);
c3.addItemListener(this);
fr.add(p);
fr.addWindowListener(new wclose());
fr.setSize(800,800);
fr.setVisible(true);
}
public void itemStateChanged(ItemEvent ie)
{
if(ie.getSource()==c1)
{
if(c1.getState()==true)
System.out.println(c1.getLabel());
}
if(ie.getSource()==c2)
{
if(c2.getState()==true)
System.out.println(c2.getLabel());
}
if(ie.getSource()==c3)
{
if(c3.getState()==true)
System.out.println(c3.getLabel());
}
}
public void actionPerformed(ActionEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}
private void paint() {
throw new UnsupportedOperationException("Not yet implemented");
}
}
class wclose extends WindowAdapter
{
@Override
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
}
public class UseRadio
{
public static void main(String args[])
{
Radio robj=new Radio();
}
}
import java.awt.event.*;
class Radio implements ItemListener
{
Frame fr;
Panel p;
CheckboxGroup cgp;
Checkbox c1,c2,c3;
private String msg;
public Radio()
{
fr=new Frame("RADIO BUTTON");
p=new Panel();
cgp=new CheckboxGroup();
c1=new Checkbox("CASH",cgp,true);
c2=new Checkbox("CHEQUE",cgp,false);
c3=new Checkbox("DEMAND DRAFT",cgp,false);
p.add(c1);
p.add(c2);
p.add(c3);
c1.addItemListener(this);
c2.addItemListener(this);
c3.addItemListener(this);
fr.add(p);
fr.addWindowListener(new wclose());
fr.setSize(800,800);
fr.setVisible(true);
}
public void itemStateChanged(ItemEvent ie)
{
if(ie.getSource()==c1)
{
if(c1.getState()==true)
System.out.println(c1.getLabel());
}
if(ie.getSource()==c2)
{
if(c2.getState()==true)
System.out.println(c2.getLabel());
}
if(ie.getSource()==c3)
{
if(c3.getState()==true)
System.out.println(c3.getLabel());
}
}
public void actionPerformed(ActionEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}
private void paint() {
throw new UnsupportedOperationException("Not yet implemented");
}
}
class wclose extends WindowAdapter
{
@Override
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
}
public class UseRadio
{
public static void main(String args[])
{
Radio robj=new Radio();
}
}
Comments
Post a Comment