import java.awt.*;
import java.awt.event.*;
class ChkBox implements ItemListener
{
Frame fr;
Panel p;
Checkbox c1,c2,c3;
private String msg;
public ChkBox()
{
fr=new Frame("CHECK BOX");
p=new Panel();
c1=new Checkbox("ONE");
c2=new Checkbox("TWO");
c3=new Checkbox("THREE");
p.add(c1);
p.add(c2);
p.add(c3);
c1.addItemListener(this);
c2.addItemListener(this);
c3.addItemListener(this);
fr.add(p);
fr.addWindowListener(new close());
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 close extends WindowAdapter
{
@Override
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
}
public class UseCheckBox {
public static void main(String args[])
{
ChkBox chk=new ChkBox();
}
}
import java.awt.event.*;
class ChkBox implements ItemListener
{
Frame fr;
Panel p;
Checkbox c1,c2,c3;
private String msg;
public ChkBox()
{
fr=new Frame("CHECK BOX");
p=new Panel();
c1=new Checkbox("ONE");
c2=new Checkbox("TWO");
c3=new Checkbox("THREE");
p.add(c1);
p.add(c2);
p.add(c3);
c1.addItemListener(this);
c2.addItemListener(this);
c3.addItemListener(this);
fr.add(p);
fr.addWindowListener(new close());
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 close extends WindowAdapter
{
@Override
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
}
public class UseCheckBox {
public static void main(String args[])
{
ChkBox chk=new ChkBox();
}
}
Comments
Post a Comment